Add the '--undo' option to 'refresh'
[stgit] / stgit / commands / refresh.py
index c5f390f..306e7b3 100644 (file)
@@ -47,6 +47,9 @@ options = [make_option('-f', '--force',
            make_option('-s', '--showpatch',
                        help = 'show the patch content in the editor buffer',
                        action = 'store_true'),
+           make_option('--undo',
+                       help = 'revert the commit generated by the last refresh',
+                       action = 'store_true'),
            make_option('-m', '--message',
                        help = 'use MESSAGE as the patch ' \
                        'description'),
@@ -78,6 +81,13 @@ def func(parser, options, args):
     if not options.force:
         check_head_top_equal()
 
+    if options.undo:
+        print 'Undoing the "%s" refresh...' % patch,
+        sys.stdout.flush()
+        crt_series.undo_refresh()
+        print 'done'
+        return
+
     if options.author:
         options.authname, options.authemail = name_email(options.author)
 
@@ -99,7 +109,8 @@ def func(parser, options, args):
                                  author_email = options.authemail,
                                  author_date = options.authdate,
                                  committer_name = options.commname,
-                                 committer_email = options.commemail)
+                                 committer_email = options.commemail,
+                                 backup = True)
 
         print 'done'
     else: