Mercurial > hg-stable
changeset 35397:b963750b125f
hgweb: implement json-graph
It's essentially a copy of json-log with graph-related things added (col, row,
color, edges).
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Thu, 07 Dec 2017 17:18:29 +0800 |
parents | dd11df900f7f |
children | 0432e54f4dbe |
files | contrib/wix/templates.wxs mercurial/hgweb/webcommands.py mercurial/templates/json/graph.tmpl mercurial/templates/json/map tests/test-hgweb-json.t |
diffstat | 5 files changed, 374 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/wix/templates.wxs Mon Dec 11 22:16:13 2017 -0800 +++ b/contrib/wix/templates.wxs Thu Dec 07 17:18:29 2017 +0800 @@ -42,6 +42,7 @@ <Directory Id="templates.jsondir" Name="json"> <Component Id="templates.json" Guid="$(var.templates.json.guid)" Win64='$(var.IsX64)'> <File Id="json.changelist.tmpl" Name="changelist.tmpl" KeyPath="yes" /> + <File Id="json.graph.tmpl" Name="graph.tmpl" /> <File Id="json.map" Name="map" /> </Component> </Directory>
--- a/mercurial/hgweb/webcommands.py Mon Dec 11 22:16:13 2017 -0800 +++ b/mercurial/hgweb/webcommands.py Thu Dec 07 17:18:29 2017 +0800 @@ -1277,7 +1277,7 @@ return tmpl('graph', rev=rev, symrev=symrev, revcount=revcount, uprev=uprev, lessvars=lessvars, morevars=morevars, downrev=downrev, - cols=cols, rows=rows, + cols=cols, rows=rows, changesets=count, canvaswidth=(cols + 1) * bg_height, truecanvasheight=rows * bg_height, canvasheight=canvasheight, bg_height=bg_height,
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/templates/json/graph.tmpl Thu Dec 07 17:18:29 2017 +0800 @@ -0,0 +1,5 @@ +\{ + "node": {node|json}, + "changeset_count": {changesets|json}, + "changesets": [{join(nodes%graphentry, ", ")}] +}
--- a/mercurial/templates/json/map Mon Dec 11 22:16:13 2017 -0800 +++ b/mercurial/templates/json/map Thu Dec 07 17:18:29 2017 +0800 @@ -25,6 +25,7 @@ # number of entries. changelog = changelist.tmpl shortlog = changelist.tmpl +graph = graph.tmpl changelistentry = '\{ "node": {node|json}, "date": {date|json}, @@ -37,6 +38,22 @@ "parents": [{if(allparents, join(allparents%changesetparent, ", "), join(parent%changesetparent, ", "))}] }' +graphentry = '\{ + "node": {node|json}, + "date": {date|json}, + "desc": {desc|utf8|json}, + "branch": {if(branch, branch%changesetbranch, "default"|json)}, + "bookmarks": [{join(bookmarks%changelistentryname, ", ")}], + "tags": [{join(tags%changelistentryname, ", ")}], + "user": {author|utf8|json}, + "phase": {phase|json}, + "col": {col|json}, + "row": {row|json}, + "color": {color|json}, + "edges": {edges|json}, + "parents": [{if(allparents, join(allparents%changesetparent, ", "), + join(parent%changesetparent, ", "))}] + }' changelistentryname = '{name|utf8|json}' changeset = '\{ "node": {node|json}, @@ -198,7 +215,6 @@ filelog = '\{ "entries": [{join(entries%changelistentry, ", ")}] }' -graph = '"not yet implemented"' helptopics = '\{ "topics": [{join(topics%helptopicentry, ", ")}], "earlycommands": [{join(earlycommands%helptopicentry, ", ")}],
--- a/tests/test-hgweb-json.t Mon Dec 11 22:16:13 2017 -0800 +++ b/tests/test-hgweb-json.t Thu Dec 07 17:18:29 2017 +0800 @@ -1335,7 +1335,356 @@ $ request json-graph 200 Script output follows - "not yet implemented" + { + "changeset_count": 10, + "changesets": [ + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "merge test-branch into default", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 1, + "width": -1 + } + ], + "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7", + "parents": [ + "ceed296fe500c3fac9541e31dad860cb49c89e45", + "ed66c30e87eb65337c05a4229efaa5f1d5285a90" + ], + "phase": "draft", + "row": 0, + "tags": [ + "tip" + ], + "user": "test" + }, + { + "bookmarks": [], + "branch": "test-branch", + "col": 1, + "color": 2, + "date": [ + 0.0, + 0 + ], + "desc": "another commit in test-branch", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "ed66c30e87eb65337c05a4229efaa5f1d5285a90", + "parents": [ + "6ab967a8ab3489227a83f80e920faa039a71819f" + ], + "phase": "draft", + "row": 1, + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "test-branch", + "col": 1, + "color": 2, + "date": [ + 0.0, + 0 + ], + "desc": "create test branch", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "6ab967a8ab3489227a83f80e920faa039a71819f", + "parents": [ + "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e" + ], + "phase": "draft", + "row": 2, + "tags": [], + "user": "test" + }, + { + "bookmarks": [ + "bookmark2" + ], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "create tag2", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "ceed296fe500c3fac9541e31dad860cb49c89e45", + "parents": [ + "f2890a05fea49bfaf9fb27ed5490894eba32da78" + ], + "phase": "draft", + "row": 3, + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "another commit to da/foo", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "f2890a05fea49bfaf9fb27ed5490894eba32da78", + "parents": [ + "93a8ce14f89156426b7fa981af8042da53f03aa0" + ], + "phase": "draft", + "row": 4, + "tags": [ + "tag2" + ], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "create tag", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "93a8ce14f89156426b7fa981af8042da53f03aa0", + "parents": [ + "78896eb0e102174ce9278438a95e12543e4367a7" + ], + "phase": "public", + "row": 5, + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "move foo", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "78896eb0e102174ce9278438a95e12543e4367a7", + "parents": [ + "8d7c456572acf3557e8ed8a07286b10c408bcec5" + ], + "phase": "public", + "row": 6, + "tags": [ + "tag1" + ], + "user": "test" + }, + { + "bookmarks": [ + "bookmark1" + ], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "modify da/foo", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 1, + "width": -1 + } + ], + "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5", + "parents": [ + "f8bbb9024b10f93cdbb8d940337398291d40dea8" + ], + "phase": "public", + "row": 7, + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 1, + "date": [ + 0.0, + 0 + ], + "desc": "modify foo", + "edges": [ + { + "bcolor": "", + "col": 0, + "color": 1, + "nextcol": 0, + "width": -1 + }, + { + "bcolor": "", + "col": 1, + "color": 2, + "nextcol": 0, + "width": -1 + } + ], + "node": "f8bbb9024b10f93cdbb8d940337398291d40dea8", + "parents": [ + "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e" + ], + "phase": "public", + "row": 8, + "tags": [], + "user": "test" + }, + { + "bookmarks": [], + "branch": "default", + "col": 0, + "color": 2, + "date": [ + 0.0, + 0 + ], + "desc": "initial", + "edges": [], + "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e", + "parents": [], + "phase": "public", + "row": 9, + "tags": [], + "user": "test" + } + ], + "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7" + } help/ shows help topics