This option allows popping patches without affecting the working directory.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
-def pop_patches(patches):
+def pop_patches(patches, keep = False):
"""Pop the patches in the list from the stack. It is assumed that
the patches are listed in the stack reverse order.
"""
"""Pop the patches in the list from the stack. It is assumed that
the patches are listed in the stack reverse order.
"""
print 'Popping "%s" - "%s" patches...' % (patches[0], p),
sys.stdout.flush()
print 'Popping "%s" - "%s" patches...' % (patches[0], p),
sys.stdout.flush()
- crt_series.pop_patch(p)
+ crt_series.pop_patch(p, keep)
help = 'pop all the applied patches',
action = 'store_true'),
make_option('-n', '--number', type = 'int',
help = 'pop all the applied patches',
action = 'store_true'),
make_option('-n', '--number', type = 'int',
- help = 'pop the specified number of patches')]
+ help = 'pop the specified number of patches'),
+ make_option('--keep',
+ help = 'keep the current working directory',
+ action = 'store_true')]
def func(parser, options, args):
def func(parser, options, args):
if len(args) > 1:
parser.error('incorrect number of arguments')
if len(args) > 1:
parser.error('incorrect number of arguments')
- check_local_changes()
- 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:
applied = crt_series.get_applied()
if not applied:
if patches == []:
raise CmdException, 'No patches to pop'
if patches == []:
raise CmdException, 'No patches to pop'
+ pop_patches(patches, options.keep)
if __run(checkout_cmd, files) != 0:
raise GitException, 'Failed git-checkout-index'
if __run(checkout_cmd, files) != 0:
raise GitException, 'Failed git-checkout-index'
+def switch(tree_id, keep = False):
"""Switch the tree to the given id
"""
"""Switch the tree to the given id
"""
- refresh_index()
- if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0:
- raise GitException, 'git-read-tree failed (local changes maybe?)'
+ if not keep:
+ refresh_index()
+ if __run('git-read-tree -u -m', [get_head(), tree_id]) != 0:
+ raise GitException, 'git-read-tree failed (local changes maybe?)'
self.pop_patch(name)
return patch.restore_old_boundaries()
self.pop_patch(name)
return patch.restore_old_boundaries()
- def pop_patch(self, name):
+ def pop_patch(self, name, keep = False):
"""Pops the top patch from the stack
"""
applied = self.get_applied()
"""Pops the top patch from the stack
"""
applied = self.get_applied()
patch = Patch(name, self.__patch_dir, self.__refs_dir)
patch = Patch(name, self.__patch_dir, self.__refs_dir)
- git.switch(patch.get_bottom())
+ git.switch(patch.get_bottom(), keep)
# save the new applied list
idx = applied.index(name) + 1
# save the new applied list
idx = applied.index(name) + 1