# HG changeset patch # User Yuya Nishihara <y...@tcha.org> # Date 1536999980 -32400 # Sat Sep 15 17:26:20 2018 +0900 # Node ID 9902b9afed7e73e5e84415d424014d27bc8f7c66 # Parent dc7aae11254db3db8f8994c8dd620dd0a5963fab 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. diff --git a/mercurial/logcmdutil.py b/mercurial/logcmdutil.py --- a/mercurial/logcmdutil.py +++ b/mercurial/logcmdutil.py @@ -325,16 +325,9 @@ class changesetformatter(changesetprinte '''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 @@ class changesetformatter(changesetprinte 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()) diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -2208,10 +2208,10 @@ dirty: "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 @@ dirty: $ hg log -r 'wdir()' -Tjson -q [ { - "node": null, - "rev": null + "node": "ffffffffffffffffffffffffffffffffffffffff", + "rev": 2147483647 } ] @@ -2236,11 +2236,11 @@ dirty: "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" } diff --git a/tests/test-template-keywords.t b/tests/test-template-keywords.t --- a/tests/test-template-keywords.t +++ b/tests/test-template-keywords.t @@ -52,6 +52,27 @@ experimental: $ 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: _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel