revpair: handle odd ranges (issue3474) stable
authorMatt Mackall <mpm@selenic.com>
Wed, 30 May 2012 14:13:57 -0500
branchstable
changeset 16790 2a0efa1112ac
parent 16789 c17ce7cd5090
child 16791 977c80123835
child 16799 0568c499c44a
revpair: handle odd ranges (issue3474)
mercurial/scmutil.py
tests/test-diff-change.t
--- a/mercurial/scmutil.py	Wed May 23 00:25:29 2012 +0900
+++ b/mercurial/scmutil.py	Wed May 30 14:13:57 2012 -0500
@@ -524,9 +524,11 @@
     l = revrange(repo, revs)
 
     if len(l) == 0:
+        if revs:
+            raise util.Abort(_('empty revision range'))
         return repo.dirstate.p1(), None
 
-    if len(l) == 1:
+    if len(l) == 1 and len(revs) == 1 and _revrangesep not in revs[0]:
         return repo.lookup(l[0]), None
 
     return repo.lookup(l[0]), repo.lookup(l[-1])
--- a/tests/test-diff-change.t	Wed May 23 00:25:29 2012 +0900
+++ b/tests/test-diff-change.t	Wed May 30 14:13:57 2012 -0500
@@ -29,6 +29,12 @@
   -first
   +second
 
+Test dumb revspecs (issue3474)
+
+  $ hg diff -r 2:2
+  $ hg diff -r "2 and 1"
+  abort: empty revision range
+  [255]
 
 Testing diff --change when merge: