# HG changeset patch # User Constantine Linnick # Date 1327235726 -25200 # Node ID 5e50982c633c8857118d47c9b50a8e2acb7c798b # Parent 004982e5d782786ccf08edd8b34592f3acef0797 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 diff -r 004982e5d782 -r 5e50982c633c mercurial/graphmod.py --- 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) diff -r 004982e5d782 -r 5e50982c633c mercurial/help/config.txt --- a/mercurial/help/config.txt Thu Feb 16 16:40:29 2012 -0600 +++ b/mercurial/help/config.txt Sun Jan 22 19:35:26 2012 +0700 @@ -534,6 +534,27 @@ option ensures that the on-disk format of newly created repositories will be compatible with Mercurial before version 1.7. +``graph`` +""""""""" + +This section specifies line width to visually distinguish +"main branch" or trunk in central repository graph. + +Format branch_name.attribute = value. + +Example:: + [graph] + # 2px width + default.width = 2 + +Supported arguments: + +``width`` + Set width in px. Width is number 0-99. + +Known issues: + If line style doesn't change, try to clear browser cache. + ``merge-patterns`` """""""""""""""""" diff -r 004982e5d782 -r 5e50982c633c mercurial/hgweb/webcommands.py --- a/mercurial/hgweb/webcommands.py Thu Feb 16 16:40:29 2012 -0600 +++ b/mercurial/hgweb/webcommands.py Sun Jan 22 19:35:26 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 004982e5d782 -r 5e50982c633c mercurial/templates/static/mercurial.js --- a/mercurial/templates/static/mercurial.js Thu Feb 16 16:40:29 2012 -0600 +++ b/mercurial/templates/static/mercurial.js Sun Jan 22 19:35:26 2012 +0700 @@ -112,9 +112,12 @@ y0 = this.bg[1] - this.bg_height / 2; x1 = this.cell[0] + this.box_size * end + this.box_size / 2; y1 = this.bg[1] + this.bg_height / 2; - + // Width if exists + if(line[3] && line[3]['width']){ + this.ctx.lineWidth = line[3]['width']; + } this.edge(x0, y0, x1, y1, color); - + this.ctx.lineWidth = 1; } // Draw the revision node in the right column diff -r 004982e5d782 -r 5e50982c633c tests/test-hgweb-commands.t --- a/tests/test-hgweb-commands.t Thu Feb 16 16:40:29 2012 -0600 +++ b/tests/test-hgweb-commands.t Sun Jan 22 19:35:26 2012 +0700 @@ -24,6 +24,13 @@ marked working directory as branch stable (branches are permanent and global, did you want a bookmark?) $ hg ci -Ambranch + $ hg branch unstable + marked working directory as branch unstable + (branches are permanent and global, did you want a bookmark?) + $ hg ci -Ambranch + $ echo [graph] >> .hg/hgrc + $ echo default.width = 3 >> .hg/hgrc + $ echo stable.width = 3 >> .hg/hgrc $ hg serve --config server.uncompressed=False -n test -p $HGPORT -d --pid-file=hg.pid -E errors.log $ cat hg.pid >> $DAEMON_PIDS @@ -43,6 +50,22 @@ branch + http://*:$HGPORT/#changeset-ba87b23d29ca67a305625d81a20ac279c1e3f444 (glob) + (glob) + + test + test + + 1970-01-01T00:00:00+00:00 + 1970-01-01T00:00:00+00:00 + +
+
branch
+
+
+
+ + branch http://*:$HGPORT/#changeset-1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe (glob) (glob) @@ -105,6 +128,22 @@ branch + http://*:$HGPORT/#changeset-ba87b23d29ca67a305625d81a20ac279c1e3f444 (glob) + (glob) + + test + test + + 1970-01-01T00:00:00+00:00 + 1970-01-01T00:00:00+00:00 + +
+
branch
+
+
+
+ + branch http://*:$HGPORT/#changeset-1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe (glob) (glob) @@ -208,14 +247,14 @@
    @@ -237,9 +276,9 @@ @@ -251,14 +290,19 @@ - + + + + + + - + @@ -267,9 +311,9 @@
    Thu, 01 Jan 1970 00:00:00 +0000 testbranchstable tip something branchunstable tip something
    Thu, 01 Jan 1970 00:00:00 +0000 testbranchstable
    Thu, 01 Jan 1970 00:00:00 +0000test Added tag 1.0 for changeset 2ef0ac749a14default
    Thu, 01 Jan 1970 00:00:00 +0000 test base1.0 anotherthing
    @@ -637,18 +681,19 @@ $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/raw-tags' 200 Script output follows - tip 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe + tip ba87b23d29ca67a305625d81a20ac279c1e3f444 1.0 2ef0ac749a14e4f57a5a822464a0902c6f7f448f $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/raw-branches' 200 Script output follows - stable 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe open + unstable ba87b23d29ca67a305625d81a20ac279c1e3f444 open + stable 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe inactive default a4f92ed23982be056b9852de5dfe873eaac7f0de inactive $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/raw-bookmarks' 200 Script output follows anotherthing 2ef0ac749a14e4f57a5a822464a0902c6f7f448f - something 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe + something ba87b23d29ca67a305625d81a20ac279c1e3f444 $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/summary/?style=gitweb' 200 Script output follows @@ -688,7 +733,7 @@ tags | bookmarks | branches | - files | + files | help
    @@ -707,9 +752,23 @@ Thu, 01 Jan 1970 00:00:00 +0000 test + + branch + unstable tip something + + + + changeset | + files + + + + Thu, 01 Jan 1970 00:00:00 +0000 + test + branch - stable tip something + stable @@ -717,7 +776,7 @@ files - + Thu, 01 Jan 1970 00:00:00 +0000 test @@ -731,7 +790,7 @@ files - + Thu, 01 Jan 1970 00:00:00 +0000 test @@ -777,11 +836,11 @@ Thu, 01 Jan 1970 00:00:00 +0000 - something + something - changeset | - changelog | - files + changeset | + changelog | + files ... @@ -792,6 +851,16 @@ Thu, 01 Jan 1970 00:00:00 +0000 + ba87b23d29ca + unstable + + changeset | + changelog | + files + + + + Thu, 01 Jan 1970 00:00:00 +0000 1d22e65f027e stable @@ -800,7 +869,7 @@ files - + Thu, 01 Jan 1970 00:00:00 +0000 a4f92ed23982 default @@ -861,17 +930,17 @@
     
    @@ -880,14 +949,14 @@
      - +
        @@ -991,7 +1060,7 @@ $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=heads' 200 Script output follows - 1d22e65f027e5a0609357e7d8e7508cd2ba5d2fe + ba87b23d29ca67a305625d81a20ac279c1e3f444 branches @@ -1005,10 +1074,11 @@ $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '?cmd=changegroup&roots=0000000000000000000000000000000000000000' 200 Script output follows - x\x9c\xbdTMHUA\x14\xbe\xa8\xf9\xec\xda&\x10\x11*\xb8\x88\x81\x99\xbef\xe6\xce\xbdw\xc6\xf2a\x16E\x1b\x11[%\x98\xcc\xaf\x8f\x8c\xf7\xc0\xf7\x82 (esc) - 4\x11KP2m\x95\x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BO\xcf\xde\xae\xe5\xae#\x1frM(K\x97`F\x19\x16s\x05GD\xb9\x01\xc1\x00+\x8c|\x9fp\xc11\xf0\x14\x00\x9cJ\x82<\xe0\x12\x9f\xc1\x90\xd0\xf5\xc8\x19>Pr\xaa\xeaW\xf5\xc4\xae\xd1\xfc\x17\xcf'\x13u\xb1\x9e\xcdHnC\x0e\xcc`\xc8\xa0&\xac\x0e\xf1|\x8c\x10$\xc4\x8c\xa2p\x05`\xdc\x08 \x80\xc4\xd7Rr-\x94\x10\x102\xedi;\xf3f\xf1z\x16\x86\xdb\xd8d\xe5\xe7\x8b\xf5\x8d\rzp\xb2\xfe\xac\xf5\xf2\xd3\xfe\xfckws\xedt\x96b\xd5l\x1c\x0b\x85\xb5\x170\x8f\x11\x84\xb0\x8f\x19\xa0\x00 _\x07\x1ac\xa2\xc3\x89Z\xe7\x96\xf9 \xccNFg\xc7F\xaa\x8a+\x9a\x9cc_\x17\x1b\x17\x9e]z38<\x97+\xb5,",\xc8\xc8?\\\x91\xff\x17.~U\x96\x97\xf5%\xdeN<\x8e\xf5\x97%\xe7^\xcfL\xed~\xda\x96k\xdc->\x86\x02\x83"\x96H\xa6\xe3\xaas=-\xeb7\xe5\xda\x8f\xbc (no-eol) (esc) + x\x9c\xbdTMHTQ\x14\x1e\xfc\xef\xd9&\x10\x11*x\x88\x81\x9aN\xf7\xddw\xdf{\xf7Y\x0efR\xb4\x11\xb1U\x82\xc5\xfd\x9d!c\x06\x9c'd\xa0\x99X\x82\x92i\xablUZ-*\x08\x84\x82\x02KkQ\xf8\x13\xe4\xaa\x8dn\x94\x906)\xd5B\x02\xeb\xbe\x9c\x01\x85\xc9\x996\x1d\xf8x\x97{\xefy\xe7;\xe7|\xe7\x06\x02\x81\xb1\xe0\xda\x13\xefN\xd1\xca\x8f\xcb-\xbde\xfc\xeepU\xecJ\xc3\xcd@\x86\x96\xc6\xb7^`\xe9"[H\xe4\x18T\x1a\x16p]\xc3\x96\x14\x13\xcbt\xa1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x86zR\x91LE\xe8/\xdd& (esc) + C + \xd5~u\xb0e#\x08\r\x8c\xd5\xf83\x93\x01B\x95\xe8\x1c\x03\xdb\x92s*\x99`\xcc0\x88\xb4d\xb2\xbd\x85\xc9,\x14\xb7\xf1\xd9\xf2\xe5Ku\x8d\xf5rp\xb6\xee\\\xe0\xc5\xa7C\xd9\xd7\xefe\xda\xe94\xc5\xaa\xde>\x8a\x02I\xcb!\x16\xc1\x10"\x1b\x11\xe0\x02\xc8l\xe9H\x84\xb0\xf4\xa78\xc9-\xf1(\xa9\x15\x0f.\x8c\x8fT\x16\x965\xe9'\xbe\xac6\xaeLtN\x0f\x0e/fJ-\x8d\x08s\x12#\xe7[\xfe\xff\x0b\x17\xb9\xc6KK\xfa\xa2o\xa7\x1e\x87\xfaKb\x8b\xaf?\xcc\xed{z>\xd3\xb8\xbb\xcc}\x8eB\x01\x89\xc6\xbc\x88hO\xa6\x15\xf8\rr4\xb3\xe5 (no-eol) (esc) stream_out @@ -1153,8 +1223,9 @@ $ "$TESTDIR/get-with-headers.py" 127.0.0.1:$HGPORT '/graph/' \ > | grep '^var data =' - var data = [["40b4d6888e92", [0, 1], [[0, 0, 1]], "\u80fd", "test", "1970-01-01", ["stable", true], ["tip"], ["something"]], ["1d22e65f027e", [0, 1], [[0, 0, 1]], "branch", "test", "1970-01-01", ["stable", false], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; + var data = [["548001d11f45", [0, 1], [[0, 0, 1, null]], "\u80fd", "test", "1970-01-01", ["unstable", true], ["tip"], ["something"]], ["ba87b23d29ca", [0, 1], [[0, 0, 1, {"width": "3"}]], "branch", "test", "1970-01-01", ["unstable", false], [], []], ["1d22e65f027e", [0, 1], [[0, 0, 1, {"width": "3"}]], "branch", "test", "1970-01-01", ["stable", true], [], []], ["a4f92ed23982", [0, 1], [[0, 0, 1, {"width": "3"}]], "Added tag 1.0 for changeset 2ef0ac749a14", "test", "1970-01-01", ["default", true], [], []], ["2ef0ac749a14", [0, 1], [], "base", "test", "1970-01-01", ["default", false], ["1.0"], ["anotherthing"]]]; ERRORS ENCOUNTERED $ cat errors.log +