Commits

Hidetaka Iwata committed fb748a5

graph: assign different colors to each graft lines

Comments (0)

Files changed (2)

tests/graph_test.py

     setup_20patches()
     setup_nestedbranch()
     setup_straightenedbyrevset()
+    setup_bulkgraft()
 
 def openrepo(name):
     return hg.repository(ui.ui(), os.path.join(_tmpdir, name))
         0: [],
         }
     assert_equal(expectedtable, actualtable)
+
+def setup_bulkgraft():
+    buildrepo('bulkgraft', r"""
+    7 [source=3]
+    6 [source=2]
+    5 [source=1]
+    4
+    | 3
+    | 2
+    | 1
+    |/
+    0
+    """)
+
+def test_linecolor_bulkgraft():
+    repo = openrepo('bulkgraft')
+    grapher = graph.revision_grapher(repo, {"showgraftsource": True})
+    c0, c1, c2, c3, c4 = 0, 1, 2, 3, 4
+    actualtable = buildlinecolortable(grapher)
+    expectedtable = {
+                                # wt
+        None: [c0],             # |
+                                # 7
+        7: [c0, c1],            # |\
+                                # 6 .
+        6: [c0, c2, c1],        # |\ \
+                                # 5 . .
+        5: [c0, c3, c2, c1],    # |\ \ \
+                                # 4 : : :
+        4: [c0, c3, c2, c1],    # | : : :
+                                # | : : 3
+        3: [c0, c3, c2, c4],    # | : :/
+                                # | : 2
+        2: [c0, c3, c4],        # | :/
+                                # | 1
+        1: [c0, c4],            # |/
+                                # 0
+        0: [],
+    }
+    assert_equal(expectedtable, actualtable)
+

tortoisehg/hgqt/graph.py

                 parents_to_add.append(parent)
             if is_p1:
                 color = rev_color[ctx]
+            elif link_type in (LINE_TYPE_GRAFT, LINE_TYPE_OBSOLETE):
+                color = rev_color.nextcolor()
             else:
                 color = rev_color[pctx]
             activeedges.append(GraphEdge(curr_rev, parent, color, link_type))