Remove the reordering side-effect of the latter sync changes
[stgit] / stgit / commands / sync.py
index 944a8c9..35c5c31 100644 (file)
@@ -136,15 +136,14 @@ def func(parser, options, args):
         to_pop = applied[applied.index(first_patch) + 1:]
         if to_pop:
             pop_patches(crt_series, to_pop[::-1])
-        popped = to_pop + [p for p in patches if p in unapplied]
     else:
-        popped = patches
+        to_pop = []
+    popped = to_pop + [p for p in patches if p in unapplied]
 
-    for p in patches:
+    for p in [first_patch] + popped:
         if p in popped:
             # push this patch
             push_patches(crt_series, [p])
-            popped.remove(p)
         if p not in sync_patches:
             # nothing to synchronise
             continue
@@ -171,7 +170,3 @@ def func(parser, options, args):
             out.done('updated')
         else:
             out.done()
-
-    # push the remaining patches
-    if popped:
-        push_patches(crt_series, popped)