1. TortoiseHg
  2. TortoiseHg
  3. thg

Commits

Hidetaka Iwata  committed 7ad6d98

graph: assign different color to first ancestors line and second ancestors line

assign different color to first ancestors line and second ancestors line
even when they seem one straight line.

draw asterisked edges in the color different from plused edge
(x is hidden revision)
|+
o
:\*
: o
x |*

  • Participants
  • Parent commits c2382ce
  • Branches default

Comments (0)

Files changed (2)

File tests/graph_test.py

View file
  • Ignore whitespace
     repo = openrepo('straightened-by-revset')
     revset = set([0, 1, 2, 4, 6, 7]) # exclude 3, 5
     grapher = graph.revision_grapher(repo, {"revset": revset})
-    c0 = 0
+    c0, c1 = 0, 1
     actualtable = buildlinecolortable(grapher)
     expectedtable = {
                               # 7
         7: [c0],              # |
                               # 6
-        6: [c0],              #  \
+        6: [c1],              #  \
                               #   4
-        4: [c0],              #   |
+        4: [c1],              #   |
                               #   2
         2: [c0],              #  /
                               # 1
     repo = openrepo('straightened-by-revset')
     revset = set([0, 1, 2, 3, 4, 6, 7]) # exclude 5
     grapher = graph.revision_grapher(repo, {"revset": revset})
-    c0 = 0
+    c0, c1 = 0, 1
     actualtable = buildlinecolortable(grapher)
     expectedtable = {
                               # 7
         7: [c0],              # |
                               # 6
-        6: [c0],              # |
+        6: [c1],              # |
                               # 4
-        4: [c0],              # |
+        4: [c1],              # |
                               # | 3
-        3: [c0, c0],          # | |
+        3: [c1, c0],          # | |
                               # 2 |
         2: [c0, c0],          # |/
                               # 1
     repo = openrepo('straightened-by-revset')
     revset = set([0, 1, 2, 3, 6, 7]) # exclude 4, 5
     grapher = graph.revision_grapher(repo, {"revset": revset})
-    c0 = 0
+    c0, c1 = 0, 1
     actualtable = buildlinecolortable(grapher)
     expectedtable = {
                               # 7
     repo = openrepo('straightened-by-revset')
     revset = set([0, 1, 3, 4, 6, 7]) # exclude 2, 5
     grapher = graph.revision_grapher(repo, {"revset": revset})
-    c0 = 0
+    c0, c1 = 0, 1
     actualtable = buildlinecolortable(grapher)
     expectedtable = {
                               # 7
         7: [c0],              # |
                               # 6
-        6: [c0],              #  \
+        6: [c1],              #  \
                               #   4
         4: [],                #
                               # 3

File tortoisehg/hgqt/graph.py

View file
  • Ignore whitespace
                 if stop_rev <= src_rev < curr_rev and not hidden(src_rev):
                     parents.append((octx, LINE_TYPE_OBSOLETE))
         parents_to_add = []
-        for pno, (pctx, link_type) in enumerate(parents):
+        for pctx, link_type in parents:
             parent = pctx.rev()
             if parent not in next_revs:
                 # Because the parents originate from multiple sources, it is
                 if parent in parents_to_add:
                     continue
                 parents_to_add.append(parent)
-            if pno == 0:
-                color = rev_color.get(pctx, rev_color.get(ctx))
-            else:
-                color = rev_color.get(pctx)
+            color = rev_color[pctx]
             activeedges.append(GraphEdge(curr_rev, parent, color, link_type))
 
         # parents_to_add.sort()
         self._curcolor += 1
         return self._curcolor
 
-    def get(self, ctx, default=None):
+    def __getitem__(self, ctx):
         rev = ctx.rev()
         if rev not in self._knowncolors:
             self._fillpendingheads(rev)
             if rev not in self._knowncolors:
-                if default is None:
-                    color = self.nextcolor()
-                else:
-                    color = default
+                color = self.nextcolor()
                 self._knowncolors[rev] = color
                 p_ctxs = self._getparents(ctx)
                 self._pendingheads.append((p_ctxs, color))