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

login
register
mail settings
Submitter Gregory Szorc
Date March 31, 2015, 9:56 p.m.
Message ID <1129157e88e33c1b6133.1427838967@gps-mbp.local>
Download mbox | patch
Permalink /patch/8396/
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 1427838896 25200
#      Tue Mar 31 14:54:56 2015 -0700
# Node ID 1129157e88e33c1b613317812b4d2bf13648b9fe
# Parent  88d510e48b43278f54959063097e1030be300c0b
json: implement {bookmarks} template

Patch

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -13,9 +13,17 @@  tagentry = '\{
   "tag": {tag|json},
   "node": {node|json},
   "date": {date|json}
   }'
-bookmarks = '"not yet implemented"'
+bookmarks = '\{
+  "node": {node|json},
+  "bookmarks": [{join(entries%bookmarkentry, ", ")}]
+  }'
+bookmarkentry = '\{
+  "bookmark": {bookmark|json},
+  "node": {node|json},
+  "date": {date|json}
+  }'
 branches = '"not yet implemented"'
 summary = '"not yet implemented"'
 filediff = '"not yet implemented"'
 filecomparison = '"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
@@ -190,9 +190,29 @@  bookmarks/ shows bookmarks info
 
   $ request json-bookmarks
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "bookmarks": [
+      {
+        "bookmark": "bookmark1",
+        "date": [
+          0.0,
+          0
+        ],
+        "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5"
+      },
+      {
+        "bookmark": "bookmark2",
+        "date": [
+          0.0,
+          0
+        ],
+        "node": "ceed296fe500c3fac9541e31dad860cb49c89e45"
+      }
+    ],
+    "node": "6ab967a8ab3489227a83f80e920faa039a71819f"
+  }
 
 branches/ shows branches info
 
   $ request json-branches