json: implement {comparison} template
authorGregory Szorc <gregory.szorc@gmail.com>
Fri, 10 Apr 2015 22:26:53 -0400
changeset 24714 84859415a4c9
parent 24713 2f43f8cf8219
child 24715 1439bacf0ec7
json: implement {comparison} template Similar to {filediff}, we abbreviate some property names to cut down on string bloat.
mercurial/templates/json/map
tests/test-hgweb-json.t
--- a/mercurial/templates/json/map	Fri Apr 10 22:39:22 2015 -0400
+++ b/mercurial/templates/json/map	Fri Apr 10 22:26:53 2015 -0400
@@ -112,7 +112,28 @@
   "n": {lineno|json},
   "l": {line|json}
   }'
-filecomparison = '"not yet implemented"'
+filecomparison = '\{
+  "path": {file|json},
+  "node": {node|json},
+  "date": {date|json},
+  "desc": {desc|json},
+  "author": {author|json},
+  "parents": [{join(parent%changesetparent, ", ")}],
+  "children": [{join(child%changesetparent, ", ")}],
+  "leftnode": {leftnode|json},
+  "rightnode": {rightnode|json},
+  "comparison": [{join(comparison, ", ")}]
+  }'
+comparisonblock = '\{
+  "lines": [{join(lines, ", ")}]
+  }'
+comparisonline = '\{
+  "t": {type|json},
+  "ln": {leftlineno|json},
+  "ll": {leftline|json},
+  "rn": {rightlineno|json},
+  "rl": {rightline|json}
+  }'
 fileannotate = '"not yet implemented"'
 filelog = '"not yet implemented"'
 graph = '"not yet implemented"'
--- a/tests/test-hgweb-json.t	Fri Apr 10 22:39:22 2015 -0400
+++ b/tests/test-hgweb-json.t	Fri Apr 10 22:26:53 2015 -0400
@@ -730,7 +730,35 @@
   $ request json-comparison/f8bbb9024b10/foo
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "author": "test",
+    "children": [],
+    "comparison": [
+      {
+        "lines": [
+          {
+            "ll": "foo",
+            "ln": 1,
+            "rl": "bar",
+            "rn": 1,
+            "t": "replace"
+          }
+        ]
+      }
+    ],
+    "date": [
+      0.0,
+      0
+    ],
+    "desc": "modify foo",
+    "leftnode": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
+    "node": "f8bbb9024b10f93cdbb8d940337398291d40dea8",
+    "parents": [
+      "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
+    ],
+    "path": "foo",
+    "rightnode": "f8bbb9024b10f93cdbb8d940337398291d40dea8"
+  }
 
 annotate/{revision}/{path} shows annotations for each line