# HG changeset patch
# User Anton Shestakov
# Date 1512638309 -28800
# Thu Dec 07 17:18:29 2017 +0800
# Node ID 4c48bb27dbf7473326b372c776bc1abc57a65d3d
# Parent cb0df5a3affba6e8f1789de337230cbeecda9c5a
hgweb: implement json-graph
It's essentially a copy of json-log with graph-related things added (col, row,
color, edges).
diff --git a/contrib/wix/templates.wxs b/contrib/wix/templates.wxs
--- a/contrib/wix/templates.wxs
+++ b/contrib/wix/templates.wxs
@@ -42,6 +42,7 @@
+
diff --git a/mercurial/hgweb/webcommands.py b/mercurial/hgweb/webcommands.py
--- a/mercurial/hgweb/webcommands.py
+++ b/mercurial/hgweb/webcommands.py
@@ -1277,7 +1277,7 @@ def graph(web, req, tmpl):
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,
diff --git a/mercurial/templates/json/graph.tmpl
b/mercurial/templates/json/graph.tmpl
new file mode 100644
--- /dev/null
+++ b/mercurial/templates/json/graph.tmpl
@@ -0,0 +1,5 @@
+\{
+ "node": {node|json},
+ "changeset_count": {changesets|json},
+ "changesets": [{join(nodes%graphentry, ", ")}]
+}
diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -25,6 +25,7 @@ searchentry = '{changelistentry}'
# number of entries.
changelog = changelist.tmpl
shortlog = changelist.tmpl
+graph = graph.tmpl
changelistentry = '\{
"node": {node|json},
"date": {date|json},
@@ -37,6 +38,22 @@ changelistentry = '\{
"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 @@ fileannotation = '\{
filelog = '\{
"entries": [{join(entries%changelistentry, ", ")}]
}'
-graph = '"not yet implemented"'
helptopics = '\{
"topics": [{join(topics%helptopicentry, ", ")}],
"earlycommands": [{join(earlycommands%helptopicentry, ", ")}],
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -1335,7 +1335,356 @@ graph/ shows information that can be use
$ 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": [],
+