diff mercurial/cmdutil.py @ 25762:f4412380d357

changeset_printer: display wdirrev/wdirnode values for workingctx Because we want to eliminate "if"s in the default template, it makes sense to display wdirrev/wdirnode values for now. wdir() is still experimental, so the output of "log -r'wdir()'" may change in future.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 04 Jul 2015 17:19:49 +0900
parents ff11c1565c04
children 60c791592aa7
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Jul 08 16:19:09 2015 -0700
+++ b/mercurial/cmdutil.py	Sat Jul 04 17:19:49 2015 +0900
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-from node import hex, nullid, nullrev, short
+from node import hex, bin, nullid, nullrev, short
 from i18n import _
 import os, sys, errno, re, tempfile, cStringIO, shutil
 import util, scmutil, templater, patch, error, templatekw, revlog, copies
@@ -1152,11 +1152,9 @@
             hexfunc = hex
         else:
             hexfunc = short
-        if rev is None:
-            pctx = ctx.p1()
-            revnode = (pctx.rev(), hexfunc(pctx.node()) + '+')
-        else:
-            revnode = (rev, hexfunc(changenode))
+        # as of now, wctx.node() and wctx.rev() return None, but we want to
+        # show the same values as {node} and {rev} templatekw
+        revnode = (scmutil.intrev(rev), hexfunc(bin(ctx.hex())))
 
         if self.ui.quiet:
             self.ui.write("%d:%s\n" % revnode, label='log.node')