# HG changeset patch # User Matt Mackall # Date 2010-06-19 18:00:01 # Node ID bf5d88c466e0bc5632c8d54a0d408d81eb9e366b # Parent 37cbedbeae96bfcc78ed3c1d657d40577c856011 revrange: attempt to parse old-style queries as a first pass diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -149,29 +149,35 @@ def revrange(repo, revs): seen, l = set(), [] for spec in revs: - if spec and not ( - spec.startswith(revrangesep) or spec.endswith(revrangesep)): - m = revset.match(spec) - for r in m(repo, range(len(repo))): - if r not in seen: - l.append(r) - seen.update(l) - elif revrangesep in spec: - start, end = spec.split(revrangesep, 1) - start = revfix(repo, start, 0) - end = revfix(repo, end, len(repo) - 1) - step = start > end and -1 or 1 - for rev in xrange(start, end + step, step): + # attempt to parse old-style ranges first to deal with + # things like old-tag which contain query metacharacters + try: + if revrangesep in spec: + start, end = spec.split(revrangesep, 1) + start = revfix(repo, start, 0) + end = revfix(repo, end, len(repo) - 1) + step = start > end and -1 or 1 + for rev in xrange(start, end + step, step): + if rev in seen: + continue + seen.add(rev) + l.append(rev) + continue + elif spec in repo: # single unquoted rev + rev = revfix(repo, spec, None) if rev in seen: continue seen.add(rev) l.append(rev) - else: - rev = revfix(repo, spec, None) - if rev in seen: - continue - seen.add(rev) - l.append(rev) + except error.RepoLookupError: + pass + + # fall through to new-style queries if old-style fails + m = revset.match(spec) + for r in m(repo, range(len(repo))): + if r not in seen: + l.append(r) + seen.update(l) return l diff --git a/tests/test-log.out b/tests/test-log.out --- a/tests/test-log.out +++ b/tests/test-log.out @@ -269,7 +269,7 @@ diff --git a/b1 b/b1 +postm % log -r "" -abort: 00changelog.i@: ambiguous identifier! +hg: parse error: empty query % log -r abort: unknown revision '1000000000000000000000000000000000000000'! % log -k r1