jsvn: read lines from diff/log as available
This commit is contained in:
parent
c455018cf1
commit
d33436892f
26
jsvn
26
jsvn
@ -88,22 +88,22 @@ def ansi_reset(out):
|
|||||||
def colordiff(out, line):
|
def colordiff(out, line):
|
||||||
if re.search(r'^Index:\s', line):
|
if re.search(r'^Index:\s', line):
|
||||||
ansi_color(out, 'yellow')
|
ansi_color(out, 'yellow')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
return
|
return
|
||||||
if re.match(r'={67}', line):
|
if re.match(r'={67}', line):
|
||||||
ansi_color(out, 'yellow')
|
ansi_color(out, 'yellow')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
return
|
return
|
||||||
if re.search(r'^-', line):
|
if re.search(r'^-', line):
|
||||||
ansi_color(out, 'red')
|
ansi_color(out, 'red')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
return
|
return
|
||||||
elif re.search(r'^\+', line):
|
elif re.search(r'^\+', line):
|
||||||
ansi_color(out, 'green')
|
ansi_color(out, 'green')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
return
|
return
|
||||||
m = re.match(r'(@@.*@@)(.*)', line)
|
m = re.match(r'(@@.*@@)(.*)', line)
|
||||||
@ -111,10 +111,9 @@ def colordiff(out, line):
|
|||||||
ansi_color(out, 'cyan')
|
ansi_color(out, 'cyan')
|
||||||
out.write(m.group(1))
|
out.write(m.group(1))
|
||||||
out.write(m.group(2))
|
out.write(m.group(2))
|
||||||
out.write('\n')
|
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
return
|
return
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
|
|
||||||
def findInPath(cmd):
|
def findInPath(cmd):
|
||||||
path_entries = os.environ['PATH'].split(os.pathsep)
|
path_entries = os.environ['PATH'].split(os.pathsep)
|
||||||
@ -410,13 +409,15 @@ def lockable(argv, svn, out):
|
|||||||
return RET_OK
|
return RET_OK
|
||||||
|
|
||||||
def diff(argv, svn, out):
|
def diff(argv, svn, out):
|
||||||
for line in Popen([svn] + argv, stdout=PIPE).communicate()[0].split('\n'):
|
pout = Popen([svn] + argv, stdout=PIPE).stdout
|
||||||
|
for line in iter(pout.readline, ''):
|
||||||
colordiff(out, line)
|
colordiff(out, line)
|
||||||
return RET_OK
|
return RET_OK
|
||||||
|
|
||||||
def log(argv, svn, out):
|
def log(argv, svn, out):
|
||||||
in_diff = False
|
in_diff = False
|
||||||
for line in Popen([svn] + argv, stdout=PIPE).communicate()[0].split('\n'):
|
pout = Popen([svn] + argv, stdout=PIPE).stdout
|
||||||
|
for line in iter(pout.readline, ''):
|
||||||
if re.match(r'(r\d+)\s+\|', line):
|
if re.match(r'(r\d+)\s+\|', line):
|
||||||
parts = line.split('|')
|
parts = line.split('|')
|
||||||
if len(parts) == 4:
|
if len(parts) == 4:
|
||||||
@ -433,25 +434,24 @@ def log(argv, svn, out):
|
|||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
out.write('|')
|
out.write('|')
|
||||||
out.write(parts[3])
|
out.write(parts[3])
|
||||||
out.write('\n')
|
|
||||||
elif re.match(r'-{72}', line):
|
elif re.match(r'-{72}', line):
|
||||||
ansi_color(out, 'yellow')
|
ansi_color(out, 'yellow')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
in_diff = False
|
in_diff = False
|
||||||
elif re.match(r'={67}', line):
|
elif re.match(r'={67}', line):
|
||||||
ansi_color(out, 'yellow')
|
ansi_color(out, 'yellow')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
in_diff = True
|
in_diff = True
|
||||||
elif in_diff:
|
elif in_diff:
|
||||||
colordiff(out, line)
|
colordiff(out, line)
|
||||||
elif re.search(r'^Index:\s', line):
|
elif re.search(r'^Index:\s', line):
|
||||||
ansi_color(out, 'yellow')
|
ansi_color(out, 'yellow')
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
ansi_reset(out)
|
ansi_reset(out)
|
||||||
else:
|
else:
|
||||||
out.write(line + '\n')
|
out.write(line)
|
||||||
return RET_OK
|
return RET_OK
|
||||||
|
|
||||||
def root(argv, svn, out):
|
def root(argv, svn, out):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user