shooting in the foot with caret ^ on windows

Simon King simon at simonking.org.uk
Mon Jul 21 11:09:10 UTC 2014


On Mon, Jul 21, 2014 at 11:31 AM, anatoly techtonik <techtonik at gmail.com> wrote:
> On Mon, Jul 21, 2014 at 12:25 PM, Simon King <simon at simonking.org.uk> wrote:
>> On Mon, Jul 21, 2014 at 3:53 AM, anatoly techtonik <techtonik at gmail.com> wrote:
>>> On Mon, Jul 21, 2014 at 2:10 AM, Matt Mackall <mpm at selenic.com> wrote:
>>>> On Sun, 2014-07-20 at 13:53 +0300, anatoly techtonik wrote:
>>>>> C:\discovery>hg log -r tip^ --style compact
>>>>> 108   6dab298d9851   2014-05-16 21:40 +0300   techtonik
>>>>>   graphics/pysdl2/demofire.py: 1.5 - Fire Plane (not optimized)
>>>> ...
>>>>> It would be nice to mention this on
>>>>> http://www.selenic.com/hg/help/revsets and link to
>>>>> cross-platform alternative.
>>>>
>>>> Docs: sure, send a patch.
>>>
>>> Is there online editor somewhere?
>>>
>>>> As for a shell-safe alternative, the following symbols aren't suitable:
>>>>
>>>> `~!@#$%&*()_-+=\|:;'"<>,./?
>>>>
>>>> ..because they're either used by a common shell and/or revsets already.
>>>> As that's every single other symbol on a US keyboard, I'm going to have
>>>> to deny your request.
>>>
>>> Isn't something like parents(tip)[3] is an safe alternative to tip^3 ?
>>
>> (aside: tip^3 doesn't make sense - a changeset can have at most 2 parents)
>>
>> I'm not sure I understand what you mean by safe. That wouldn't work in bash:
>>
>>   $: hg log -r parents(tip)
>>   -bash: syntax error near unexpected token `('
>
> On Windows this is ok. But it is not clear how to choose second parent.

The p1() and p2() functions select the first and second parents. It
looks like parentheses don't need quoting in Windows, so:

  hg log -r p2(tip)

...should do what you want. Of course, in bash you'd need to quote that...

>
>> It's also much longer to type than just putting quotes around the caret version:
>>
>>   hg log -r "tip^2"
>
> To much surprise, quoting works, but you need to know about that.

I suppose, but understanding your shell's quoting rules is important
if you want to be able to do anything non-trivial with it.
Unfortunately, the Windows command processor is particularly obscure.
I generally quote revset expressions out of habit because I have no
idea what characters Windows treats as special.

>
> Looks like there is no convenient solution possible. It will be either
> Windows-only
> or Linux-only. Is there a pattern name for such cases?

Life?

Simon



More information about the Mercurial mailing list