log: have changesetformatter fill in wdir() rev and node (BC)
authorYuya Nishihara <yuya@tcha.org>
Sat, 15 Sep 2018 17:26:20 +0900
changeset 39795 ba93db1745ba
parent 39794 4f44f747f094
child 39796 94ca3579e84e
log: have changesetformatter fill in wdir() rev and node (BC) This matches the behavior of the default template keywords. wdir() support is still experimental so we can change the output.
mercurial/logcmdutil.py
tests/test-log.t
tests/test-template-keywords.t
--- a/mercurial/logcmdutil.py	Sun Sep 23 16:11:01 2018 +0900
+++ b/mercurial/logcmdutil.py	Sat Sep 15 17:26:20 2018 +0900
@@ -325,16 +325,9 @@
         '''show a single changeset or file revision'''
         fm = self._fm
         fm.startitem()
-
         fm.context(ctx=ctx)
-        # TODO: maybe this should be wdirrev/wdirnode?
-        rev = ctx.rev()
-        if rev is None:
-            hexnode = None
-        else:
-            hexnode = fm.hexfunc(ctx.node())
-        fm.data(rev=rev,
-                node=hexnode)
+        fm.data(rev=scmutil.intrev(ctx),
+                node=fm.hexfunc(scmutil.binnode(ctx)))
 
         if self.ui.quiet:
             return
@@ -350,7 +343,7 @@
                                        for c in ctx.parents()], name='node'))
 
         if self.ui.debugflag:
-            if rev is None:
+            if ctx.rev() is None:
                 hexnode = None
             else:
                 hexnode = fm.hexfunc(ctx.manifestnode())
--- a/tests/test-log.t	Sun Sep 23 16:11:01 2018 +0900
+++ b/tests/test-log.t	Sat Sep 15 17:26:20 2018 +0900
@@ -2208,10 +2208,10 @@
     "branch": "default",
     "date": [*, 0], (glob)
     "desc": "",
-    "node": null,
+    "node": "ffffffffffffffffffffffffffffffffffffffff",
     "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
     "phase": "draft",
-    "rev": null,
+    "rev": 2147483647,
     "tags": [],
     "user": "test"
    }
@@ -2220,8 +2220,8 @@
   $ hg log -r 'wdir()' -Tjson -q
   [
    {
-    "node": null,
-    "rev": null
+    "node": "ffffffffffffffffffffffffffffffffffffffff",
+    "rev": 2147483647
    }
   ]
 
@@ -2236,11 +2236,11 @@
     "extra": {"branch": "default"},
     "manifest": null,
     "modified": ["d1/f1"],
-    "node": null,
+    "node": "ffffffffffffffffffffffffffffffffffffffff",
     "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"],
     "phase": "draft",
     "removed": [".d6/f1"],
-    "rev": null,
+    "rev": 2147483647,
     "tags": [],
     "user": "test"
    }
--- a/tests/test-template-keywords.t	Sun Sep 23 16:11:01 2018 +0900
+++ b/tests/test-template-keywords.t	Sat Sep 15 17:26:20 2018 +0900
@@ -52,6 +52,27 @@
   $ hg log -r 'wdir()' -T '{rev}:{node}\n'
   2147483647:ffffffffffffffffffffffffffffffffffffffff
 
+  $ hg log -r 'wdir()' -Tjson --debug
+  [
+   {
+    "added": [],
+    "bookmarks": [],
+    "branch": "default",
+    "date": [0, 0],
+    "desc": "",
+    "extra": {"branch": "default"},
+    "manifest": null,
+    "modified": [],
+    "node": "ffffffffffffffffffffffffffffffffffffffff",
+    "parents": ["95c24699272ef57d062b8bccc32c878bf841784a"],
+    "phase": "draft",
+    "removed": [],
+    "rev": 2147483647,
+    "tags": [],
+    "user": "test"
+   }
+  ]
+
 Some keywords are invalid for working-directory revision, but they should
 never cause crash: