Patchwork [3,of,3] hgweb: add phase to {changeset} template

login
register
mail settings
Submitter Gregory Szorc
Date April 1, 2015, 6:02 a.m.
Message ID <875a5b2f83d4233da4ca.1427868130@gps-mbp.local>
Download mbox | patch
Permalink /patch/8409/
State Accepted
Headers show

Comments

Gregory Szorc - April 1, 2015, 6:02 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1427866152 25200
#      Tue Mar 31 22:29:12 2015 -0700
# Node ID 875a5b2f83d4233da4cacd0840a230e53b4ff776
# Parent  8ea63ae7d3fde67fdbf07518d7e0da1ebf787980
hgweb: add phase to {changeset} template

It's pretty surprising phase wasn't part of this template call already.
We now expose {phase} to the {changeset} template and we expose this
data to JSON.

This brings JSON output in line with the output from `hg log -Tjson`.
The lone exception is hweb doesn't print the numeric rev. As has been
stated previously, I don't believe hgweb should be exposing these
unstable identifiers. (We can add them later if we really want them.)
There is still work to bring hgweb in parity with --verbose and
--debug output from the CLI.
Matt Mackall - April 1, 2015, 4:13 p.m.
On Tue, 2015-03-31 at 23:02 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@gmail.com>
> # Date 1427866152 25200
> #      Tue Mar 31 22:29:12 2015 -0700
> # Node ID 875a5b2f83d4233da4cacd0840a230e53b4ff776
> # Parent  8ea63ae7d3fde67fdbf07518d7e0da1ebf787980
> hgweb: add phase to {changeset} template

These are queued for default, thanks.

Patch

diff --git a/mercurial/hgweb/webutil.py b/mercurial/hgweb/webutil.py
--- a/mercurial/hgweb/webutil.py
+++ b/mercurial/hgweb/webutil.py
@@ -323,8 +323,9 @@  def changesetentry(web, req, tmpl, ctx):
         author=ctx.user(),
         desc=ctx.description(),
         extra=ctx.extra(),
         date=ctx.date(),
+        phase=ctx.phasestr(),
         files=files,
         diffsummary=lambda **x: diffsummary(diffstatsgen),
         diffstat=diffstats,
         archives=web.archivelist(ctx.hex()),
diff --git a/mercurial/templates/json/map b/mercurial/templates/json/map
--- a/mercurial/templates/json/map
+++ b/mercurial/templates/json/map
@@ -10,9 +10,10 @@  changeset = '\{
   "branch": {if(branch, branch%changesetbranch, "default"|json)},
   "bookmarks": [{join(changesetbookmark, ", ")}],
   "tags": [{join(changesettag, ", ")}],
   "user": {author|json},
-  "parents": [{join(parent%changesetparent, ", ")}]
+  "parents": [{join(parent%changesetparent, ", ")}],
+  "phase": {phase|json}
   }'
 changesetbranch = '{name|json}'
 changesetbookmark = '{bookmark|json}'
 changesettag = '{tag|json}'
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
@@ -21,8 +21,9 @@ 
   (leaving bookmark bookmark1)
   $ hg mv foo foo-new
   $ hg commit -m 'move foo'
   $ hg tag -m 'create tag' tag1
+  $ hg phase --public -r .
   $ echo baz > da/foo
   $ hg commit -m 'another commit to da/foo'
   $ hg tag -m 'create tag2' tag2
   $ hg bookmark bookmark2
@@ -161,8 +162,9 @@  changeset/ renders the tip changeset
     "parents": [
       "ceed296fe500c3fac9541e31dad860cb49c89e45",
       "ed66c30e87eb65337c05a4229efaa5f1d5285a90"
     ],
+    "phase": "draft",
     "tags": [
       "tip"
     ],
     "user": "test"
@@ -184,8 +186,9 @@  changeset/{revision} shows tags
     "node": "78896eb0e102174ce9278438a95e12543e4367a7",
     "parents": [
       "8d7c456572acf3557e8ed8a07286b10c408bcec5"
     ],
+    "phase": "public",
     "tags": [
       "tag1"
     ],
     "user": "test"
@@ -209,8 +212,9 @@  changeset/{revision} shows bookmarks
     "node": "8d7c456572acf3557e8ed8a07286b10c408bcec5",
     "parents": [
       "f8bbb9024b10f93cdbb8d940337398291d40dea8"
     ],
+    "phase": "public",
     "tags": [],
     "user": "test"
   }
 
@@ -230,8 +234,9 @@  changeset/{revision} shows branches
     "node": "6ab967a8ab3489227a83f80e920faa039a71819f",
     "parents": [
       "06e557f3edf66faa1ccaba5dd8c203c21cc79f1e"
     ],
+    "phase": "draft",
     "tags": [],
     "user": "test"
   }