remove trailing blank line on colorized output piped to less
This commit is contained in:
parent
ae0b02ea02
commit
2b2589369f
24
jsvn
24
jsvn
@ -231,25 +231,30 @@ def ansi_reset(out):
|
||||
out.write('\033[0m')
|
||||
|
||||
def colordiff(out, line):
|
||||
line = line.strip()
|
||||
if re.match(r'Index:\s', line):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
return
|
||||
if re.match(r'={67}', line):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
return
|
||||
if re.match(r'-', line):
|
||||
ansi_color(out, 'red')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
return
|
||||
elif re.match(r'\+', line):
|
||||
ansi_color(out, 'green')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
return
|
||||
m = re.match(r'(@@.*@@)(.*)', line)
|
||||
if m is None:
|
||||
@ -262,6 +267,7 @@ def colordiff(out, line):
|
||||
out.write('\n')
|
||||
return
|
||||
out.write(line)
|
||||
out.write('\n')
|
||||
|
||||
def findInPath(cmd):
|
||||
path_entries = os.environ['PATH'].split(os.pathsep)
|
||||
@ -377,8 +383,9 @@ def filter_update(pout, out):
|
||||
ansi_color(out, 'yellow')
|
||||
elif action == 'G':
|
||||
ansi_color(out, 'magenta')
|
||||
out.write(line)
|
||||
out.write(line.strip())
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
continue
|
||||
out.write(line)
|
||||
|
||||
@ -473,9 +480,10 @@ def branch(argv, svn, out):
|
||||
ansi_color(out, 'green')
|
||||
else:
|
||||
out.write(' ')
|
||||
out.write(b + '\n')
|
||||
out.write(b)
|
||||
if b == current:
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
return RET_OK
|
||||
branch_name = argv[-1]
|
||||
if len(argv) >= 3 and argv[1] == "-d":
|
||||
@ -702,6 +710,7 @@ def log(argv, svn, out):
|
||||
mode = 'normal'
|
||||
pout = Popen([svn] + argv, stdout=PIPE).stdout
|
||||
for line in iter(pout.readline, ''):
|
||||
line = line.strip()
|
||||
if mode == 'normal' and re.match(r'(r\d+)\s+\|', line):
|
||||
parts = line.split('|')
|
||||
if len(parts) == 4:
|
||||
@ -718,10 +727,13 @@ def log(argv, svn, out):
|
||||
ansi_reset(out)
|
||||
out.write('|')
|
||||
out.write(parts[3])
|
||||
out.write('\n')
|
||||
else:
|
||||
out.write(line)
|
||||
out.write('\n')
|
||||
elif mode == 'normal' and re.match(r'Changed.paths:', line):
|
||||
out.write(line)
|
||||
out.write('\n')
|
||||
mode = 'cp'
|
||||
elif mode == 'cp' and re.match(r' [ADM] ', line):
|
||||
action = line[3]
|
||||
@ -733,15 +745,18 @@ def log(argv, svn, out):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
elif re.match(r'-{72}', line):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
mode = 'normal'
|
||||
elif re.match(r'={67}', line):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
mode = 'diff'
|
||||
elif mode == 'diff':
|
||||
colordiff(out, line)
|
||||
@ -749,8 +764,10 @@ def log(argv, svn, out):
|
||||
ansi_color(out, 'yellow')
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
else:
|
||||
out.write(line)
|
||||
out.write('\n')
|
||||
return RET_OK
|
||||
|
||||
def update(argv, svn, out):
|
||||
@ -763,6 +780,7 @@ def status(argv, svn, out):
|
||||
external_printed = True
|
||||
pout = Popen([svn] + argv, stdout=PIPE).stdout
|
||||
for line in iter(pout.readline, ''):
|
||||
line = line.strip()
|
||||
m = re.match(r"Performing status on external item at '(.*)':", line)
|
||||
if m is not None:
|
||||
external = m.group(1)
|
||||
@ -789,8 +807,10 @@ def status(argv, svn, out):
|
||||
continue # don't print externals
|
||||
out.write(line)
|
||||
ansi_reset(out)
|
||||
out.write('\n')
|
||||
continue
|
||||
out.write(line)
|
||||
out.write('\n')
|
||||
return RET_OK
|
||||
|
||||
def externals(argv, svn, out):
|
||||
|
Loading…
x
Reference in New Issue
Block a user