Mercurial > hg-stable
changeset 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 | 0d37b9b21467 |
children | 60c791592aa7 |
files | mercurial/cmdutil.py tests/test-add.t tests/test-command-template.t tests/test-log.t |
diffstat | 4 files changed, 28 insertions(+), 10 deletions(-) [+] |
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')
--- a/tests/test-add.t Wed Jul 08 16:19:09 2015 -0700 +++ b/tests/test-add.t Sat Jul 04 17:19:49 2015 +0900 @@ -109,7 +109,7 @@ wdir doesn't cause a crash, and can be dynamically selected if dirty $ hg log -r "heads(. or wdir() & file('**'))" - changeset: 2:*+ (glob) + changeset: 2147483647:ffffffffffff parent: 2:* (glob) parent: 1:* (glob) user: test
--- a/tests/test-command-template.t Wed Jul 08 16:19:09 2015 -0700 +++ b/tests/test-command-template.t Sat Jul 04 17:19:49 2015 +0900 @@ -180,6 +180,26 @@ $ hg log --debug -T phases > phases.out $ cmp log.out phases.out || diff -u log.out phases.out +Default style of working-directory revision should also be the same (but +date may change while running tests): + + $ hg log -r 'wdir()' | sed 's|^date:.*|date:|' > log.out + $ hg log -r 'wdir()' --style default | sed 's|^date:.*|date:|' > style.out + $ cmp log.out style.out || diff -u log.out style.out + + $ hg log -r 'wdir()' -v | sed 's|^date:.*|date:|' > log.out + $ hg log -r 'wdir()' -v --style default | sed 's|^date:.*|date:|' > style.out + $ cmp log.out style.out || diff -u log.out style.out + + $ hg log -r 'wdir()' -q > log.out + $ hg log -r 'wdir()' -q --style default > style.out + $ cmp log.out style.out || diff -u log.out style.out + + $ hg log -r 'wdir()' --debug | sed 's|^date:.*|date:|' > log.out + $ hg log -r 'wdir()' --debug --style default \ + > | sed 's|^date:.*|date:|' > style.out + $ cmp log.out style.out || diff -u log.out style.out + Default style should also preserve color information (issue2866): $ cp $HGRCPATH $HGRCPATH-bak
--- a/tests/test-log.t Wed Jul 08 16:19:09 2015 -0700 +++ b/tests/test-log.t Sat Jul 04 17:19:49 2015 +0900 @@ -1626,16 +1626,16 @@ working-directory revision requires special treatment $ hg log -r 'wdir()' - changeset: 0:65624cd9070a+ + changeset: 2147483647:ffffffffffff parent: 0:65624cd9070a user: test date: [A-Za-z0-9:+ ]+ (re) $ hg log -r 'wdir()' -q - 0:65624cd9070a+ + 2147483647:ffffffffffff $ hg log -r 'wdir()' --debug - changeset: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08+ + changeset: 2147483647:ffffffffffffffffffffffffffffffffffffffff phase: draft parent: 0:65624cd9070a035fa7191a54f2b8af39f16b0c08 parent: -1:0000000000000000000000000000000000000000