Bug 890032 - Apply multiple patches in correct order, r=jdm
authorSteve Fink <sfink@mozilla.com>
Wed, 03 Jul 2013 13:19:53 -0700
changeset 74 37b57ace9b1f
parent 73 6cad4b904ceb
child 75 8d608039123e
push id55
push usersfink@mozilla.com
push dateWed, 03 Jul 2013 21:38:37 +0000
reviewersjdm
bugs890032
Bug 890032 - Apply multiple patches in correct order, r=jdm
__init__.py
bzhandler.py
--- a/__init__.py
+++ b/__init__.py
@@ -195,18 +195,21 @@ def extsetup(ui=None):
     # now process the delayed imports
 
     # these opts are invariant for all patches
     newopts = {}
     newopts.update(opts)
     newopts['force'] = True
 
     # loop through the Patches and import them by calculating their url. The
-    # bz:// handler will have cached the lookup so we don't hit the network here
-    for patch in bzhandler.delayed_imports:
+    # bz:// handler will have cached the lookup so we don't hit the network
+    # here. Each one of these pushes an unapplied patch onto the beginning of
+    # the queue, and unapplied patches are ignored when importing them, so do
+    # these in reverse order.
+    for patch in reversed(list(bzhandler.delayed_imports)):
       newopts['name'] = checkpatchname(patch)
       path = makebzurl(patch.bug.num, patch.id)
 
       orig(ui, repo, path, **newopts)
 
   extensions.wrapcommand(cmdtable, 'qimport', qimporthook)
 
   # Here we setup the protocol handlers
--- a/bzhandler.py
+++ b/bzhandler.py
@@ -104,17 +104,17 @@ class Handler(urllib2.BaseHandler):
             else:
               if int(choice) <= 0:
                 raise IndexError()
               delayed_imports.append(patches[int(choice) - 1])
           except (ValueError, IndexError):
             self.ui.warn("Invalid patch number = '%s'\n" % choice)
             continue
         if not patch and len(delayed_imports) > 0:
-          patch = delayed_imports.pop(0)
+          patch = delayed_imports.pop()
 
     # and finally return the response
     if patch:
       imported_patches.append((patch, req.get_full_url()))
       return PatchResponse(patch)
 
 # interface reverse engineered from urllib.addbase
 class PatchResponse(object):