Patchwork [3,of,3] identify: provide changectx to templater

login
register
mail settings
Submitter Yuya Nishihara
Date June 26, 2017, 1:48 a.m.
Message ID <6ec9639b1930a6433daa.1498441684@mimosa>
Download mbox | patch
Permalink /patch/21718/
State Accepted
Headers show

Comments

Yuya Nishihara - June 26, 2017, 1:48 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1498437436 -32400
#      Mon Jun 26 09:37:16 2017 +0900
# Node ID 6ec9639b1930a6433daac5f5332c494cb5e31917
# Parent  8407931dc104dd45e7c7d6661710e108c59ce001
identify: provide changectx to templater
Augie Fackler - June 26, 2017, 2:55 p.m.
On Mon, Jun 26, 2017 at 10:48:04AM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1498437436 -32400
> #      Mon Jun 26 09:37:16 2017 +0900
> # Node ID 6ec9639b1930a6433daac5f5332c494cb5e31917
> # Parent  8407931dc104dd45e7c7d6661710e108c59ce001
> identify: provide changectx to templater

queued, thanks

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2795,6 +2795,7 @@  def identify(ui, repo, source=None, rev=
                 fn.startitem()
                 fn.data(rev=p.rev())
                 fn.data(node=p.hex())
+                fn.context(ctx=p)
             fn.end()
         else:
             hexoutput = hexfunc(ctx.node())
@@ -2834,6 +2835,7 @@  def identify(ui, repo, source=None, rev=
         fm.data(branch=ctx.branch())
         fm.data(tags=fm.formatlist(taglist, name='tag', sep=':'))
         fm.data(bookmarks=fm.formatlist(ctx.bookmarks(), name='bookmark'))
+        fm.context(ctx=ctx)
 
     fm.plain("%s\n" % ' '.join(output))
     fm.end()
diff --git a/tests/test-identify.t b/tests/test-identify.t
--- a/tests/test-identify.t
+++ b/tests/test-identify.t
@@ -56,6 +56,13 @@  with options
    }
   ]
 
+test template keywords and functions which require changectx:
+
+  $ hg id -T '{rev} {node|shortest}\n'
+  2147483647 ffff
+  $ hg id -T '{parents % "{rev} {node|shortest} {desc}\n"}'
+  0 cb9a a
+
 with modifications
 
   $ echo b > a