jsvn: use re.match() instead of anchored re.search()

This commit is contained in:
Josh Holtrop 2012-02-21 15:48:54 -05:00
parent 1cbd3c2c30
commit 13b1427e11

14
jsvn
View File

@ -89,7 +89,7 @@ def ansi_reset(out):
out.write('\033[0m') out.write('\033[0m')
def colordiff(out, line): def colordiff(out, line):
if re.search(r'^Index:\s', line): if re.match(r'Index:\s', line):
ansi_color(out, 'yellow') ansi_color(out, 'yellow')
out.write(line) out.write(line)
ansi_reset(out) ansi_reset(out)
@ -99,12 +99,12 @@ def colordiff(out, line):
out.write(line) out.write(line)
ansi_reset(out) ansi_reset(out)
return return
if re.search(r'^-', line): if re.match(r'-', line):
ansi_color(out, 'red') ansi_color(out, 'red')
out.write(line) out.write(line)
ansi_reset(out) ansi_reset(out)
return return
elif re.search(r'^\+', line): elif re.match(r'\+', line):
ansi_color(out, 'green') ansi_color(out, 'green')
out.write(line) out.write(line)
ansi_reset(out) ansi_reset(out)
@ -442,7 +442,7 @@ def log(argv, svn, out):
elif mode == 'normal' and re.match(r'Changed.paths:', line): elif mode == 'normal' and re.match(r'Changed.paths:', line):
out.write(line) out.write(line)
mode = 'cp' mode = 'cp'
elif mode == 'cp' and re.search(r'^ [ADM] ', line): elif mode == 'cp' and re.match(r' [ADM] ', line):
action = line[3] action = line[3]
if action == 'A': if action == 'A':
ansi_color(out, 'green') ansi_color(out, 'green')
@ -464,7 +464,7 @@ def log(argv, svn, out):
mode = 'diff' mode = 'diff'
elif mode == 'diff': elif mode == 'diff':
colordiff(out, line) colordiff(out, line)
elif re.search(r'^Index:\s', line): elif re.match(r'Index:\s', line):
ansi_color(out, 'yellow') ansi_color(out, 'yellow')
out.write(line) out.write(line)
ansi_reset(out) ansi_reset(out)
@ -484,11 +484,11 @@ def update(argv, svn, out):
continue continue
if re.match(r'\s*$', line): if re.match(r'\s*$', line):
continue continue
if re.search(r'^External at revision ', line): if re.match(r'External at revision ', line):
if external_printed: if external_printed:
out.write(line) out.write(line)
continue continue
if re.search(r'^(Updated.to|At) revision', line): if re.match(r'(Updated.to|At) revision', line):
out.write(line) out.write(line)
continue continue