Changing the wdir() {rev} and {node} output

Jordi Gutiérrez Hermoso jordigh at
Mon Apr 29 11:37:02 EDT 2019

On Wed, 2019-04-17 at 08:29 +0900, Yuya Nishihara wrote:
> On Tue, 16 Apr 2019 10:14:53 -0400, Jordi Gutiérrez Hermoso wrote:
> > While I think it might be okay to keep the iternal values,
>> >
>> > I think it's far too confusing to expose them in the user interface.
>> > A particular inconsistency I see is that we already have a way to show
> > wdir(), for example. In a way, `hg id -T` is kind of an alias for `hg
> > log -r 'wdir()' -T ... ` in a way that is not obvious. But trying to
> > use '{node}' or '{rev}' in `hg id` results in exposing the internal
> > revision and node magic numbers, which is very confusing behaviour,
> > since the default behaviour of `hg id` is to show `{p1.rev}+` instead
> > if there are changes in the wdir.
>> > Another instance in which this happens is `hg annotate -r 'wdir()'`,
> > which also shows plusses to indicate that the changes are only in the
> > working directory.
>> > I think we should keep this behaviour throughout, for consistency.
> > Since `wdir()` is still marked as experimental, we can change its
> > current behaviour. I propose consistency with `hg id` as follows:
> First, I'm okay to change the output of "hg whatever -r 'wdir()'" if that
> makes things more consistent. However, {rev}/{node} keywords should still
> return wdirrev/wdirhex since they are valid identifiers whereas "<p1node>+"
> isn't.

But this is the problem that we currently have. It's difficult to
produce the default template of `hg id` unless you dig deeper into
template syntax. Maybe we should just make the `+` part of the syntax
for parsing revnums... but that conflicts with revset syntax, oh

Could we add a unary postfix `+` operator to revsets?

> >     * If the working directory is clean, the following are equivalent:
>> >           hg log -r 'wdir()' -T '{rev}:{node}'
> >           hg log -r . -T '{rev}:{node}'
> Do you mean `hg log -r 'wdir()'` should fall back to '.' if wdir is clean?
> I believe it'll be way complicated.

Maybe yes? Conceptually, showing the log for the wdir doesn't seem to
be that useful of an operation. The only reason I can see for doing
that is to get the current time and the current user, but that would
probably be better done with dedicated template keywords.

> If clean "wdir()" == ".", "hg status --change 'wdir()'" would have to
> show the changes in "." as well, which makes no sense.

Hm, okay, I see the complication here. So maybe let's not do this
except for display purpose of the {rev} and {node} template keywords.

More information about the Mercurial-devel mailing list