hg log -f -r : foo.cpp gives an error

Matt Mackall mpm at selenic.com
Fri Jul 17 19:10:59 UTC 2015


On Fri, 2015-07-17 at 14:38 -0400, Bob Eby wrote:
> Hi Everyone,
> 
> When I run:
> 
> hg log -f -r : foo.cpp

I have no idea what you'd expect this to do: following the history.. of
all the history is a bit meaningless.

Or maybe you're just trying to control the order that's output.

> on my repository I get some kind of error:
> 
> hg: parse error at 1: not a prefix: end

The simplest version of this bug is:

 $ hg log -r "(:)"
 hg: parse error at 2: not a prefix: )

And that's because ":" is not a valid revset (see hg help revsets), but
IS a valid legacy specifier (which we silently fall back to when we
can't parse something as a revset). Unfortunately, bare ":" is simply
too ambiguous to be part of revsets in any useful way and most of us
have forgotten it even exists. But when we use follow, the -r option can
only be a revset, because it gets built into a larger revset:

    opts['rev'] = [revset.formatspec('reverse(::%lr)', opts.get('rev'))]

which means the resulting expression is:

  reverse(::(:))

..which also explains why you're having trouble reversing it: the
ancestors of the argument have a predefined order that's getting
reversed.

You might want to try one of:

  hg log -r "reverse(follow('foo.cpp'))"
  hg log -r "follow('foo.cpp')"

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial mailing list