Bug 848342 - Rename the correct patch, r=edmorley
authorSteve Fink <sfink@mozilla.com>
Thu, 05 Sep 2013 09:49:39 -0700
changeset 76 db8bbbde5cbb
parent 75 8d608039123e
child 77 9fec7d31e8d5
push id57
push usersfink@mozilla.com
push date2013-09-05 16:50 +0000
reviewersedmorley
bugs848342
Bug 848342 - Rename the correct patch, r=edmorley
__init__.py
--- a/__init__.py
+++ b/__init__.py
@@ -149,23 +149,16 @@ def extsetup(ui=None):
     # and that's OK.
     if opts['preview']:
       extensions.wrapfunction(url, "open", previewopen)
 
     # mercurial's url.search_re includes the // and that doesn't match what we
     # want which is bz:dddddd(/ddddd)?
     files = map(fixuppath, files)
 
-    # Remember where the next patch will be inserted into the series
-    try:
-      # hg 1.9+
-      insert = q.fullseriesend()
-    except:
-      insert = q.full_series_end()
-
     # Do the import as normal. The first patch of any bug is actually imported
     # and the rest are stored in the global delayed_imports. The imported
     # patches have dumb filenames because there's no way to tell mq to pick the
     # patch name *after* download.
     ret = orig(ui, repo, *files, **opts)
     if ret:
       return ret
 
@@ -173,23 +166,21 @@ def extsetup(ui=None):
     if not opts['name']:
       # cache the lookup of the name. findcmd is not fast.
       qrename = cmdutil.findcmd("qrename", commands.table)[1][0]
 
       # For all the already imported patches, rename them. Except there will
       # only be one, since if the url resolves to multiple patches then
       # everything but the first will go into bzhandler.delayed_imports.
       for (patch, path) in list(bzhandler.imported_patches):
-        # Find where qimport will have inserted the initial patch
         try:
           # hg 1.9+
-          oldpatchname = q.fullseries[insert]
+          oldpatchname = q.fullseries[q.fullseriesend()]
         except:
-          oldpatchname = q.full_series[insert]
-        insert += 1
+          oldpatchname = q.full_series[q.full_series_end()]
         newpatchname = checkpatchname(patch)
         if newpatchname != oldpatchname:
           qrename(ui, repo, oldpatchname, newpatchname)
           # mq always reports the original name, which is confusing so we'll
           # report the rename. But if ui.verbose is on, qrename will have
           # already reported it.
           if not ui.verbose:
             ui.write("renamed %s -> %s\n" % (oldpatchname, newpatchname))