From c43a3bd5e953c3a2aa78223dbbaefbab3abf8d77 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 27 Jun 2012 09:16:42 -0400 Subject: [PATCH] add -k to stash pop to allow keeping stash object - close #13 --- README | 4 ++-- jsvn | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README b/README index 750d48b..312a812 100644 --- a/README +++ b/README @@ -67,9 +67,9 @@ Implemented subcommands: - this only works with text files, not binary files list: - show a list of all stash objects - pop [id]: + pop [-k] [id]: - apply the stash object back to the working copy - - the stash object is removed if it was successfully applied + - the stash object is removed unless -k (keep) given - defaults to the newest stash object created show [id]: - display the diff stored in stash with ID diff --git a/jsvn b/jsvn index 6d44d38..39c1f98 100755 --- a/jsvn +++ b/jsvn @@ -964,20 +964,26 @@ def stash(argv, svn, out): out.write(')') out.write('\n') elif action == 'pop': + keep = False + options, args = getopt.getopt(argv, 'k') + for opt, val in options: + if opt == '-k': + keep = True owd = os.getcwd() wc_dir = get_svn_wc_root(svn) os.chdir(wc_dir) stash_ids = get_stash_ids(svn) if len(stash_ids) > 0: stash_idx = stash_ids[-1] - if len(argv) >= 1: - stash_idx = int(argv[0]) + if len(args) >= 1: + stash_idx = int(args[0]) stash_fname = get_stash_fname(svn, stash_idx) p = Popen([svn, 'patch', stash_fname], stdout=PIPE) filter_update(p.stdout, out) rc = p.wait() if rc == 0: - os.unlink(stash_fname) + if not keep: + os.unlink(stash_fname) out.write('Popped stash %d\n' % stash_idx) else: out.write('Error popping stash %d\n' % stash_idx)