Patchwork [3,of,4] templates: add support for search webcommand in json style

login
register
mail settings
Submitter Laura Médioni
Date June 15, 2016, 12:06 p.m.
Message ID <b7ea27cf0339ad30e00a.1465992367@sh79.dev.logilab.fr>
Download mbox | patch
Permalink /patch/15510/
State Changes Requested
Headers show

Comments

Laura Médioni - June 15, 2016, 12:06 p.m.
# HG changeset patch
# User Laura Médioni <laura.medioni@logilab.fr>
# Date 1465547502 -7200
#      Fri Jun 10 10:31:42 2016 +0200
# Node ID b7ea27cf0339ad30e00ac307af2e104cb2f2f106
# Parent  8a068602ddea1d5021acd55b8d5d13c436900fda
templates: add support for search webcommand in json style

Patch

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -5,11 +5,18 @@  filerevision = '\{
   "lines": [{join(text%lineentry, ", ")}]
   }'
 lineentry = '\{
   "line": {line|json}
   }'
-search = '"not yet implemented"'
+search = '\{
+  "node": {node|json},
+  "query": {query|json},
+  "entries": [{join(entries%searchentry, ", ")}]
+  }'
+searchentry = '\{
+  "node": {node|json}
+  }'
 # changelog and shortlog are the same web API but with different
 # number of entries.
 changelog = changelist.tmpl
 shortlog = changelist.tmpl
 changelistentry = '\{
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
@@ -895,10 +895,29 @@  summary/ shows a summary of repository s
         "tag": "tag1"
       }
     ]
   }
 
+  $ request json-changelog?rev=create
+  200 Script output follows
+  
+  {
+    "entries": [
+      {
+        "node": "6ab967a8ab3489227a83f80e920faa039a71819f"
+      },
+      {
+        "node": "ceed296fe500c3fac9541e31dad860cb49c89e45"
+      },
+      {
+        "node": "93a8ce14f89156426b7fa981af8042da53f03aa0"
+      }
+    ],
+    "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
+    "query": "create"
+  }
+
 filediff/{revision}/{path} shows changes to a file in a revision
 
   $ request json-diff/f8bbb9024b10/foo
   200 Script output follows