From e45af3d4a0faa3f7c46a0a2a9647ad09f1ba8720 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Tue, 17 Oct 2006 19:37:26 +0100 Subject: [PATCH] Fix the preserving of the local changes during pop The operation now only preserves the local changes by reverse-applying the diff of the popped patches. Signed-off-by: Catalin Marinas --- stgit/commands/pop.py | 9 +++++---- stgit/stack.py | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/stgit/commands/pop.py b/stgit/commands/pop.py index 7c260a6..645eebd 100644 --- a/stgit/commands/pop.py +++ b/stgit/commands/pop.py @@ -37,8 +37,8 @@ options = [make_option('-a', '--all', action = 'store_true'), make_option('-n', '--number', type = 'int', help = 'pop the specified number of patches'), - make_option('--keep', - help = 'keep the current working directory', + make_option('-k', '--keep', + help = 'keep the local changes', action = 'store_true')] @@ -48,10 +48,11 @@ def func(parser, options, args): if len(args) > 1: parser.error('incorrect number of arguments') + check_conflicts() + check_head_top_equal() + if not options.keep: check_local_changes() - check_conflicts() - check_head_top_equal() applied = crt_series.get_applied() if not applied: diff --git a/stgit/stack.py b/stgit/stack.py index 26a2fc5..93a3d4e 100644 --- a/stgit/stack.py +++ b/stgit/stack.py @@ -975,6 +975,11 @@ class Series: patch = Patch(name, self.__patch_dir, self.__refs_dir) + # only keep the local changes + if keep and not git.apply_diff(git.get_head(), patch.get_bottom()): + raise StackException, \ + 'Failed to pop patches while preserving the local changes' + git.switch(patch.get_bottom(), keep) # save the new applied list -- 2.11.0