Patchwork [5,of,5,json-style] json: implement {branches} template

login
register
mail settings
Submitter Gregory Szorc
Date March 31, 2015, 9:56 p.m.
Message ID <a6a28a098be75013ba35.1427838968@gps-mbp.local>
Download mbox | patch
Permalink /patch/8397/
State Accepted
Headers show

Comments

Gregory Szorc - March 31, 2015, 9:56 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1427776644 25200
#      Mon Mar 30 21:37:24 2015 -0700
# Node ID a6a28a098be75013ba358f1c2c4a79db88613c5f
# Parent  1129157e88e33c1b613317812b4d2bf13648b9fe
json: implement {branches} template
Matt Mackall - March 31, 2015, 10:23 p.m.
On Tue, 2015-03-31 at 14:56 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1427776644 25200
> #      Mon Mar 30 21:37:24 2015 -0700
> # Node ID a6a28a098be75013ba358f1c2c4a79db88613c5f
> # Parent  1129157e88e33c1b613317812b4d2bf13648b9fe
> json: implement {branches} template

These are queued for default, thanks.

Patch

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -22,9 +22,17 @@  bookmarkentry = '\{
   "bookmark": {bookmark|json},
   "node": {node|json},
   "date": {date|json}
   }'
-branches = '"not yet implemented"'
+branches = '\{
+  "branches": [{join(entries%branchentry, ", ")}]
+  }'
+branchentry = '\{
+  "branch": {branch|json},
+  "node": {node|json},
+  "date": {date|json},
+  "status": {status|json}
+  }'
 summary = '"not yet implemented"'
 filediff = '"not yet implemented"'
 filecomparison = '"not yet implemented"'
 fileannotate = '"not yet implemented"'
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
@@ -217,9 +217,30 @@  branches/ shows branches info
 
   $ request json-branches
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "branches": [
+      {
+        "branch": "test-branch",
+        "date": [
+          0.0,
+          0
+        ],
+        "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
+        "status": "open"
+      },
+      {
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "node": "ceed296fe500c3fac9541e31dad860cb49c89e45",
+        "status": "open"
+      }
+    ]
+  }
 
 summary/ shows a summary of repository state
 
   $ request json-summary