1.1 --- a/tortoisehg/hgtk/logview/revgraph.py Thu Sep 17 14:03:03 2009 +0200
1.2 +++ b/tortoisehg/hgtk/logview/revgraph.py Thu Sep 17 15:09:16 2009 +0200
1.3 @@ -57,6 +57,9 @@
1.4 def __get_parents(repo, rev):
1.5 return [x for x in repo.changelog.parentrevs(rev) if x != nullrev]
1.6
1.7 +def _color_of_branch(repo, rev):
1.8 + return sum([ord(c) for c in repo[rev].branch()])
1.9 +
1.10 def _color_of(repo, rev, nextcolor, preferredcolor, branch_color=False):
1.11 if not branch_color:
1.12 if preferredcolor[0]:
1.13 @@ -67,7 +70,7 @@
1.14 nextcolor[0] = nextcolor[0] + 1
1.15 return rv
1.16 else:
1.17 - return sum([ord(c) for c in repo[rev].branch()])
1.18 + return _color_of_branch(repo, rev)
1.19
1.20 type_PLAIN = 0
1.21 type_LOOSE_LOW = 1
1.22 @@ -154,7 +157,12 @@
1.23 two branches.
1.24 """
1.25
1.26 - def __init__(self, repo, start_rev, stop_rev):
1.27 + def __init__(self, repo, start_rev, stop_rev, branch_color):
1.28 + '''
1.29 + start_rev - first (newest) changeset to cover
1.30 + stop_rev - last (oldest) changeset to cover
1.31 + branch_color - true if branch name determines colours
1.32 + '''
1.33 assert start_rev >= stop_rev
1.34 self.repo = repo
1.35
1.36 @@ -201,6 +209,9 @@
1.37
1.38 # Next colour used. for branches
1.39 self.nextcolor = 0
1.40 +
1.41 + # Flag to indicate if coloring is done pr micro-branch or pr named branch
1.42 + self.branch_color = branch_color
1.43
1.44 def _get_parents(self, rev):
1.45 return [x for x in self.repo.changelog.parentrevs(rev) if x != nullrev]
1.46 @@ -217,8 +228,12 @@
1.47 of branch_head as part of the same branch. Stops when stop_rev
1.48 is passed or a known revision is found"""
1.49 assert not branch_head in self.branch4rev
1.50 - self.color4branch[branch_head] = self.nextcolor
1.51 - self.nextcolor += 1
1.52 + if self.branch_color:
1.53 + self.color4branch[branch_head] = \
1.54 + _color_of_branch(self.repo, branch_head)
1.55 + else:
1.56 + self.color4branch[branch_head] = self.nextcolor
1.57 + self.nextcolor += 1
1.58 self.next_in_branch[branch_head] = branch_head
1.59 branch_name = self._branch_name(branch_head)
1.60 rev = branch_head
1.61 @@ -330,8 +345,8 @@
1.62 # Return result
1.63 return (rev, node, lines, None)
1.64
1.65 -def branch_grapher(repo, start_rev, stop_rev):
1.66 - grapher = BranchGrapher(repo, start_rev, stop_rev)
1.67 +def branch_grapher(repo, start_rev, stop_rev, branch_color=False):
1.68 + grapher = BranchGrapher(repo, start_rev, stop_rev, branch_color)
1.69 while grapher.more():
1.70 yield grapher.next()
1.71
2.1 --- a/tortoisehg/hgtk/logview/treeview.py Thu Sep 17 14:03:03 2009 +0200
2.2 +++ b/tortoisehg/hgtk/logview/treeview.py Thu Sep 17 15:09:16 2009 +0200
2.3 @@ -164,7 +164,8 @@
2.4 start = len(self.repo.changelog) - 1
2.5 noheads = opts.get('noheads', False)
2.6 if opts.get('branch-view', False):
2.7 - self.grapher = branch_grapher(self.repo, start, end)
2.8 + self.grapher = branch_grapher(self.repo, start, end,
2.9 + self.branch_color)
2.10 else:
2.11 self.grapher = revision_grapher(self.repo, start, end, pats,
2.12 noheads, self.branch_color)