Remove --undo flags from stg commands and docs
PATCH 1/1 Remove --undo flags from stg commands and docs
Now that we have "stg undo" et.al., they aren't needed anymore.
---
In this one, I've just removed the --undo flag from sync without adding anything back. Still undetermined if that's OK.
Documentation/tutorial.txt | 4 +++- TODO | 2 -- stgit/commands/goto.py | 3 +-- stgit/commands/pop.py | 2 +- stgit/commands/push.py | 29 +++++----------------------- stgit/commands/rebase.py | 2 +- stgit/commands/repair.py | 9 +++++---- stgit/commands/sync.py | 24 +++-------------------- stgit/stack.py | 45 +------------------------------------------- t/t1200-push-modified.sh | 2 +- t/t1201-pull-trailing.sh | 2 +- t/t1202-push-undo.sh | 8 ++++---- 12 files changed, 26 insertions(+), 106 deletions(-)
Documentation/tutorial.txt +3 -1
@@ -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>
TODO +0 -2
@@ -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
stgit/commands/goto.py +1 -2
@@ -23,8 +23,7 @@ help = 'push or pop patches to the given one' usage = """%prog [options] <name> 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.""" directory = common.DirectoryHasRepositoryLib() options = []
stgit/commands/pop.py +1 -1
@@ -33,7 +33,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).""" directory = DirectoryGotoToplevel(log = True)
stgit/commands/push.py +5 -24
@@ -30,11 +30,11 @@ usage = """%prog [options] [<patch1>] [<patch2>] [<patch3>..<patch4>] 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."""
@@ -50,9 +50,6 @@ options = [make_option('-a', '--all', action = 'store_true'), make_option('-m', '--merged', help = 'check for patches merged upstream', - action = 'store_true'), - make_option('--undo', - help = 'undo the last patch pushing', action = 'store_true')]
@@ -60,22 +57,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)
stgit/commands/rebase.py +1 -1
@@ -38,7 +38,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""" directory = DirectoryGotoToplevel(log = True)
stgit/commands/repair.py +5 -4
@@ -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.
stgit/commands/sync.py +3 -21
@@ -32,9 +32,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.""" directory = DirectoryGotoToplevel(log = True) options = [make_option('-a', '--all',
@@ -43,10 +41,7 @@ options = [make_option('-a', '--all', make_option('-B', '--ref-branch', help = 'syncronise patches with BRANCH'), make_option('-s', '--series', - help = 'syncronise patches with SERIES'), - make_option('--undo', - help = 'undo the synchronisation of the current patch', - action = 'store_true')] + help = 'syncronise patches with SERIES')] def __check_all(): check_local_changes()
@@ -68,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():
@@ -157,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)
stgit/stack.py +1 -44
63 lines not on this page · raw message
t/t1200-push-modified.sh +1 -1
@@ -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 applied))" = "" ] && [ "$(echo $(stg unapplied))" = "p1 p2" ] )
t/t1201-pull-trailing.sh +1 -1
@@ -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 ) "
t/t1202-push-undo.sh +4 -4
@@ -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
2008/7/4 Karl Hasselström <[email protected]>:
Quoted 1 line
Now that we have "stg undo" et.al., they aren't needed anymore.
Great, thanks.
Quoted 2 lines
In this one, I've just removed the --undo flag from sync without adding anything back. Still undetermined if that's OK.
I think it should be ok (see the other thread). Anyway, have you heard of anyone else using sync apart from me?
Signature · 1 line
Catalin
Quoted 7 lines · Catalin Marinas
2008/7/4 Karl Hasselström <[email protected]>:
Quoted 2 lines
In this one, I've just removed the --undo flag from sync without adding anything back. Still undetermined if that's OK.
I think it should be ok (see the other thread). Anyway, have you heard of anyone else using sync apart from me?
No, I haven't.
I've tried to understand what it does, and as far as I can tell it doesn't do quite what I want. (What I want is the ability to 3-way merge StGit patch stacks, so that I can modify the same patch stack in several places and merge back and forth. From what I recall, the sync command is more like a 2-way merge -- that is, it doesn't take the last common ancestor into account. But it's been a while since I studied it.)
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle
2008/7/8 Karl Hasselström <[email protected]>:
Quoted 12 lines · Catalin Marinas
Quoted 8 lines
2008/7/4 Karl Hasselström <[email protected]>:
Quoted 2 lines
In this one, I've just removed the --undo flag from sync without adding anything back. Still undetermined if that's OK.
I think it should be ok (see the other thread). Anyway, have you heard of anyone else using sync apart from me?
No, I haven't.
Quoted 7 lines
I've tried to understand what it does, and as far as I can tell it doesn't do quite what I want. (What I want is the ability to 3-way merge StGit patch stacks, so that I can modify the same patch stack in several places and merge back and forth. From what I recall, the sync command is more like a 2-way merge -- that is, it doesn't take the last common ancestor into account. But it's been a while since I studied it.)
No, the sync command is a 3-way merge between the top of a remote patch, the top of the current patch (current HEAD actually) and the bottom of the remote patch as ancestor. It also has a mode to synchronise with a patch file and it applies the patch onto the bottom of the current patch and does the merging between patch tops afterwards.
This is not ideal as I have to deal with safe conflicts several time (maybe adding git-rerere support would help). If you have better ideas for keeping two stacks in sync, I'm happy to accept them (or maybe just a different workflow).
Signature · 1 line
Catalin
Quoted 23 lines · Catalin Marinas
2008/7/8 Karl Hasselström <[email protected]>:
Quoted 6 lines · Catalin Marinas
Quoted 2 lines
Anyway, have you heard of anyone else using sync apart from me?
No, I haven't.
Quoted 7 lines
I've tried to understand what it does, and as far as I can tell it doesn't do quite what I want. (What I want is the ability to 3-way merge StGit patch stacks, so that I can modify the same patch stack in several places and merge back and forth. From what I recall, the sync command is more like a 2-way merge -- that is, it doesn't take the last common ancestor into account. But it's been a while since I studied it.)
No, the sync command is a 3-way merge between the top of a remote patch, the top of the current patch (current HEAD actually) and the bottom of the remote patch as ancestor. It also has a mode to synchronise with a patch file and it applies the patch onto the bottom of the current patch and does the merging between patch tops afterwards.
Quoted 4 lines
This is not ideal as I have to deal with safe conflicts several time (maybe adding git-rerere support would help). If you have better ideas for keeping two stacks in sync, I'm happy to accept them (or maybe just a different workflow).
Yeah, the actual _tree merging_ is 3-way, but the _patch merging_ is 2-way, since you don't consider the patches' latest common ancestor. So you run into problems much like what you'd get if you tried to apply a patch, change it, then apply it again, etc.
When merging two branches with stack logs, you can find the stack log of the merge base, and use that to 3-way merge the patches.
( To 3-way merge a patch:
1. You have the common ancestor (A), and the two diverged patches (B and C).
2. Push A, B, and C separately onto the same commit. (If there are conflicts at this stage, one probably wants to just ignore them automatically, like merge-recursive does.) Now, A_b == B_b == C_b. (_b is the patch's bottom; _t is its top.)
3. 3-way merge A_t, B_t and C_t to get the new patch top.
4. Commit message etc. can be merged with a standard 3-way merge.
To merge an entire patch stack, first merge the stack bases (with an ordinary 3-way merge, for example), then merge any changes is the patch order, and then merge all the patches one by one.
As I've said before, I haven't actually tried this, so I don't know if it'll work as intended. But it sounds right ... and it works out OK for trivial cases like when the patch is only modified in one branch, or when no patch bottoms are changed by step (2). )
Signature · 2 lines
Karl Hasselström, [email protected] www.treskal.com/kalle