[PATCH 2 of 2] mq: don't confuse 0 with None when referencing patches

Mads Kiilerich mads at kiilerich.com
Tue Oct 26 20:23:10 CDT 2010


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1288142540 -7200
# Branch stable
# Node ID 57151be6b269814f9835c36bde611d1a2f4a3311
# Parent  853b21b7c75ae00ecb711cde0c5737458de055b5
mq: don't confuse 0 with None when referencing patches

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -929,12 +929,10 @@
     # if the exact patch name does not exist, we try a few
     # variations.  If strict is passed, we try only #1
     #
-    # 1) a number to indicate an offset in the series file
+    # 1) a number (as string) to indicate an offset in the series file
     # 2) a unique substring of the patch name was given
     # 3) patchname[-+]num to indicate an offset in the series file
     def lookup(self, patch, strict=False):
-        patch = patch and str(patch)
-
         def partial_name(s):
             if s in self.series:
                 return s
@@ -953,7 +951,7 @@
                     return self.series[0]
             return None
 
-        if patch is None:
+        if not patch:
             return None
         if patch in self.series:
             return patch
@@ -2636,7 +2634,7 @@
                 if i == 0:
                     q.pop(repo, all=True)
                 else:
-                    q.pop(repo, i - 1)
+                    q.pop(repo, str(i - 1))
                 break
     if popped:
         try:
diff --git a/tests/test-mq-guards.t b/tests/test-mq-guards.t
--- a/tests/test-mq-guards.t
+++ b/tests/test-mq-guards.t
@@ -477,19 +477,19 @@
   $ hg qselect --reapply not-c
   popping guarded patches
   popping d.patch
-  now at: c.patch
+  popping c.patch
+  now at: new.patch
   reapplying unguarded patches
   applying d.patch
   patch d.patch is empty
   now at: d.patch
   $ hg qser -v
   0 A new.patch
-  1 A c.patch
+  1 G c.patch
   2 A d.patch
   $ hg qselect --reapply not-new
   popping guarded patches
   popping d.patch
-  popping c.patch
   popping new.patch
   patch queue now empty
   reapplying unguarded patches


More information about the Mercurial-devel mailing list