Now that we have "stg undo" et.al., they aren't needed anymore.
Signed-off-by: Karl Hasselström <kha@treskal.com>
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>
- 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
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 = []
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 = [
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."""
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)
"""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)
Or if you want to skip that patch:
- $ stg push --undo
+ $ stg undo --hard
$ stg push next-patch..top-patch"""
options = [
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
* 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.
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',
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)
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():
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)
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,
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)
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
"""
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" ]
)
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
)
"
# 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
test_expect_success \
'Undo the previous push' \
'
- stg push --undo
+ stg undo --hard
'
test_expect_success \
touch newfile &&
git add newfile &&
rm newfile &&
- stg push --undo
+ stg undo --hard
'
test_done