Branch colors not working

Anonymous avatarAnonymous created an issue

I recently upgraded to TortoiseHg 2.1.2. I used branch coloring extensively, with this line in my hgrc:

branchcolors = release:#FF0000 test:#00FF00 development:#0000FF

That is, release was red, test was green, and development was blue. Now when I load it, release is blue, development is green, and test is red. Trying to change the colors hasn't helped. It seems like it's randomly assigning those 3 colors to those branches.

Comments (5)

  1. Eduard-Cristian Stefan

    I have started to work on it a few weeks ago, but I'm not very sure if it's the right way to do it (so no config bits for now). If someone else has a better idea, please improve it.

    diff --git a/tortoisehg/hgqt/ b/tortoisehg/hgqt/
    --- a/tortoisehg/hgqt/
    +++ b/tortoisehg/hgqt/
    @@ -101,14 +101,13 @@
                     curr_rev -= 1
    -            rev_color[curr_rev] = curcolor = nextcolor
    -            nextcolor += 1
    +            rev_color[curr_rev] = ctx.branch()
                 p_revs = getparents(ctx)
                 while p_revs:
                     rev0 = p_revs[0]
                     if rev0 < stop_rev or rev0 in rev_color:
    -                rev_color[rev0] = curcolor
    +                rev_color[rev0] = repo[rev0].branch()
                     p_revs = getparents(repo[rev0])
             curcolor = rev_color[curr_rev]
             rev_index = revs.index(curr_rev)
    @@ -129,12 +128,7 @@
                 if parent not in next_revs:
                     if parent not in rev_color:
    -                    if preferred_color:
    -                        rev_color[parent] = preferred_color
    -                        preferred_color = None
    -                    else:
    -                        rev_color[parent] = nextcolor
    -                        nextcolor += 1
    +                    rev_color[parent] = repo[parent].branch()
                 preferred_color = None
             # parents_to_add.sort()
    diff --git a/tortoisehg/hgqt/ b/tortoisehg/hgqt/
    --- a/tortoisehg/hgqt/
    +++ b/tortoisehg/hgqt/
    @@ -100,7 +100,7 @@
             # To be deleted
             self._user_colors = {}
    -        self._branch_colors = {}
    +        self._branch_colors = {'default':'green', 'stable': 'blue', 'PROD':'red'}
             self._columnmap = {
                 'Rev':      self.getrev,
    @@ -318,7 +318,7 @@
                 for start, end, color in lines:
                     lpen = QPen(pen)
    -                lpen.setColor(QColor(get_color(color)))
    +                lpen.setColor(QColor(self.namedbranch_color(color)))
                     x1 = self.col2x(start) 
  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.