Patchwork [6,of,6] templatekw: make {rev} return wdirrev instead of None

login
register
mail settings
Submitter Yuya Nishihara
Date July 2, 2015, 3:17 p.m.
Message ID <8886ec4d7e5f90fc3337.1435850225@mimosa>
Download mbox | patch
Permalink /patch/9876/
State Accepted
Headers show

Comments

Yuya Nishihara - July 2, 2015, 3:17 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1435843101 -32400
#      Thu Jul 02 22:18:21 2015 +0900
# Node ID 8886ec4d7e5f90fc3337f551c57513e2f85d223a
# Parent  2286ea45d24c150d9ca9d0bc55c8c9303260abff
templatekw: make {rev} return wdirrev instead of None

wdirrev/wdirnode identifiers are still experimental, but {node} is mapped to
wdirnode. So {rev} should do the same for consistency.

I'm not sure if templatekw can import scmutil. If not, we should move intrev()
to node module.
Matt Mackall - July 8, 2015, 5:01 p.m.
On Fri, 2015-07-03 at 00:17 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1435843101 -32400
> #      Thu Jul 02 22:18:21 2015 +0900
> # Node ID 8886ec4d7e5f90fc3337f551c57513e2f85d223a
> # Parent  2286ea45d24c150d9ca9d0bc55c8c9303260abff
> templatekw: make {rev} return wdirrev instead of None

These (except 2) are queued for default, thanks.

Patch

diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -6,7 +6,7 @@ 
 # GNU General Public License version 2 or any later version.
 
 from node import hex
-import patch, util, error
+import patch, scmutil, util, error
 import hbisect
 
 # This helper class allows us to handle both:
@@ -382,7 +382,7 @@  def showphaseidx(repo, ctx, templ, **arg
 
 def showrev(repo, ctx, templ, **args):
     """:rev: Integer. The repository-local changeset revision number."""
-    return ctx.rev()
+    return scmutil.intrev(ctx.rev())
 
 def showsubrepos(**args):
     """:subrepos: List of strings. Updated subrepositories in the changeset."""
diff --git a/tests/test-command-template.t b/tests/test-command-template.t
--- a/tests/test-command-template.t
+++ b/tests/test-command-template.t
@@ -51,6 +51,12 @@  Second branch starting at nullrev:
   8 t
   7 f
 
+Working-directory revision has special identifiers, though they are still
+experimental:
+
+  $ hg log -r 'wdir()' -T '{rev}:{node}\n'
+  2147483647:ffffffffffffffffffffffffffffffffffffffff
+
 Some keywords are invalid for working-directory revision, but they should
 never cause crash: