[log] IDEA-117500 Optimize grouping of branch references

Instead of iterating over the list of all branches for each passed
VcsRef, do the following:
* group refs by root
* for each root prepare sets and map of local branches,
  tracked remote branched and non-tracked remote branches.
* for each ref in this root check if it is contained in one of the sets.
[log] IDEA-117500 Don't repaint branches panel on every updateUI

VcsLogUI.updateUI is called frequently (e.g. almost on every click),
in particular to repaint the graph and highlight the currently
selected branch.

And the BranchesPanel should be repainted only when the set of
branches changes, which may happen only on refresh => subscribe the
panel to git-log-refresh events and rebuild the panel then.