|
@@ -8,7 +8,7 @@ workspace, given patch or two files, or from stdin, with **side by side** and
|
8
|
8
|
"""
|
9
|
9
|
|
10
|
10
|
META_INFO = {
|
11
|
|
- 'version' : '0.6',
|
|
11
|
+ 'version' : '0.7',
|
12
|
12
|
'license' : 'BSD-3',
|
13
|
13
|
'author' : 'Matthew Wang',
|
14
|
14
|
'email' : 'mattwyl(@)gmail(.)com',
|
|
@@ -588,7 +588,7 @@ def markup_to_pager(stream, opts):
|
588
|
588
|
color_diff = markup.markup(side_by_side=opts.side_by_side,
|
589
|
589
|
width=opts.width)
|
590
|
590
|
|
591
|
|
- # args stolen fron git source: github.com/git/git/blob/master/pager.c
|
|
591
|
+ # Args stolen from git source: github.com/git/git/blob/master/pager.c
|
592
|
592
|
pager = subprocess.Popen(['less', '-FRSX'],
|
593
|
593
|
stdin=subprocess.PIPE, stdout=sys.stdout)
|
594
|
594
|
try:
|
|
@@ -610,18 +610,20 @@ def check_command_status(arguments):
|
610
|
610
|
return False
|
611
|
611
|
|
612
|
612
|
|
613
|
|
-def revision_control_diff():
|
|
613
|
+def revision_control_diff(args):
|
614
|
614
|
"""Return diff from revision control system."""
|
615
|
615
|
for _, ops in VCS_INFO.items():
|
616
|
616
|
if check_command_status(ops['probe']):
|
617
|
|
- return subprocess.Popen(ops['diff'], stdout=subprocess.PIPE).stdout
|
|
617
|
+ return subprocess.Popen(
|
|
618
|
+ ops['diff'] + args, stdout=subprocess.PIPE).stdout
|
618
|
619
|
|
619
|
620
|
|
620
|
|
-def revision_control_log():
|
|
621
|
+def revision_control_log(args):
|
621
|
622
|
"""Return log from revision control system."""
|
622
|
623
|
for _, ops in VCS_INFO.items():
|
623
|
624
|
if check_command_status(ops['probe']):
|
624
|
|
- return subprocess.Popen(ops['log'], stdout=subprocess.PIPE).stdout
|
|
625
|
+ return subprocess.Popen(
|
|
626
|
+ ops['log'] + args, stdout=subprocess.PIPE).stdout
|
625
|
627
|
|
626
|
628
|
|
627
|
629
|
def decode(line):
|
|
@@ -655,25 +657,13 @@ def main():
|
655
|
657
|
opts, args = parser.parse_args()
|
656
|
658
|
|
657
|
659
|
if opts.log:
|
658
|
|
- diff_hdl = revision_control_log()
|
|
660
|
+ diff_hdl = revision_control_log(args)
|
659
|
661
|
if not diff_hdl:
|
660
|
662
|
sys.stderr.write(('*** Not in a supported workspace, supported '
|
661
|
663
|
'are: %s\n') % ', '.join(supported_vcs))
|
662
|
664
|
return 1
|
663
|
|
- elif len(args) > 2:
|
664
|
|
- parser.print_help()
|
665
|
|
- return 1
|
666
|
|
- elif len(args) == 2:
|
667
|
|
- diff_hdl = subprocess.Popen(['diff', '-u', args[0], args[1]],
|
668
|
|
- stdout=subprocess.PIPE).stdout
|
669
|
|
- elif len(args) == 1:
|
670
|
|
- if IS_PY3:
|
671
|
|
- # Python3 needs the newline='' to keep '\r' (DOS format)
|
672
|
|
- diff_hdl = open(args[0], mode='rt', newline='')
|
673
|
|
- else:
|
674
|
|
- diff_hdl = open(args[0], mode='rt')
|
675
|
665
|
elif sys.stdin.isatty():
|
676
|
|
- diff_hdl = revision_control_diff()
|
|
666
|
+ diff_hdl = revision_control_diff(args)
|
677
|
667
|
if not diff_hdl:
|
678
|
668
|
sys.stderr.write(('*** Not in a supported workspace, supported '
|
679
|
669
|
'are: %s\n\n') % ', '.join(supported_vcs))
|