revert bugfix: revert deleted items in order by status but added/modified items in reverse order

This commit is contained in:
Josh Holtrop 2013-10-24 10:30:52 -04:00
parent efdad72708
commit 4fa19ce27a

23
jsvn
View File

@ -1232,23 +1232,26 @@ def revert_h(argv, svn, out, config):
if target.endswith('/'): if target.endswith('/'):
argv[i] = target[:-1] argv[i] = target[:-1]
p = Popen([svn, 'status'], stdout=PIPE) p = Popen([svn, 'status'], stdout=PIPE)
status_lines = [] modified_files = []
for line in iter(p.stdout.readline, ''): for line in iter(p.stdout.readline, ''):
status_lines.append(line)
for line in reversed(status_lines):
m = re.match(STATUS_LINE_REGEX, line) m = re.match(STATUS_LINE_REGEX, line)
if m is not None: if m is not None:
action = line[0] action = line[0]
prop_action = line[1] prop_action = line[1]
if action in ('A', 'M', 'D', '!') or prop_action == 'M': if action in ('A', 'M', 'D', '!') or prop_action == 'M':
fname = m.group(1) fname = m.group(1)
for target in argv: if action in ('D', '!'):
if fname.startswith(os.getcwd() + os.sep): modified_files.append(fname)
fname = fname[len(os.getcwd() + os.sep):] else:
if target == '.' or target == fname or fname.startswith(target + os.sep): modified_files.insert(0, fname)
Popen([svn, 'revert', fname]).wait() for fname in modified_files:
did_something = True for target in argv:
break if fname.startswith(os.getcwd() + os.sep):
fname = fname[len(os.getcwd() + os.sep):]
if target == '.' or target == fname or fname.startswith(target + os.sep):
Popen([svn, 'revert', fname]).wait()
did_something = True
break
return RET_OK if did_something else RET_REEXEC return RET_OK if did_something else RET_REEXEC
def get_svn_contents_to_stash(targets, svn, out, keep, patch, externals): def get_svn_contents_to_stash(targets, svn, out, keep, patch, externals):