Commits

Hidetaka Iwata committed c2382ce

graph: add tests about graph straightened by revset

Comments (0)

Files changed (1)

     setup_20nodes()
     setup_20patches()
     setup_nestedbranch()
+    setup_straightenedbyrevset()
 
 def openrepo(name):
     return hg.repository(ui.ui(), os.path.join(_tmpdir, name))
         }
     assert_equal(expectedtable, actualtable)
 
+def setup_straightenedbyrevset():
+    buildrepo('straightened-by-revset', r"""
+        7
+        6
+        |\
+        5 |
+        | 4
+        3 |
+        | 2
+        |/
+        1
+        0
+    """)
+
+def test_linecolor_straightened_by_revset():
+    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
+    actualtable = buildlinecolortable(grapher)
+    expectedtable = {
+                              # 7
+        7: [c0],              # |
+                              # 6
+        6: [c0],              #  \
+                              #   4
+        4: [c0],              #   |
+                              #   2
+        2: [c0],              #  /
+                              # 1
+        1: [c0],              # |
+                              # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_linecolor_straightened_by_revset_2():
+    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
+    actualtable = buildlinecolortable(grapher)
+    expectedtable = {
+                              # 7
+        7: [c0],              # |
+                              # 6
+        6: [c0],              # |
+                              # 4
+        4: [c0],              # |
+                              # | 3
+        3: [c0, c0],          # | |
+                              # 2 |
+        2: [c0, c0],          # |/
+                              # 1
+        1: [c0],              # |
+                              # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_linecolor_straightened_by_revset_3():
+    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
+    actualtable = buildlinecolortable(grapher)
+    expectedtable = {
+                              # 7
+        7: [c0],              # |
+                              # 6
+        6: [],                #
+                              # 3
+        3: [c0],              # |
+                              # | 2
+        2: [c0, c0],          # |/
+                              # 1
+        1: [c0],              # |
+                              # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)
+
+def test_linecolor_straightened_by_revset_4():
+    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
+    actualtable = buildlinecolortable(grapher)
+    expectedtable = {
+                              # 7
+        7: [c0],              # |
+                              # 6
+        6: [c0],              #  \
+                              #   4
+        4: [],                #
+                              # 3
+        3: [c0],              # |
+                              # 1
+        1: [c0],              # |
+                              # 0
+        0: [],
+        }
+    assert_equal(expectedtable, actualtable)