changeset 29380:c1b526f55116

templates: add support for filelog webcommand in json style Modify changelistentry structure to also deliver phase and branch data and use either 'parents' or 'allparents' depending on what is defined in the view, in order to reuse it in filelog structure.
author Laura Médioni <laura.medioni@logilab.fr>
date Fri, 03 Jun 2016 11:28:22 +0200
parents fc777c855d66
children 8bfe44494a0d
files mercurial/templates/json/map tests/test-hgweb-json.t
diffstat 2 files changed, 143 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templates/json/map	Thu Jun 09 12:41:57 2016 +0200
+++ b/mercurial/templates/json/map	Fri Jun 03 11:28:22 2016 +0200
@@ -9,10 +9,13 @@
   "node": {node|json},
   "date": {date|json},
   "desc": {desc|utf8|json},
+  "branch": {if(branch, branch%changesetbranch, "default"|json)},
   "bookmarks": [{join(bookmarks%changelistentryname, ", ")}],
   "tags": [{join(tags%changelistentryname, ", ")}],
   "user": {author|utf8|json},
-  "parents": [{join(allparents%changesetparent, ", ")}]
+  "phase": {phase|json},
+  "parents": [{if(allparents, join(allparents%changesetparent, ", "),
+                  join(parent%changesetparent, ", "))}]
   }'
 changelistentryname = '{name|utf8|json}'
 changeset = '\{
@@ -156,7 +159,9 @@
   "lineno": {lineno|json},
   "revdate": {revdate|json}
   }'
-filelog = '"not yet implemented"'
+filelog = '\{
+  "entries": [{join(entries%changelistentry, ", ")}]
+  }'
 graph = '"not yet implemented"'
 helptopics = '\{
   "topics": [{join(topics%helptopicentry, ", ")}],
--- a/tests/test-hgweb-json.t	Thu Jun 09 12:41:57 2016 +0200
+++ b/tests/test-hgweb-json.t	Fri Jun 03 11:28:22 2016 +0200
@@ -169,6 +169,7 @@
     "changesets": [
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -179,6 +180,7 @@
           "ceed296fe500c3fac9541e31dad860cb49c89e45",
           "ed66c30e87eb65337c05a4229efaa5f1d5285a90"
         ],
+        "phase": "draft",
         "tags": [
           "tip"
         ],
