Patchwork [2,of,3] hgweb: add files to the json changeset template

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date Nov. 15, 2019, 9:02 p.m.
Message ID <6a9122d3cd3639ddacb8.1573851757@chloe>
Download mbox | patch
Permalink /patch/43284/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - Nov. 15, 2019, 9:02 p.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1573851385 18000
#      Fri Nov 15 15:56:25 2019 -0500
# Node ID 6a9122d3cd3639ddacb8768c573ea9eaeb9a6a33
# Parent  66854dfbde7f2191ff3da155872ac15f1b8e6934
hgweb: add files to the json changeset template

As far as I can tell, it's currently impossible via JSON to figure out
what files are touched by a particular revision. Reusing the
filenodelink and filenolink templates from the other hgweb templates
should provide this information.

Patch

diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -65,6 +65,7 @@  changeset = '\{
   "tags": [{join(changesettag, ", ")}],
   "user": {author|utf8|json},
   "parents": [{join(parent%changesetparent, ", ")}],
+  "files": [{join(files, ", ")}],
   "phase": {phase|json}
   }'
 changesetbranch = '{name|utf8|json}'
@@ -229,8 +230,11 @@  help = '\{
   "topic": {topic|utf8|json},
   "rawdoc": {doc|utf8|json}
   }'
-filenodelink = ''
-filenolink = ''
+filenodelink = '\{
+  "file": {file|json},
+  "status": {status|json}
+  }'
+filenolink = '{filenodelink}'
 index = '\{
   "entries": [{join(entries%indexentry, ", ")}]
   }'
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
@@ -782,6 +782,12 @@  changeset/ renders the tip changeset
       0
     ],
     "desc": "merge test-branch into default",
+    "files": [
+      {
+        "file": "foo-new",
+        "status": "modified"
+      }
+    ],
     "node": "cc725e08502a79dd1eda913760fbe06ed7a9abc7",
     "parents": [
       "ceed296fe500c3fac9541e31dad860cb49c89e45",
@@ -807,6 +813,16 @@  changeset/{revision} shows tags
       0
     ],
     "desc": "move foo",
+    "files": [
+      {
+        "file": "foo",
+        "status": "removed"
+      },
+      {
+        "file": "foo-new",
+        "status": "added"
+      }
+    ],
     "node": "78896eb0e102174ce9278438a95e12543e4367a7",
     "parents": [
       "8d7c456572acf3557e8ed8a07286b10c408bcec5"
@@ -833,6 +849,12 @@  changeset/{revision} shows bookmarks
       0
     ],
     "desc": "modify da/foo",
+    "files": [
+      {
+        "file": "da/foo",
+        "status": "modified"
+      }
+    ],
     "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5",
     "parents": [
       "f8bbb9024b10f93cdbb8d940337398291d40dea8"
@@ -855,6 +877,12 @@  changeset/{revision} shows branches
       0
     ],
     "desc": "create test branch",
+    "files": [
+      {
+        "file": "foo",
+        "status": "modified"
+      }
+    ],
     "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
     "parents": [
       "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"