diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -1101,21 +1101,24 @@ class changeset_printer(object): '''show a single changeset or file revision''' changenode = ctx.node() rev = ctx.rev() - - if self.ui.quiet: - self.ui.write("%d:%s\n" % (rev, short(changenode)), - label='log.node') - return - - date = util.datestr(ctx.date()) - if self.ui.debugflag: hexfunc = hex else: hexfunc = short + if rev is None: + pctx = ctx.p1() + revnode = (pctx.rev(), hexfunc(pctx.node()) + '+') + else: + revnode = (rev, hexfunc(changenode)) + + if self.ui.quiet: + self.ui.write("%d:%s\n" % revnode, label='log.node') + return + + date = util.datestr(ctx.date()) # i18n: column positioning for "hg log" - self.ui.write(_("changeset: %d:%s\n") % (rev, hexfunc(changenode)), + self.ui.write(_("changeset: %d:%s\n") % revnode, label='log.changeset changeset.%s' % ctx.phasestr()) # branches are shown first before any other names due to backwards diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -1623,6 +1623,16 @@ issue3772: hg log -r :null showing revis user: date: Thu Jan 01 00:00:00 1970 +0000 +working-directory revision requires special treatment + + $ hg log -r 'wdir()' + changeset: 0:65624cd9070a+ + user: test + date: [A-Za-z0-9:+ ]+ (re) + + $ hg log -r 'wdir()' -q + 0:65624cd9070a+ + Check that adding an arbitrary name shows up in log automatically $ cat > ../names.py <