|
@@ -40,6 +40,15 @@ COLORS = {
|
40
|
40
|
'lightcyan' : '\x1b[1;36m',
|
41
|
41
|
}
|
42
|
42
|
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+REVISION_CONTROL = (
|
|
46
|
+ (['git', 'rev-parse'], ['git', 'diff']),
|
|
47
|
+ (['svn', 'info'], ['svn', 'diff']),
|
|
48
|
+ (['hg', 'summary'], ['hg', 'diff'])
|
|
49
|
+)
|
|
50
|
+
|
|
51
|
+
|
43
|
52
|
def ansi_code(color):
|
44
|
53
|
return COLORS.get(color, '')
|
45
|
54
|
|
|
@@ -481,14 +490,16 @@ def check_command_status(arguments):
|
481
|
490
|
return False
|
482
|
491
|
|
483
|
492
|
|
|
493
|
+def command_pipe(arguments):
|
|
494
|
+ """Return stdout pipe after starting subprocess."""
|
|
495
|
+ return subprocess.Popen(arguments, stdout=subprocess.PIPE).stdout
|
|
496
|
+
|
|
497
|
+
|
484
|
498
|
def revision_control_diff(path):
|
485
|
499
|
"""Return diff from revision control system."""
|
486
|
|
- if check_command_status(['git', 'rev-parse']):
|
487
|
|
- return subprocess.Popen(['git', 'diff'], stdout=subprocess.PIPE).stdout
|
488
|
|
- elif check_command_status(['svn', 'info']):
|
489
|
|
- return subprocess.Popen(['svn', 'diff'], stdout=subprocess.PIPE).stdout
|
490
|
|
- elif check_command_status(['hg', 'summary']):
|
491
|
|
- return subprocess.Popen(['hg', 'diff'], stdout=subprocess.PIPE).stdout
|
|
500
|
+ for check, diff in REVISION_CONTROL:
|
|
501
|
+ if check_command_status(check):
|
|
502
|
+ return command_pipe(diff)
|
492
|
503
|
|
493
|
504
|
|
494
|
505
|
def decode(line):
|