@@ -186,6 +188,7 @@
       },
       {
         "bookmarks": [],
+        "branch": "test-branch",
         "date": [
           0.0,
           0
@@ -195,11 +198,13 @@
         "parents": [
           "6ab967a8ab3489227a83f80e920faa039a71819f"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "test-branch",
         "date": [
           0.0,
           0
@@ -209,6 +214,7 @@
         "parents": [
           "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
@@ -216,6 +222,7 @@
         "bookmarks": [
           "bookmark2"
         ],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -225,11 +232,13 @@
         "parents": [
           "f2890a05fea49bfaf9fb27ed5490894eba32da78"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -239,6 +248,7 @@
         "parents": [
           "93a8ce14f89156426b7fa981af8042da53f03aa0"
         ],
+        "phase": "draft",
         "tags": [
           "tag2"
         ],
@@ -246,6 +256,7 @@
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -255,11 +266,13 @@
         "parents": [
           "78896eb0e102174ce9278438a95e12543e4367a7"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -269,6 +282,7 @@
         "parents": [
           "8d7c456572acf3557e8ed8a07286b10c408bcec5"
         ],
+        "phase": "public",
         "tags": [
           "tag1"
         ],
@@ -278,6 +292,7 @@
         "bookmarks": [
           "bookmark1"
         ],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -287,11 +302,13 @@
         "parents": [
           "f8bbb9024b10f93cdbb8d940337398291d40dea8"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -301,11 +318,13 @@
         "parents": [
           "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -313,6 +332,7 @@
         "desc": "initial",
         "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
         "parents": [],
+        "phase": "public",
         "tags": [],
         "user": "test"
       }
@@ -330,6 +350,7 @@
     "changesets": [
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -339,11 +360,13 @@
         "parents": [
           "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -351,6 +374,7 @@
         "desc": "initial",
         "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
         "parents": [],
+        "phase": "public",
         "tags": [],
         "user": "test"
       }
@@ -368,6 +392,7 @@
     "changesets": [
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -378,6 +403,7 @@
           "ceed296fe500c3fac9541e31dad860cb49c89e45",
           "ed66c30e87eb65337c05a4229efaa5f1d5285a90"
         ],
+        "phase": "draft",
         "tags": [
           "tip"
         ],
@@ -385,6 +411,7 @@
       },
       {
         "bookmarks": [],
+        "branch": "test-branch",
         "date": [
           0.0,
           0
@@ -394,11 +421,13 @@
         "parents": [
           "6ab967a8ab3489227a83f80e920faa039a71819f"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "test-branch",
         "date": [
           0.0,
           0
@@ -408,6 +437,7 @@
         "parents": [
           "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
@@ -415,6 +445,7 @@
         "bookmarks": [
           "bookmark2"
         ],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -424,11 +455,13 @@
         "parents": [
           "f2890a05fea49bfaf9fb27ed5490894eba32da78"
         ],
+        "phase": "draft",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -438,6 +471,7 @@
         "parents": [
           "93a8ce14f89156426b7fa981af8042da53f03aa0"
         ],
+        "phase": "draft",
         "tags": [
           "tag2"
         ],
@@ -445,6 +479,7 @@
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -454,11 +489,13 @@
         "parents": [
           "78896eb0e102174ce9278438a95e12543e4367a7"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -468,6 +505,7 @@
         "parents": [
           "8d7c456572acf3557e8ed8a07286b10c408bcec5"
         ],
+        "phase": "public",
         "tags": [
           "tag1"
         ],
@@ -477,6 +515,7 @@
         "bookmarks": [
           "bookmark1"
         ],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -486,11 +525,13 @@
         "parents": [
           "f8bbb9024b10f93cdbb8d940337398291d40dea8"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -500,11 +541,13 @@
         "parents": [
           "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
         ],
+        "phase": "public",
         "tags": [],
         "user": "test"
       },
       {
         "bookmarks": [],
+        "branch": "default",
         "date": [
           0.0,
           0
@@ -512,6 +555,7 @@
         "desc": "initial",
         "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
         "parents": [],
+        "phase": "public",
         "tags": [],
         "user": "test"
       }
@@ -862,7 +906,98 @@
   $ request json-filelog/f8bbb9024b10/foo
   200 Script output follows
   
-  "not yet implemented"
+  {
+    "entries": [
+      {
+        "bookmarks": [],
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "desc": "modify foo",
+        "node": "f8bbb9024b10f93cdbb8d940337398291d40dea8",
+        "parents": [
+          "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
+        ],
+        "phase": "public",
+        "tags": [],
+        "user": "test"
+      },
+      {
+        "bookmarks": [],
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "desc": "initial",
+        "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
+        "parents": [],
+        "phase": "public",
+        "tags": [],
+        "user": "test"
+      }
+    ]
+  }
+
+  $ request json-filelog/cc725e08502a/da/foo
+  200 Script output follows
+  
+  {
+    "entries": [
+      {
+        "bookmarks": [],
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "desc": "another commit to da/foo",
+        "node": "f2890a05fea49bfaf9fb27ed5490894eba32da78",
+        "parents": [
+          "8d7c456572acf3557e8ed8a07286b10c408bcec5"
+        ],
+        "phase": "draft",
+        "tags": [
+          "tag2"
+        ],
+        "user": "test"
+      },
+      {
+        "bookmarks": [
+          "bookmark1"
+        ],
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "desc": "modify da/foo",
+        "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5",
+        "parents": [
+          "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
+        ],
+        "phase": "public",
+        "tags": [],
+        "user": "test"
+      },
+      {
+        "bookmarks": [],
+        "branch": "default",
+        "date": [
+          0.0,
+          0
+        ],
+        "desc": "initial",
+        "node": "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e",
+        "parents": [],
+        "phase": "public",
+        "tags": [],
+        "user": "test"
+      }
+    ]
+  }
 
 (archive/ doesn't use templating, so ignore it)