mq: don't warn about ambiguous patch name when using patch index (issue1439)
authorJason Orendorff <jorendorff@mozilla.com>
Tue, 06 Jan 2009 10:30:22 +0100
changeset 7568 12df451ce205
parent 7567 0946294d1f32
child 7569 89207edf3973
child 7607 3cf85220a9f9
mq: don't warn about ambiguous patch name when using patch index (issue1439)
hgext/mq.py
tests/test-mq-qgoto
tests/test-mq-qgoto.out
--- a/hgext/mq.py	Mon Jan 05 14:34:20 2009 +0100
+++ b/hgext/mq.py	Tue Jan 06 10:30:22 2009 +0100
@@ -838,14 +838,11 @@
                 if s == 'qbase':
                     return self.series[0]
             return None
+
         if patch == None:
             return None
-
-        # we don't want to return a partial match until we make
-        # sure the file name passed in does not exist (checked below)
-        res = partial_name(patch)
-        if res and res == patch:
-            return res
+        if patch in self.series:
+            return patch
 
         if not os.path.isfile(self.join(patch)):
             try:
@@ -853,10 +850,11 @@
             except(ValueError, OverflowError):
                 pass
             else:
-                if sno < len(self.series):
+                if -len(self.series) <= sno < len(self.series):
                     return self.series[sno]
+
             if not strict:
-                # return any partial match made above
+                res = partial_name(patch)
                 if res:
                     return res
                 minus = patch.rfind('-')
--- a/tests/test-mq-qgoto	Mon Jan 05 14:34:20 2009 +0100
+++ b/tests/test-mq-qgoto	Tue Jan 06 10:30:22 2009 +0100
@@ -25,3 +25,25 @@
 hg qgoto a.patch
 hg qgoto c.patch
 hg qgoto b.patch
+
+echo
+echo % Using index
+hg qgoto 0
+hg qgoto 2
+
+echo
+echo % No warnings when using index
+hg qnew bug314159
+echo d >> c
+hg qrefresh
+hg qnew bug141421
+echo e >> c
+hg qrefresh
+hg qgoto 1
+hg qgoto 3
+
+echo
+echo % Detect ambiguous non-index
+hg qgoto 14
+
+exit 0
--- a/tests/test-mq-qgoto.out	Mon Jan 05 14:34:20 2009 +0100
+++ b/tests/test-mq-qgoto.out	Tue Jan 06 10:30:22 2009 +0100
@@ -4,3 +4,21 @@
 applying c.patch
 Now at: c.patch
 Now at: b.patch
+
+% Using index
+Now at: a.patch
+applying b.patch
+applying c.patch
+Now at: c.patch
+
+% No warnings when using index
+Now at: b.patch
+applying c.patch
+applying bug314159
+Now at: bug314159
+
+% Detect ambiguous non-index
+patch name "14" is ambiguous:
+  bug314159
+  bug141421
+abort: patch 14 not in series