Bug 5764 - .^:: gives "hg: parse error at 4: not a prefix: end"
Summary: .^:: gives "hg: parse error at 4: not a prefix: end"
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: revset (show other bugs)
Version: default branch
Hardware: PC Linux
: wish feature
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-28 17:04 UTC by Kyle Lippincott
Modified: 2018-01-17 15:07 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Lippincott 2017-12-28 17:04 UTC
≻ hg version
Mercurial Distributed SCM (version 4.4.2+390-b963750b125f)
(see https://mercurial-scm.org for more information)

Copyright (C) 2005-2017 Matt Mackall and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Broken version:
≻ ./hg log -r '.^::' -T '{shortest(node,8)}\n' 
hg: parse error at 4: not a prefix: end


Working versions:
≻ ./hg log -r '(.^)::' -T '{shortest(node,8)}\n'
8bb90cc4
b378a3d8

≻ ./hg log -r '.^::all()' -T '{shortest(node,8)}\n' 
8bb90cc4
b378a3d8

≻ ./hg log -r '.^::.' -T '{shortest(node,8)}\n' 
8bb90cc4
b378a3d8


I assume what's happening is that ^ is being interpreted before the ::, so hg is parsing this as (.)^(::), i.e. x^n where x=., n=::, and not like (.^)::, i.e. x::y, where x=.^ and y is unspecified.
Comment 1 Yuya Nishihara 2017-12-30 02:41 UTC
> parsing this as (.)^(::)

Exactly.

This is a limitation of the current parser with 1 lookahead, but it's confusing
that x^::y is allowed but x^:: isn't.

https://www.mercurial-scm.org/repo/hg/rev/805651777188
Comment 2 HG Bot 2018-01-16 13:05 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/beb667c9880f
Yuya Nishihara <yuya@tcha.org>
revset: parse x^:: as (x^):: (issue5764)

We have to make '::' a valid primary expression to parse 'x^::' as '(x)^(::)'
first, but that doesn't change the language because a prefix operator '::y'
precedes a primary '::'.

I can't think of an intuitive meaning of '::', so it's just rejected. Given
'x::y' can be considered to default to {x = roots(), y = heads()}, '::' could
be 'roots()::heads()', which seems not any useful.

(please test the fix)