[PATCH 1 of 4] templates: add support for filerevision webcommand in json style

Laura Médioni laura.medioni at logilab.fr
Wed Jun 15 12:06:05 UTC 2016


# HG changeset patch
# User Laura Médioni <laura.medioni at logilab.fr>
# Date 1464949962 -7200
#      Fri Jun 03 12:32:42 2016 +0200
# Node ID 21e855b309f5c1527938874ededc8168fa387c17
# Parent  bfd47c239e711d1010e12dad8e76d1c3bdfe2a0d
templates: add support for filerevision webcommand in json style

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -1,7 +1,14 @@
 mimetype = 'application/json'
-filerevision = '"not yet implemented"'
+filerevision = '\{
+  "node": {node|json},
+  "path": {file|json},
+  "lines": [{join(text%lineentry, ", ")}]
+  }'
+lineentry = '\{
+  "line": {line|json}
+  }'
 search = '"not yet implemented"'
 # changelog and shortlog are the same web API but with different
 # number of entries.
 changelog = changelist.tmpl
 shortlog = changelist.tmpl
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
@@ -112,11 +112,19 @@
 file/{revision}/{path} shows file revision
 
   $ request json-file/06e557f3edf6/foo
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "lines": [
+      {
+        "line": "foo\n"
+      }
+    ],
+    "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
+    "path": "foo"
+  }
 
 file/{revision} shows root directory info
 
   $ request json-file/cc725e08502a
   200 Script output follows


More information about the Mercurial-devel mailing list