Remove --undo flags from stg commands and docs
authorKarl Hasselström <kha@treskal.com>
Sun, 21 Sep 2008 12:17:42 +0000 (14:17 +0200)
committerKarl Hasselström <kha@treskal.com>
Sun, 21 Sep 2008 12:19:07 +0000 (14:19 +0200)
Now that we have "stg undo" et.al., they aren't needed anymore.

Signed-off-by: Karl Hasselström <kha@treskal.com>
12 files changed:
Documentation/tutorial.txt
TODO
stgit/commands/goto.py
stgit/commands/pop.py
stgit/commands/push.py
stgit/commands/rebase.py
stgit/commands/repair.py
stgit/commands/sync.py
stgit/stack.py
t/t1200-push-modified.sh
t/t1201-pull-trailing.sh
t/t1202-push-undo.sh

index 5d2e50a..472a5c3 100644 (file)
@@ -178,7 +178,9 @@ patches in a stack.
 During a push operation, merge conflicts can occur (especially if you
 are changing the order of the patches in your stack). If the push causes
 merge conflicts, they need to be fixed and 'stg resolved' run (see
-below). A 'push' operation can also be reverted with 'stg push --undo'.
+below). A 'push' operation can also be reverted with 'stg undo' (you
+will need to give it the --hard flag, since the conflicting push will
+have left your work tree dirty).
 A few more stack basics; to rename a patch:
 
   stg rename <old-name> <new-name>
diff --git a/TODO b/TODO
index 884b831..ff52a95 100644 (file)
--- a/TODO
+++ b/TODO
@@ -8,8 +8,6 @@ The TODO list before 1.0:
 - debian package support
 - man page
 - document the workflow on the StGIT wiki
-- maybe a separate undo command rather than passing a --undo option to
-  push and refresh
 - use same configuration file as GIT
 - release 1.0
 
index 2bfef0f..0d4cd29 100644 (file)
@@ -23,8 +23,7 @@ kind = 'stack'
 usage = ['<patch-name>']
 description = """
 Push/pop patches to/from the stack until the one given on the command
-line becomes current. There is no '--undo' option for 'goto'. Use the
-'push --undo' command for this."""
+line becomes current."""
 
 options = []
 
index 1c56671..855dc09 100644 (file)
@@ -32,7 +32,7 @@ not specified).
 
 A series of pop and push operations are performed so that only the
 patches passed on the command line are popped from the stack. Some of
-the push operations may fail because of conflicts (push --undo would
+the push operations may fail because of conflicts ("stg undo" would
 revert the last push operation)."""
 
 options = [
index c3d553d..a7c7578 100644 (file)
@@ -29,11 +29,11 @@ usage = ['[options] [<patch1>] [<patch2>] [<patch3>..<patch4>]']
 description = """
 Push one or more patches (defaulting to the first unapplied one) onto
 the stack. The 'push' operation allows patch reordering by commuting
-them with the three-way merge algorithm. If the result of the 'push'
-operation is not acceptable or if there are too many conflicts, the
-'--undo' option can be used to revert the last pushed patch. Conflicts
-raised during the push operation have to be fixed and the 'resolved'
-command run.
+them with the three-way merge algorithm. If there are conflicts while
+pushing a patch, those conflicts are written to the work tree, and the
+command halts. Conflicts raised during the push operation have to be
+fixed and the 'resolved' command run (alternatively, you may undo the
+conflicting push with 'stg undo').
 
 The command also notifies when the patch becomes empty (fully merged
 upstream) or is modified (three-way merged) by the 'push' operation."""
@@ -46,9 +46,7 @@ options = [
     opt('--reverse', action = 'store_true',
         short = 'Push the patches in reverse order'),
     opt('-m', '--merged', action = 'store_true',
-        short = 'Check for patches merged upstream'),
-    opt('--undo', action = 'store_true',
-        short = 'Undo the last patch pushing')]
+        short = 'Check for patches merged upstream')]
 
 directory = DirectoryGotoToplevel(log = True)
 
