Changed sync not to use -b which has other semantics.
[stgit] / stgit / commands / sync.py
index 594d7de..2ec7427 100644 (file)
@@ -38,7 +38,7 @@ The sync operation can be reverted for individual patches with --undo."""
 options = [make_option('-a', '--all',
                        help = 'synchronise all the patches',
                        action = 'store_true'),
-           make_option('-b', '--branch',
+           make_option('-B', '--ref-branch',
                        help = 'syncronise patches with BRANCH'),
            make_option('-s', '--series',
                        help = 'syncronise patches with SERIES'),
@@ -69,26 +69,22 @@ def func(parser, options, args):
     global crt_series
 
     if options.undo:
-        if options.branch or options.series:
+        if options.ref_branch or options.series:
             raise CmdException, \
-                  '--undo cannot be specified with --branch or --series'
+                  '--undo cannot be specified with --ref-branch or --series'
         __check_all()
 
-        print 'Undoing the "%s" sync...' % crt_series.get_current(),
-        sys.stdout.flush()
-
+        out.start('Undoing the sync of "%s"' % crt_series.get_current())
         crt_series.undo_refresh()
         git.reset()
-
-        print 'done'
+        out.done()
         return
 
-    if options.branch:
+    if options.ref_branch:
         # the main function already made crt_series to be the remote
         # branch
-        remote_series = crt_series
-        stgit.commands.common.crt_series = crt_series = stack.Series()
-        if options.branch == crt_series.get_branch():
+        remote_series = stack.Series(options.ref_branch)
+        if options.ref_branch == crt_series.get_name():
             raise CmdException, 'Cannot synchronise with the current branch'
         remote_patches = remote_series.get_applied()
 
@@ -119,8 +115,10 @@ def func(parser, options, args):
         patches = applied
     elif len(args) != 0:
         patches = parse_patches(args, applied, ordered = True)
+    elif applied:
+        patches = [crt_series.get_current()]
     else:
-        parser.error('no patches specified')
+        parser.error('no patches applied')
 
     if not patches:
         raise CmdException, 'No patches to synchronise'
@@ -145,8 +143,7 @@ def func(parser, options, args):
             del popped[:idx]
 
         # the actual sync
-        print 'Synchronising "%s"...' % p,
-        sys.stdout.flush()
+        out.start('Synchronising "%s"' % p)
 
         patch = crt_series.get_patch(p)
         bottom = patch.get_bottom()
@@ -165,9 +162,9 @@ def func(parser, options, args):
             # backup information was already reset above
             crt_series.refresh_patch(cache_update = False, backup = False,
                                      log = 'sync')
-            print 'done (updated)'
+            out.done('updated')
         else:
-            print 'done'
+            out.done()
 
     # push the remaining patches
     if popped: