chiark / gitweb /
Allow the synchronisation of the unapplied patches
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 20 Mar 2008 23:12:33 +0000 (23:12 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 20 Mar 2008 23:12:33 +0000 (23:12 +0000)
This is useful to avoid pushing patches when a sync operation failed
and needs to be resumed.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/sync.py

index 660ee4121f7b2b5b0fac44a17d77fa0e7768b4df..e0c8c7de48f2786722d6d2b089bd385b6a953691 100644 (file)
@@ -38,7 +38,7 @@ The sync operation can be reverted for individual patches with --undo."""
 
 directory = DirectoryGotoToplevel()
 options = [make_option('-a', '--all',
-                       help = 'synchronise all the patches',
+                       help = 'synchronise all the applied patches',
                        action = 'store_true'),
            make_option('-B', '--ref-branch',
                        help = 'syncronise patches with BRANCH'),
@@ -112,7 +112,9 @@ def func(parser, options, args):
     if options.all:
         patches = applied
     elif len(args) != 0:
-        patches = parse_patches(args, applied, ordered = True)
+        unapplied = crt_series.get_unapplied()
+        patches = parse_patches(args, applied + unapplied, len(applied),
+                                ordered = True)
     elif applied:
         patches = [crt_series.get_current()]
     else:
@@ -129,16 +131,22 @@ def func(parser, options, args):
         raise CmdException, 'No common patches to be synchronised'
 
     # pop to the one before the first patch to be synchronised
-    popped = applied[applied.index(sync_patches[0]) + 1:]
-    if popped:
-        pop_patches(crt_series, popped[::-1])
+    first_patch = sync_patches[0]
+    if first_patch in applied:
+        to_pop = applied[applied.index(first_patch) + 1:]
+        if to_pop:
+            pop_patches(crt_series, to_pop[::-1])
+        popped = patches[patches.index(first_patch) + 1:]
+    else:
+        popped = patches
 
-    for p in sync_patches:
+    for p in patches:
         if p in popped:
-            # push to this patch
-            idx = popped.index(p) + 1
-            push_patches(crt_series, popped[:idx])
-            del popped[:idx]
+            # push this patch
+            push_patches(crt_series, [p])
+        if p not in sync_patches:
+            # nothing to synchronise
+            continue
 
         # the actual sync
         out.start('Synchronising "%s"' % p)
@@ -163,7 +171,3 @@ def func(parser, options, args):
             out.done('updated')
         else:
             out.done()
-
-    # push the remaining patches
-    if popped:
-        push_patches(crt_series, popped)