From 5f4a4c5a9690073319844ccd7b900b857fbb5eee Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 7 Apr 2012 16:54:34 -0400 Subject: [PATCH] stash: abort creating stash file if changes to binary files are present --- jsvn | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/jsvn b/jsvn index 67bc372..dd1f91b 100755 --- a/jsvn +++ b/jsvn @@ -814,18 +814,24 @@ def stash(argv, svn, out): fh = open(stash_fname, 'w') proc = Popen([svn, 'diff'], stdout=PIPE) wrote_something = False + found_binary_file = False for line in iter(proc.stdout.readline, ''): - if len(line) > 0: - wrote_something = True + if re.match(r'Cannot.display..file.marked.as.a.binary.type', + line, flags=re.I): + found_binary_file = True fh.write(line) + wrote_something = True proc.wait() fh.close() - if wrote_something: + if found_binary_file: + out.write('Error: cannot stash with changes to binary files\n') + os.unlink(stash_fname) + elif wrote_something: Popen([svn, 'revert', '--depth=infinity', '.'], stdout=PIPE).wait() out.write('Created stash %d\n' % stash_idx) else: - out.write('Nothing to stash!\n') + out.write('Error: no changes to stash!\n') os.unlink(stash_fname) os.chdir(owd) elif action == 'list':