@@ -56,22 +54,6 @@ def func(parser, options, args):
     """Pushes the given patch or all onto the series
     """
 
-    # If --undo is passed, do the work and exit
-    if options.undo:
-        patch = crt_series.get_current()
-        if not patch:
-            raise CmdException, 'No patch to undo'
-
-        out.start('Undoing push of "%s"' % patch)
-        resolved_all()
-        if crt_series.undo_push():
-            out.done()
-        else:
-            out.done('patch unchanged')
-        print_crt_patch(crt_series)
-
-        return
-
     check_local_changes()
     check_conflicts()
     check_head_top_equal(crt_series)
index b5a80bb..60168ab 100644 (file)
@@ -37,7 +37,7 @@ the rebase by executing the following sequence:
 
 Or if you want to skip that patch:
 
-        $ stg push --undo
+        $ stg undo --hard
         $ stg push next-patch..top-patch"""
 
 options = [
index e06df3a..ff9bb61 100644 (file)
@@ -34,8 +34,9 @@ as commit, pull, merge, and rebase -- you will leave the StGit
 metadata in an inconsistent state. In that situation, you have two
 options:
 
-  1. Use "git reset" or similar to undo the effect of the git
-     command(s).
+  1. Use "stg undo" to undo the effect of the git commands. (If you
+     know what you are doing and want more control, "git reset" or
+     similar will work too.)
 
   2. Use "stg repair". This will fix up the StGit metadata to
      accomodate the modifications to the branch. Specifically, it will
@@ -48,8 +49,8 @@ options:
        * However, merge commits cannot become patches; if you have
          committed a merge on top of your stack, "repair" will simply
          mark all patches below the merge unapplied, since they are no
-         longer reachable. If this is not what you want, use "git
-         reset" to get rid of the merge and run "stg repair" again.
+         longer reachable. If this is not what you want, use "stg
+         undo" to get rid of the merge and run "stg repair" again.
 
        * The applied patches are supposed to be precisely those that
          are reachable from the branch head. If you have used e.g.
index 26a49f0..966ac55 100644 (file)
@@ -31,9 +31,7 @@ For each of the specified patches perform a three-way merge with the
 same patch in the specified branch or series. The command can be used
 for keeping patches on several branches in sync. Note that the
 operation may fail for some patches because of conflicts. The patches
-in the series must apply cleanly.
-
-The sync operation can be reverted for individual patches with --undo."""
+in the series must apply cleanly."""
 
 options = [
     opt('-a', '--all', action = 'store_true',
@@ -41,9 +39,7 @@ options = [
     opt('-B', '--ref-branch',
         short = 'Syncronise patches with BRANCH'),
     opt('-s', '--series',
-        short = 'Syncronise patches with SERIES'),
-    opt('--undo', action = 'store_true',
-        short = 'Undo the synchronisation of the current patch')]
+        short = 'Syncronise patches with SERIES')]
 
 directory = DirectoryGotoToplevel(log = True)
 
@@ -67,18 +63,6 @@ def __series_merge_patch(base, patchdir, pname):
 def func(parser, options, args):
     """Synchronise a range of patches
     """
-    if options.undo:
-        if options.ref_branch or options.series:
-            raise CmdException, \
-                  '--undo cannot be specified with --ref-branch or --series'
-        __check_all()
-
-        out.start('Undoing the sync of "%s"' % crt_series.get_current())
-        crt_series.undo_refresh()
-        git.reset()
-        out.done()
-        return
-
     if options.ref_branch:
         remote_series = stack.Series(options.ref_branch)
         if options.ref_branch == crt_series.get_name():
@@ -156,8 +140,7 @@ def func(parser, options, args):
         bottom = patch.get_bottom()
         top = patch.get_top()
 
-        # reset the patch backup information. That's needed in case we
-        # undo the sync but there were no changes made
+        # reset the patch backup information.
         patch.set_top(top, backup = True)
 
         # the actual merging (either from a branch or an external file)
index 74c2c10..9958e7a 100644 (file)
@@ -740,26 +740,6 @@ class Series(PatchSet):
 
         return commit_id
 
-    def undo_refresh(self):
-        """Undo the patch boundaries changes caused by 'refresh'
-        """
-        name = self.get_current()
-        assert(name)
-
-        patch = self.get_patch(name)
-        old_bottom = patch.get_old_bottom()
-        old_top = patch.get_old_top()
-
-        # the bottom of the patch is not changed by refresh. If the
-        # old_bottom is different, there wasn't any previous 'refresh'
-        # command (probably only a 'push')
-        if old_bottom != patch.get_bottom() or old_top == patch.get_top():
-            raise StackException, 'No undo information available'
-
-        git.reset(tree_id = old_top, check_out = False)
-        if patch.restore_old_boundaries():
-            self.log_patch(patch, 'undo')
-
     def new_patch(self, name, message = None, can_edit = True,
                   unapplied = False, show_patch = False,
                   top = None, bottom = None, commit = True,
@@ -1019,7 +999,7 @@ class Series(PatchSet):
                 git.merge_recursive(bottom, head, top)
             except git.GitException, ex:
                 out.error('The merge failed during "push".',
-                          'Revert the operation with "push --undo".')
+                          'Revert the operation with "stg undo".')
 
         append_string(self.__applied_file, name)
 
@@ -1043,29 +1023,6 @@ class Series(PatchSet):
 
         return modified
 
-    def undo_push(self):
-        name = self.get_current()
-        assert(name)
-
-        patch = self.get_patch(name)
-        old_bottom = patch.get_old_bottom()
-        old_top = patch.get_old_top()
-
-        # the top of the patch is changed by a push operation only
-        # together with the bottom (otherwise the top was probably
-        # modified by 'refresh'). If they are both unchanged, there
-        # was a fast forward
-        if old_bottom == patch.get_bottom() and old_top != patch.get_top():
-            raise StackException, 'No undo information available'
-
-        git.reset()
-        self.pop_patch(name)
-        ret = patch.restore_old_boundaries()
-        if ret:
-            self.log_patch(patch, 'undo')
-
-        return ret
-
     def pop_patch(self, name, keep = False):
         """Pops the top patch from the stack
         """
index 35c9bdd..a591124 100755 (executable)
@@ -56,7 +56,7 @@ test_expect_success \
 test_expect_success \
     'Rollback the push' '
     (
-        cd bar && stg push --undo &&
+        cd bar && stg undo --hard &&
         [ "$(echo $(stg series --applied --noprefix))" = "" ] &&
         [ "$(echo $(stg series --unapplied --noprefix))" = "p1 p2" ]
     )
index 3a7efc1..d66ad26 100755 (executable)
@@ -49,7 +49,7 @@ test_expect_success \
 
 test_expect_success \
     'Pull those patches applied upstream' \
-    "(cd bar && stg push --undo && stg push --all --merged
+    "(cd bar && stg undo && stg push --all --merged
      )
 "
 
index 544fe8d..79439de 100755 (executable)
@@ -3,10 +3,10 @@
 # Copyright (c) 2006 Catalin Marinas
 #
 
-test_description='Exercise push --undo with missing files.
+test_description='Exercise stg undo with push of missing files.
 
 Test the case where a patch fails to be pushed because it modifies a
-missing file. The "push --undo" command has to be able to revert it.
+missing file. The "stg undo" command has to be able to revert it.
 '
 
 . ./test-lib.sh
@@ -49,7 +49,7 @@ test_expect_success \
 test_expect_success \
        'Undo the previous push' \
        '
-       stg push --undo
+       stg undo --hard
        '
 
 test_expect_success \
@@ -64,7 +64,7 @@ test_expect_success \
        touch newfile &&
        git add newfile &&
        rm newfile &&
-       stg push --undo
+       stg undo --hard
        '
 
 test_done