Mercurial > hg
changeset 24602:201caa10536b
jsonchangeset: set rev and node to "null" for workingctx
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Mar 2015 20:15:40 +0900 |
parents | d80819f67d59 |
children | e74f819e9160 |
files | mercurial/cmdutil.py tests/test-log.t |
diffstat | 2 files changed, 33 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Apr 03 21:36:39 2015 +0900 +++ b/mercurial/cmdutil.py Sat Mar 14 20:15:40 2015 +0900 @@ -1260,8 +1260,12 @@ def _show(self, ctx, copies, matchfn, props): '''show a single changeset or file revision''' - hexnode = hex(ctx.node()) rev = ctx.rev() + if rev is None: + jrev = jnode = 'null' + else: + jrev = str(rev) + jnode = '"%s"' % hex(ctx.node()) j = encoding.jsonescape if self._first: @@ -1271,13 +1275,13 @@ self.ui.write(",\n {") if self.ui.quiet: - self.ui.write('\n "rev": %d' % rev) - self.ui.write(',\n "node": "%s"' % hexnode) + self.ui.write('\n "rev": %s' % jrev) + self.ui.write(',\n "node": %s' % jnode) self.ui.write('\n }') return - self.ui.write('\n "rev": %d' % rev) - self.ui.write(',\n "node": "%s"' % hexnode) + self.ui.write('\n "rev": %s' % jrev) + self.ui.write(',\n "node": %s' % jnode) self.ui.write(',\n "branch": "%s"' % j(ctx.branch())) self.ui.write(',\n "phase": "%s"' % ctx.phasestr()) self.ui.write(',\n "user": "%s"' % j(ctx.user()))
--- a/tests/test-log.t Fri Apr 03 21:36:39 2015 +0900 +++ b/tests/test-log.t Sat Mar 14 20:15:40 2015 +0900 @@ -1642,6 +1642,30 @@ date: [A-Za-z0-9:+ ]+ (re) extra: branch=default + $ hg log -r 'wdir()' -Tjson + [ + { + "rev": null, + "node": null, + "branch": "default", + "phase": "draft", + "user": "test", + "date": [*, 0], (glob) + "desc": "", + "bookmarks": [], + "tags": ["tip"], + "parents": ["65624cd9070a035fa7191a54f2b8af39f16b0c08"] + } + ] + + $ hg log -r 'wdir()' -Tjson -q + [ + { + "rev": null, + "node": null + } + ] + Check that adding an arbitrary name shows up in log automatically $ cat > ../names.py <<EOF