jsvn: add "update" subcommand handler for colorized output
This commit is contained in:
parent
e49bbb212e
commit
1cbd3c2c30
44
jsvn
44
jsvn
@ -472,6 +472,46 @@ def log(argv, svn, out):
|
||||
out.write(line)
|
||||
return RET_OK
|
||||
|
||||
def update(argv, svn, out):
|
||||
external = ''
|
||||
external_printed = True
|
||||
pout = Popen([svn] + argv, stdout=PIPE).stdout
|
||||
for line in iter(pout.readline, ''):
|
||||
m = re.match(r"Fetching external item into '(.*)':", line)
|
||||
if m is not None:
|
||||
external = m.group(1)
|
||||
external_printed = False
|
||||
continue
|
||||
if re.match(r'\s*$', line):
|
||||
continue
|
||||
if re.search(r'^External at revision ', line):
|
||||
if external_printed:
|
||||
out.write(line)
|
||||
continue
|
||||
if re.search(r'^(Updated.to|At) revision', line):
|
||||
out.write(line)
|
||||
continue
|
||||
|
||||
# anything not matched yet will cause an external to be shown
|
||||
if not external_printed:
|
||||
out.write("\nExternal '%s':\n" % external)
|
||||
external_printed = True
|
||||
if re.match(r'[ADUCGER ]{2}[B ][C ] ', line):
|
||||
action = line[0]
|
||||
if action == 'A':
|
||||
ansi_color(out, 'green')
|
||||
elif action == 'D':
|
||||
ansi_color(out, 'red')
|
||||
elif action == 'C':
|
||||
ansi_color(out, 'yellow')
|
||||
elif action == 'G':
|
||||
ansi_color(out, 'cyan')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
continue
|
||||
out.write(line)
|
||||
return RET_OK
|
||||
|
||||
def root(argv, svn, out):
|
||||
sys.stdout.write(getSVNRoot(svn) + '\n')
|
||||
return RET_OK
|
||||
@ -513,6 +553,8 @@ def main(argv):
|
||||
'diff': diff,
|
||||
'log': log,
|
||||
'root': root,
|
||||
'up': update,
|
||||
'update': update,
|
||||
'watch-lock': watch_lock,
|
||||
'users': users,
|
||||
'binaries': binaries,
|
||||
@ -526,7 +568,7 @@ def main(argv):
|
||||
if r == RET_OK or r == RET_ERR:
|
||||
do_normal_exec = False
|
||||
|
||||
if (argv[0] in ('st', 'status', 'up', 'update')
|
||||
if (argv[0] in ('st', 'status')
|
||||
and colorsvn != ''):
|
||||
realsvn = colorsvn
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user