Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 24175:c4e3e7b031b7
revrange: don't parse revset aliases as hash prefixes (issue4553)
If a user has a revsetalias defined, it is their explicit wish for
this alias to be parsed as a revset and nothing else. Although the
case of the alias being short enough and only contain the letters a-f
is probably kind of rare, it may still happen.
author | Jordi Guti?rrez Hermoso <jordigh@octave.org> |
---|---|
date | Wed, 25 Feb 2015 18:12:01 -0500 |
parents | fafd9a1284cf |
children | ca1365078c86 |
line wrap: on
line diff
--- a/mercurial/scmutil.py Tue Feb 24 08:49:22 2015 +0100 +++ b/mercurial/scmutil.py Wed Feb 25 18:12:01 2015 -0500 @@ -628,12 +628,22 @@ return repo[val].rev() seen, l = set(), revset.baseset([]) + + revsetaliases = [alias for (alias, _) in + repo.ui.configitems("revsetalias")] + for spec in revs: if l and not seen: seen = set(l) # attempt to parse old-style ranges first to deal with # things like old-tag which contain query metacharacters try: + # ... except for revset aliases without arguments. These + # should be parsed as soon as possible, because they might + # clash with a hash prefix. + if spec in revsetaliases: + raise error.RepoLookupError + if isinstance(spec, int): seen.add(spec) l = l + revset.baseset([spec]) @@ -641,6 +651,9 @@ if _revrangesep in spec: start, end = spec.split(_revrangesep, 1) + if start in revsetaliases or end in revsetaliases: + raise error.RepoLookupError + start = revfix(repo, start, 0) end = revfix(repo, end, len(repo) - 1) if end == nullrev and start < 0: