[PATCH] Draw default branch on graph with bold line

Constantine theaspect at gmail.com
Fri Jan 6 03:17:58 UTC 2012


# HG changeset patch
# User Constantine Linnick <theaspect at gmail.com>
# Date 1325818775 -25200
# Node ID 3bc9c187e173544a33080eafb9372bc9bef229d0
# Parent  371cff9610cdf6d6a7e1a6238ce75441b8107f03
Draw default branch on graph with bold line

diff -r 371cff9610cd -r 3bc9c187e173 mercurial/graphmod.py
--- a/mercurial/graphmod.py    Tue Jan 03 17:13:03 2012 -0600
+++ b/mercurial/graphmod.py    Fri Jan 06 09:59:35 2012 +0700
@@ -16,7 +16,6 @@
 context of the graph returned. Type is a constant specifying the node type.
 Data depends on type.
 """
-
 from mercurial.node import nullrev

 CHANGESET = 'C'
@@ -67,7 +66,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 +82,11 @@
     seen = []
     colors = {}
     newcolor = 1
+    defaults = {}
+
+    for (branch, style) in repo.ui.configitems('graph'):
+        defaults[branch] = style.split()
+
     for (cur, type, data, parents) in dag:

         # Compute seen and next
@@ -111,10 +115,10 @@
         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],
defaults[repo[eid].branch()] if defaults.has_key(repo[eid].branch()) else
None))
             elif eid == cur:
                 for p in parents:
-                    edges.append((ecol, next.index(p), color))
+                    edges.append((ecol, next.index(p), color,
defaults[repo[p].branch()] if defaults.has_key(repo[eid].branch()) else
None))

         # Yield and move on
         yield (cur, type, data, (col, color), edges)
diff -r 371cff9610cd -r 3bc9c187e173 mercurial/help/config.txt
--- a/mercurial/help/config.txt    Tue Jan 03 17:13:03 2012 -0600
+++ b/mercurial/help/config.txt    Fri Jan 06 09:59:35 2012 +0700
@@ -534,6 +534,23 @@
     option ensures that the on-disk format of newly created
     repositories will be compatible with Mercurial before version 1.7.

+``graph``
+"""""""""
+
+This section specifies branch names which will be enbolden on graph
+to visually distinguish "main branch" or trunk in central repository
+graph.
+
+Format branch_name = number, where number is width in px. If width
+is not specified, it will be 3px width.
+
+Example::
+  [graph]
+  default = 2px
+  # graph line will be 3px width
+  stable =
+
+
 ``merge-patterns``
 """"""""""""""""""

diff -r 371cff9610cd -r 3bc9c187e173 mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py    Tue Jan 03 17:13:03 2012 -0600
+++ b/mercurial/hgweb/webcommands.py    Fri Jan 06 09:59:35 2012 +0700
@@ -770,7 +770,7 @@
         startrev = uprev

     dag = graphmod.dagwalker(web.repo, range(startrev, downrev - 1, -1))
-    tree = list(graphmod.colored(dag))
+    tree = list(graphmod.colored(dag,web.repo))
     canvasheight = (len(tree) + 1) * bg_height - 27
     data = []
     for (id, type, ctx, vtx, edges) in tree:
diff -r 371cff9610cd -r 3bc9c187e173 mercurial/templates/static/mercurial.js
--- a/mercurial/templates/static/mercurial.js    Tue Jan 03 17:13:03 2012
-0600
+++ b/mercurial/templates/static/mercurial.js    Fri Jan 06 09:59:35 2012
+0700
@@ -113,8 +113,13 @@
                 x1 = this.cell[0] + this.box_size * end + this.box_size /
2;
                 y1 = this.bg[1] + this.bg_height / 2;

-                this.edge(x0, y0, x1, y1, color);
-
+                if(line[3]){
+                    this.ctx.lineWidth = line[3][0] ? line[3][0] : 3;
+                    this.edge(x0, y0, x1, y1, color);
+                    this.ctx.lineWidth = 1;
+                }else{
+                    this.edge(x0, y0, x1, y1, color);
+                }
             }

             // Draw the revision node in the right column
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20120106/bd8cd0fe/attachment-0002.html>


More information about the Mercurial-devel mailing list