diff mercurial/graphmod.py @ 16129:5e50982c633c

graph: in hgrc specify line width for main branch You can specify width to visually distinguish main branch (trunk) on hgweb's graph page. Settings format is branch_name.width = value, where width in px e.g.: [graph] default.width = 3
author Constantine Linnick <theaspect@gmail.com>
date Sun, 22 Jan 2012 19:35:26 +0700
parents 03e1c2d35c6a
children 33f702e52906
line wrap: on
line diff
--- a/mercurial/graphmod.py	Thu Feb 16 16:40:29 2012 -0600
+++ b/mercurial/graphmod.py	Sun Jan 22 19:35:26 2012 +0700
@@ -67,7 +67,7 @@
         parents = set([p.rev() for p in ctx.parents() if p.node() in include])
         yield (ctx.rev(), CHANGESET, ctx, sorted(parents))
 
-def colored(dag):
+def colored(dag, repo):
     """annotates a DAG with colored edge information
 
     For each DAG node this function emits tuples::
@@ -83,6 +83,20 @@
     seen = []
     colors = {}
     newcolor = 1
+    config = {}
+
+    for key, val in repo.ui.configitems('graph'):
+        if '.' not in key:
+            continue
+        branch, setting = key.rsplit('.', 1)
+        gdict = config.setdefault(branch, {})
+
+        # Validation
+        if (setting == "width" and val.isdigit() and 0 < int(val) < 30):
+            gdict[setting] = val
+        else:
+            continue
+
     for (cur, type, data, parents) in dag:
 
         # Compute seen and next
@@ -111,10 +125,14 @@
         edges = []
         for ecol, eid in enumerate(seen):
             if eid in next:
-                edges.append((ecol, next.index(eid), colors[eid]))
+                edges.append((
+                    ecol, next.index(eid), colors[eid],
+                    config.get(repo[eid].branch(), None)))
             elif eid == cur:
                 for p in parents:
-                    edges.append((ecol, next.index(p), color))
+                    edges.append((
+                        ecol, next.index(p), color,
+                        config.get(repo[p].branch(), None)))
 
         # Yield and move on
         yield (cur, type, data, (col, color), edges)