Explained by example: A script to prepare a repository: -------------------------------- hg init echo l-1 > f hg add f hg qnew some-bug-fix echo l-2 >> f hg qnew idea-start echo l-3 >> f hg qnew idea-improved -------------------------------- Trying to see the diff of combined changes by all idea-* patches: This used to work in Mercurial 1.8.4 with parentrevspec extension but gives an error in 1.9: $ hg diff -r idea-start^:idea-improved abort: unknown revision 'idea'! This is a regression. I carry around tens of patches, all of them with dashes in their names as word separators. One could try to work around this by adding a lot of ugly quotes and backslash escapes: hg diff -r \'idea-start\'^:\'idea-improved\' However, even this doesn't work, and throws an exception: ** unknown exception encountered, please report by visiting ** http://mercurial.selenic.com/wiki/BugTracker ** Python 2.4.3 (#1, Sep 3 2009, 15:37:37) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] ** Mercurial Distributed SCM (version 1.9) ** Extensions loaded: extdiff, graphlog, hgk, record, transplant, mq, color, rpcath, rebase, convert, children, schemes, progress, patience Traceback (most recent call last): File "/home/tomba/mercurial/bin/hg", line 38, in ? mercurial.dispatch.run() File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 27, in run File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 64, in dispatch File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 87, in _runcatch File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 675, in _dispatch File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 454, in runcommand File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/extensions.py", line 182, in wrap File "home/tomba/mercurial/lib64/python2.4/site-packages/hgext/color.py", line 367, in colorcmd File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 729, in _runcommand File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 683, in checkargs File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/dispatch.py", line 672, in <lambda> File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/util.py", line 385, in check File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/extensions.py", line 136, in wrap File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/util.py", line 385, in check File "/home/tomba/hg/hg-patience/patience.py", line 66, in diffcmdwrapper ret = orig(*args, **kwargs) File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/util.py", line 385, in check File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/extensions.py", line 136, in wrap File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/util.py", line 385, in check File "home/tomba/mercurial/lib64/python2.4/site-packages/hgext/mq.py", line 3218, in mqcommand File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/util.py", line 385, in check File "/usr/lib64/python2.4/commands.py", line 2188, in diff File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/scmutil.py", line 486, in revpair File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/scmutil.py", line 539, in revrange File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/revset.py", line 1017, in mfunc File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/revset.py", line 120, in getset File "home/tomba/mercurial/lib64/python2.4/site-packages/mercurial/revset.py", line 676, in parentspec TypeError: int() argument must be a string or a number The exception is a secondary issue. The main issue is that specifying parent revision with ^ stopped working when using mq patch names with dashes as word separators.
This is a fallout from revsets. I pointed it out at the time because I used to have a lot of branch names with dashes, but it somehow fell under the rug, it seems. (See https://groups.google.com/d/msg/mercurial_devel/aQ0VbR1bYP0/TLTYIj1f0QsJ)
This works fine: hg log -r foo-bar ..when parsing of the expression "foo - bar" fails, we fall back to looking up "foo-bar". This fails: hg log -r foo-bar^ ..because the parentrevspec extension no longer exists and ^ is now understood as being part of a revset expression "foo - bar^". However, this works: hg log -r '"foo-bar"^' just as described in the revset help: Identifiers such as branch names must be quoted with single or double quotes if they contain characters outside of "[._a-zA-Z0-9\x80-\xff]" or if they match one of the predefined predicates. Your attempt at quoting doesn't get past your shell.
> Your attempt at quoting doesn't get past your shell. It did get past shell, as evidenced by: $ echo hg diff -r \'idea-start\'^:\'idea-improved\' hg diff -r 'idea-start'^:'idea-improved' Quoting the way you showed: $ hg diff -r '"idea-start"^:"idea-improved"' gives the same exception.
Ahh, you're right. The exception is caused by ^ expecting a number if it's used as an infix operator and is triggered by a simple: foo^:bar This works: '("foo-bar"^):"foo-baz"' Looks like the best way to fix this is to have optimizer restructure the expression when it encounters x^:y. Here's a fix: diff -r 62bb370ee3f3 mercurial/revset.py --- a/mercurial/revset.py Tue Jul 05 17:46:12 2011 -0500 +++ b/mercurial/revset.py Wed Jul 06 13:34:06 2011 -0500 @@ -928,6 +928,14 @@ elif op == 'group': return optimize(x[1], small) elif op in 'range list parent ancestorspec': + if op == 'parent': + # x^:y means (x^) : y, not x ^ (:y) + post = ('parentpost', x[1]) + if x[2][0] == 'dagrangepre': + return optimize(('dagrange', post, x[2][1]), small) + elif x[2][0] == 'rangepre': + return optimize(('range', post, x[2][1]), small) + wa, ta = optimize(x[1], small) wb, tb = optimize(x[2], small) return wa + wb, (op, ta, tb)
This fixed the exception. Thank you. Can we make mq patch names with dashes in them work without quoting? Four quotes and four apostrophes is quite a bit just to use "^" for parent revision. One would just not use "^" instead. Removing support for the "-" convenience operator fixes the problem.
A minor correction: four quotes and *two* apostrophes.
Fixed by http://selenic.com/repo/hg/rev/805651777188 Matt Mackall <mpm@selenic.com> revsets: do the right thing with x^:y (issue2884) (please test the fix)
Fixed by http://selenic.com/repo/hg/rev/f96c354493d7 Matt Mackall <mpm@selenic.com> revsets: actually catch type error on tip^p1(tip) (issue2884) (please test the fix)
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:21 EDT --- This bug was previously known as _bug_ 2884 at http://mercurial.selenic.com/bts/issue2884 Imported an attachment (id=1562)