Missing an argument to an alias using positional arguments throws a stacktrace. F:\temp\branching> hg --config alias.bob="log --style $1 --rev $2" bob compact ** unknown exception encountered, please report by visiting ** http://mercurial.selenic.com/wiki/BugTracker ** Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] ** Mercurial Distributed SCM (version 2.1.1) ** Extensions loaded: Traceback (most recent call last): File "hg", line 42, in <module> File "mercurial\dispatch.pyo", line 27, in run File "mercurial\dispatch.pyo", line 64, in dispatch File "mercurial\dispatch.pyo", line 87, in _runcatch File "mercurial\dispatch.pyo", line 578, in _dispatch File "mercurial\dispatch.pyo", line 386, in _parse File "mercurial\dispatch.pyo", line 229, in aliasargs File "re.pyo", line 151, in sub File "mercurial\dispatch.pyo", line 228, in replacer IndexError: list index out of range
Fixed by http://selenic.com/repo/hg/rev/1c2aaf05f7d7 Matt Mackall <mpm@selenic.com> aliases: use empty string for missing position parameters (issue3331) (please test the fix)
Fix tested: H:\hg\hg-stable>hg-Python26\python hg.py --config alias.bob="log --style $1 --rev $2" bob compact hg: parse error: empty query Confirm no more exception traceback reported. However the error reported is not helpful. There is no indication whether it is too few args to the alias or a deeper problem in mercurial processing the command. In the case above for --rev I expected to see what normally happens when the rev is omitted: H:\hg\hg-stable>hg-Python26\python hg.py log --rev hg log: option --rev requires argument hg log [OPTION]... [FILE] ... What happens is effectively hg log --rev "" which is not obvious, and the replacement with an empty string may have different results for different command arguments (e.g. a commit alias with a positional arg for the commit message that is no supplied.) I'd be happy with just reporting fewer arguments than required by the alias.
The following would be more helpful in my view as it is more obvious where the source of the problem is: H:\hg\hg-stable>hg-python26\python hg.py diff diff -r 900eee0778d1 mercurial/dispatch.py --- a/mercurial/dispatch.py Thu Mar 22 17:07:39 2012 -0500 +++ b/mercurial/dispatch.py Fri Mar 23 10:52:10 2012 +0000 @@ -227,7 +227,7 @@ nums.append(num) if num < len(givenargs): return givenargs[num] - return '' + raise util.Abort(_('too few arguments for command alias')) cmd = re.sub(r'\$(\d+|\$)', replacer, cmd) givenargs = [x for i, x in enumerate(givenargs) if i not in nums] H:\hg\hg-stable>hg-python26\python hg.py --config alias.bob="log --style $1 --rev $2" bob compact abort: too few arguments for command alias
Fixed by http://selenic.com/repo/hg/rev/795d591b6ef5 Matt Mackall <mpm@selenic.com> alias: abort on missing positional args (issue3331) (please test the fix)
Yay, happy dance! Works for me - many thanks.
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:29 EDT --- This bug was previously known as _bug_ 3331 at http://mercurial.selenic.com/bts/issue3331 Bug Status was UNCONFIRMED but everconfirmed was true Setting status to CONFIRMED
Fixed by https://mercurial-scm.org/repo/hg/rev/a046d6890761 Martin von Zweigbergk <martinvonz@google.com> rebase: avoid defining two lists with the same contents In abort(), there's "dstates" and "rebased" that are identical, which they seem to have been since 0806823370d8 (rebase: properly calculate descendant set when aborting (issue3332), 2012-03-22). Let's de-duplicate. I don't know what "dstates" means, but "rebased" makes sense (it's the list of rebased revisions), so let's pick that. Differential Revision: https://phab.mercurial-scm.org/D2878 (please test the fix)
Bug was set to TESTING for 7 days, resolving