# HG changeset patch # User Henrik Stuart <h...@hstuart.dk> # Date 1253992710 -7200 # Node ID ed864cd7d9e9338fbe06afe41b8278285e87396e # Parent aa219b19c42f94d24996866dc17658170d6a7278 logview: support configuration-defined colors for named branches
diff -r aa219b19c42f -r ed864cd7d9e9 doc/source/changelog.txt --- a/doc/source/changelog.txt Sat Sep 26 21:05:49 2009 +0200 +++ b/doc/source/changelog.txt Sat Sep 26 21:18:30 2009 +0200 @@ -209,6 +209,12 @@ :guilabel:`Dead Branches` Comma separated list of branch names that should be ignored when building a list of branch names for a repository. + :guilabel:`Branch Colors` + Space separated list of branch names and colors on the + form branch:#XXXXXX. Spaces and colons in the branch name must be + escaped using a backslash (\\). Likewise some other characters + can be escaped in this way, e.g. \\u0040 will be decoded to the + @ character, and \\n to a linefeed. The exact colors given to particular users can be configured by adding lines like these to your :file:`Mercurial.ini` file: :: diff -r aa219b19c42f -r ed864cd7d9e9 tortoisehg/hgtk/logview/graphcell.py --- a/tortoisehg/hgtk/logview/graphcell.py Sat Sep 26 21:05:49 2009 +0200 +++ b/tortoisehg/hgtk/logview/graphcell.py Sat Sep 26 21:18:30 2009 +0200 @@ -97,10 +97,14 @@ ( 1.0, 0.0, 1.0 ), ] - if colour == 0: - colour_rgb = mainline_color + if isinstance(colour, str): + r, g, b = colour[1:3], colour[3:5], colour[5:7] + colour_rgb = int(r, 16) / 255., int(g, 16) / 255., int(b, 16) / 255. else: - colour_rgb = colours[colour % len(colours)] + if colour == 0: + colour_rgb = mainline_color + else: + colour_rgb = colours[colour % len(colours)] red = (colour_rgb[0] * fg) or bg green = (colour_rgb[1] * fg) or bg diff -r aa219b19c42f -r ed864cd7d9e9 tortoisehg/hgtk/logview/revgraph.py --- a/tortoisehg/hgtk/logview/revgraph.py Sat Sep 26 21:05:49 2009 +0200 +++ b/tortoisehg/hgtk/logview/revgraph.py Sat Sep 26 21:18:30 2009 +0200 @@ -51,14 +51,56 @@ __copyright__ = "Copyright 2007 Joel Rosdahl, 2008 Steve Borho" __author__ = "Joel Rosdahl <j...@rosdahl.net>, Steve Borho <st...@borho.org>" +import re + from mercurial.node import nullrev from mercurial import cmdutil, util +from tortoisehg.util import hglib + def __get_parents(repo, rev): return [x for x in repo.changelog.parentrevs(rev) if x != nullrev] +known_branch_colors = None # cache for repository colour configuration + +def _get_known_branch_colors(repo): + global known_branch_colors + + repo_setting = repo.ui.config('tortoisehg', 'branchcolors') + + if known_branch_colors: + branch_colors, setting = known_branch_colors + if repo_setting == setting: + return branch_colors + + branchcolors = repo_setting + if not branchcolors: + return None + + branchcolors = hglib.tounicode(branchcolors).decode('unicode_escape') + branchcolors = [x for x in re.split(r'(?<!\\) ', branchcolors) if x] + values = {} + for branchcolor in branchcolors: + parts = re.split(r'(?<!\\):', branchcolor) + if len(parts) != 2: + continue # ignore badly formed entry + + # Mercurial branch names are encoded in utf-8 so we must + # make sure to encode back to that after having unescaped + # the string. + values[hglib.toutf(parts[0])] = hglib.toutf(parts[1]) + + known_branch_colors = values, repo_setting + return values + def _color_of_branch(repo, rev): branch = repo[rev].branch() + + candidates = _get_known_branch_colors(repo) + + if branch in candidates: + return candidates[branch] + if branch == 'default': color = 0 else: diff -r aa219b19c42f -r ed864cd7d9e9 tortoisehg/hgtk/thgconfig.py --- a/tortoisehg/hgtk/thgconfig.py Sat Sep 26 21:05:49 2009 +0200 +++ b/tortoisehg/hgtk/thgconfig.py Sat Sep 26 21:18:30 2009 +0200 @@ -116,6 +116,13 @@ _('Comma separated list of branch names that should be ignored' ' when building a list of branch names for a repository.' ' Default: None')), + (_('Branch Colors'), 'tortoisehg.branchcolors', [], + _('Space separated list of branch names and colors on the form' + ' branch:#XXXXXX. Spaces and colons in the branch name must be' + ' escaped using a backslash (\\). Likewise some other characters' + ' can be escaped in this way, e.g. \\u0040 will be decoded to the' + ' @ character, and \\n to a linefeed.' + ' Default: None')), ) _paths_info = ( ------------------------------------------------------------------------------ Come build with us! The BlackBerry® Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9-12, 2009. Register now! http://p.sf.net/sfu/devconf _______________________________________________ Tortoisehg-develop mailing list Tortoisehg-develop@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tortoisehg-develop