changeset 11405:bf5d88c466e0

revrange: attempt to parse old-style queries as a first pass
author Matt Mackall <mpm@selenic.com>
date Sat, 19 Jun 2010 13:00:01 -0500
parents 37cbedbeae96
children 42408cd43f55
files mercurial/cmdutil.py tests/test-log.out
diffstat 2 files changed, 26 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Jun 19 12:22:35 2010 -0500
+++ b/mercurial/cmdutil.py	Sat Jun 19 13:00:01 2010 -0500
@@ -149,29 +149,35 @@
 
     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
 
--- a/tests/test-log.out	Sat Jun 19 12:22:35 2010 -0500
+++ b/tests/test-log.out	Sat Jun 19 13:00:01 2010 -0500
@@ -269,7 +269,7 @@
 +postm
 
 % log -r ""
-abort: 00changelog.i@: ambiguous identifier!
+hg: parse error: empty query
 % log -r <some unknown node id>
 abort: unknown revision '1000000000000000000000000000000000000000'!
 % log -k r1