add "revert" subcommand handler
This commit is contained in:
parent
adeabcec6b
commit
cc95b79447
2
README
2
README
@ -52,6 +52,8 @@ Implemented subcommands:
|
|||||||
merge <branch>
|
merge <branch>
|
||||||
- merge branch <branch> into the current WC path
|
- merge branch <branch> into the current WC path
|
||||||
- falls back to Subversion "merge" if <branch> doesn't exist
|
- falls back to Subversion "merge" if <branch> doesn't exist
|
||||||
|
revert <path[s]>
|
||||||
|
- revert all affected files under given target path(s)
|
||||||
root
|
root
|
||||||
- output root URL (for use on shell such as "svn log $(svn root)/tags")
|
- output root URL (for use on shell such as "svn log $(svn root)/tags")
|
||||||
stash [command]
|
stash [command]
|
||||||
|
28
jsvn
28
jsvn
@ -1196,6 +1196,33 @@ def externals_h(argv, svn, out, config):
|
|||||||
out.write(line[8:])
|
out.write(line[8:])
|
||||||
return RET_OK
|
return RET_OK
|
||||||
|
|
||||||
|
def revert_h(argv, svn, out, config):
|
||||||
|
argv = argv[1:] # strip off command
|
||||||
|
if len(argv) == 0:
|
||||||
|
# do not handle if no targets are passed
|
||||||
|
return RET_REEXEC
|
||||||
|
if len(filter(lambda x: x.startswith('-'), argv)) != 0:
|
||||||
|
# do not handle if any options are passed
|
||||||
|
Popen([svn, 'revert'] + argv).wait()
|
||||||
|
return RET_OK
|
||||||
|
did_something = False
|
||||||
|
p = Popen([svn, 'status'], stdout=PIPE)
|
||||||
|
for i, target in enumerate(argv):
|
||||||
|
if target.endswith('/'):
|
||||||
|
argv[i] = target[:-1]
|
||||||
|
for line in iter(p.stdout.readline, ''):
|
||||||
|
m = re.match(STATUS_LINE_REGEX, line)
|
||||||
|
if m is not None:
|
||||||
|
action = line[0]
|
||||||
|
if action in ('A', 'M', 'D'):
|
||||||
|
fname = m.group(1)
|
||||||
|
for target in argv:
|
||||||
|
if target == '.' or target == fname or fname.startswith(target + '/'):
|
||||||
|
Popen([svn, 'revert', fname]).wait()
|
||||||
|
did_something = True
|
||||||
|
break
|
||||||
|
return RET_OK if did_something else RET_REEXEC
|
||||||
|
|
||||||
def stash_h(argv, svn, out, config):
|
def stash_h(argv, svn, out, config):
|
||||||
argv = argv[1:] # strip 'stash' command
|
argv = argv[1:] # strip 'stash' command
|
||||||
action = 'save'
|
action = 'save'
|
||||||
@ -1528,6 +1555,7 @@ def do_cmd(argv, realsvn, config, expand=True):
|
|||||||
'lockable': lockable_h,
|
'lockable': lockable_h,
|
||||||
'status': status_h,
|
'status': status_h,
|
||||||
'stash': stash_h,
|
'stash': stash_h,
|
||||||
|
'revert': revert_h,
|
||||||
}
|
}
|
||||||
|
|
||||||
do_native_exec = True
|
do_native_exec = True
|
||||||
|
Loading…
x
Reference in New Issue
Block a user