Make 'push --undo' safer
authorCatalin Marinas <catalin.marinas@gmail.com>
Thu, 7 Dec 2006 22:02:42 +0000 (22:02 +0000)
committerCatalin Marinas <catalin.marinas@gmail.com>
Thu, 7 Dec 2006 22:02:42 +0000 (22:02 +0000)
Make the push undoing a bit safer by asking the user to first clean
the local changes or conflicts rather than silently resetting them.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/push.py
t/t1200-push-modified.sh
t/t1202-push-undo.sh

index a636ad2..b6e24d9 100644 (file)
@@ -57,6 +57,9 @@ options = [make_option('-a', '--all',
 def func(parser, options, args):
     """Pushes the given patch or all onto the series
     """
 def func(parser, options, args):
     """Pushes the given patch or all onto the series
     """
+    check_conflicts()
+    check_local_changes()
+    check_head_top_equal()
 
     # If --undo is passed, do the work and exit
     if options.undo:
 
     # If --undo is passed, do the work and exit
     if options.undo:
@@ -66,7 +69,6 @@ def func(parser, options, args):
 
         print 'Undoing the "%s" push...' % patch,
         sys.stdout.flush()
 
         print 'Undoing the "%s" push...' % patch,
         sys.stdout.flush()
-        resolved_all()
         if crt_series.undo_push():
             print 'done'
         else:
         if crt_series.undo_push():
             print 'done'
         else:
@@ -75,10 +77,6 @@ def func(parser, options, args):
 
         return
 
 
         return
 
-    check_local_changes()
-    check_conflicts()
-    check_head_top_equal()
-
     unapplied = crt_series.get_unapplied()
     if not unapplied:
         raise CmdException, 'No more patches to push'
     unapplied = crt_series.get_unapplied()
     if not unapplied:
         raise CmdException, 'No more patches to push'
index 7847a38..433e452 100755 (executable)
@@ -51,7 +51,7 @@ test_expect_failure \
 
 test_expect_success \
     'Rollback the push' \
 
 test_expect_success \
     'Rollback the push' \
-    "(cd bar && stg push --undo
+    "(cd bar && stg status --reset && stg push --undo
      )
 "
 
      )
 "
 
index 335b554..45dabb4 100755 (executable)
@@ -49,6 +49,7 @@ test_expect_failure \
 test_expect_success \
        'Undo the previous push' \
        '
 test_expect_success \
        'Undo the previous push' \
        '
+       stg status --reset &&
        stg push --undo
        '
 
        stg push --undo
        '