[PATCH 2 of 2] mq: cleanup of lookup - handling of None is not relevant

Mads Kiilerich mads at kiilerich.com
Thu Oct 13 19:58:41 CDT 2011


# HG changeset patch
# User Mads Kiilerich <mads at kiilerich.com>
# Date 1318553406 -7200
# Node ID 1a582dcd9135a2ff228a5e65ec11a4f1e88fa27c
# Parent  5fe62c65a0ea2961fae1c319998aee70864cb907
mq: cleanup of lookup - handling of None is not relevant

Patch specifications in mq is passed around as a string or None. None is
generally used when no patch has been specified and there thus is nothing to
lookup and the calling code should do something else. One code path did however
pass None all the way to lookup. That case was handled in lookup, but there was
really need for that, it was undocumented, and it used to cause trouble back
when patches was specified as integers.

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -1034,8 +1034,6 @@
                     return self.series[0]
             return None
 
-        if patch is None:
-            return None
         if patch in self.series:
             return patch
 
@@ -1095,12 +1093,12 @@
                 self.ui.warn(_('no patches in series\n'))
                 return 0
 
-            patch = self.lookup(patch)
             # Suppose our series file is: A B C and the current 'top'
             # patch is B. qpush C should be performed (moving forward)
             # qpush B is a NOP (no change) qpush A is an error (can't
             # go backwards with qpush)
             if patch:
+                patch = self.lookup(patch)
                 info = self.isapplied(patch)
                 if info and info[0] >= len(self.applied) - 1:
                     self.ui.warn(


More information about the Mercurial-devel mailing list