From c5e7f25f40ce71358d0aa7242b0dd12029615001 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 23 Feb 2012 11:07:47 -0500 Subject: [PATCH] jsvn: add "externals" subcommand --- jsvn | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jsvn b/jsvn index 9b65726..662c6cb 100755 --- a/jsvn +++ b/jsvn @@ -41,6 +41,8 @@ # - with no switches, set svn:needs-lock to '*' for file[s] # - with --remove, remove svn:needs-lock' for file[s] # - with --status, prepended '*' for those with svn:needs-lock set +# externals +# - print a list of the externals in the repository # # The following subcommands are executed using their native handler, but # have their output simplified and/or colorized: @@ -59,6 +61,7 @@ import re import time from subprocess import * +STATUS_LINE_REGEX = r'[ACDIMRX?!~ ][CM ][L ][+ ][SX ][KOTB ]' ########################################################################### # Subcommand Handler Return Values # ########################################################################### @@ -558,7 +561,7 @@ def status(argv, svn, out): if not external_printed: out.write("\nExternal '%s':\n" % external) external_printed = True - if re.match(r'[ACDIMRX?!~ ][CM ][L ][+ ][SX ][KOTB ]', line): + if re.match(STATUS_LINE_REGEX, line): action = line[0] if action == 'A' or action == 'M': ansi_color(out, 'green') @@ -576,6 +579,14 @@ def status(argv, svn, out): out.write(line) return RET_OK +def externals(argv, svn, out): + pout = Popen([svn, 'status'], stdout=PIPE).stdout + for line in iter(pout.readline, ''): + if re.match(STATUS_LINE_REGEX, line): + if line[0] == 'X': + out.write(line[8:]) + return RET_OK + def root(argv, svn, out): out.write(getSVNRoot(svn) + '\n') return RET_OK @@ -613,6 +624,7 @@ def main(argv): handlers = { 'branch': branch, 'branches': branch, + 'externals': externals, 'switch': switch, 'sw': switch, 'merge': merge,