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/graph.py b/tortoisehg/hgqt/graph.py
    --- a/tortoisehg/hgqt/graph.py
    +++ b/tortoisehg/hgqt/graph.py
    @@ -101,14 +101,13 @@
                     curr_rev -= 1
                     continue
                 revs.append(curr_rev)
    -            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:
                         break
    -                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:
                     parents_to_add.append(parent)
                     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/repomodel.py b/tortoisehg/hgqt/repomodel.py
    --- a/tortoisehg/hgqt/repomodel.py
    +++ b/tortoisehg/hgqt/repomodel.py
    @@ -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)))
                     lpen.setWidth(2)
                     painter.setPen(lpen)
                     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 ProjectModifiedEvent.java.
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.