Commits

Hidetaka Iwata committed 9bbc22d

graph_test: make buildlinecolortable reusable

  • Participants
  • Parent commits d879202
  • Branches stable

Comments (0)

Files changed (1)

File tests/graph_test.py

     path = os.path.join(_tmpdir, name)
     helpers.buildgraph(path, graphtext)
 
-def buildlinecolortable(grapher):
-    table = {}  # rev: [linecolor, ...]
+def buildlinetable(grapher, predicate):
+    table = {}  # rev: [predicate(edge), ...
     for node in grapher:
         if not node:
             continue
         # draw overlapped lines in the same way as HgRepoListModel
-        ct = dict((p, e.color) for p, e
+        lt = dict((p, predicate(p, e)) for p, e
                   in sorted(node.bottomlines, key=lambda pe: pe[1].importance))
         # and sort them in (start, end) order
-        colors = [c for p, c in sorted(ct.iteritems(), key=lambda pc: pc[0])]
-        table[node.rev] = colors
+        lines = [l for p, l in sorted(lt.iteritems(), key=lambda pl: pl[0])]
+        table[node.rev] = lines
     return table
 
+def buildlinecolortable(grapher):
+    return buildlinetable(grapher, lambda p, e: e.color)
+
 def setup_namedbranch():
     buildrepo('named-branch', r"""
         8