|
@@ -11,7 +11,7 @@ See demo at homepage: https://github.com/ymattw/cdiff
|
11
|
11
|
import sys
|
12
|
12
|
|
13
|
13
|
if sys.hexversion < 0x02050000:
|
14
|
|
- sys.stderr.write("ERROR: requires python >= 2.5.0\n")
|
|
14
|
+ sys.stderr.write("*** Requires python >= 2.5.0\n")
|
15
|
15
|
sys.exit(1)
|
16
|
16
|
IS_PY3 = sys.hexversion >= 0x03000000
|
17
|
17
|
|
|
@@ -404,7 +404,12 @@ class DiffParser(object):
|
404
|
404
|
# @@ -3,7 +3,6 @@
|
405
|
405
|
hunk_header = stream.pop(0)
|
406
|
406
|
a = hunk_header.split()[1].split(',') # -3 7
|
407
|
|
- old_addr = (int(a[0][1:]), int(a[1]))
|
|
407
|
+ if len(a) > 1:
|
|
408
|
+ old_addr = (int(a[0][1:]), int(a[1]))
|
|
409
|
+ else:
|
|
410
|
+ # @@ -1 +1,2 @@
|
|
411
|
+ old_addr = (int(a[0][1:]), 0)
|
|
412
|
+
|
408
|
413
|
b = hunk_header.split()[2].split(',') # +3 6
|
409
|
414
|
if len(b) > 1:
|
410
|
415
|
new_addr = (int(b[0][1:]), int(b[1]))
|
|
@@ -508,10 +513,14 @@ def decode(line):
|
508
|
513
|
if __name__ == '__main__':
|
509
|
514
|
import optparse
|
510
|
515
|
|
511
|
|
- usage = '''%s [options] [diff]''' % os.path.basename(sys.argv[0])
|
512
|
|
- description= ('''View incremental, colored diff in unified format or '''
|
513
|
|
- '''in side by side mode with auto pager, read stdin if '''
|
514
|
|
- '''diff (patch) file is not given''')
|
|
516
|
+ supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
|
|
517
|
+
|
|
518
|
+ usage = '%s [options] [diff]' % os.path.basename(sys.argv[0])
|
|
519
|
+ description= ('View incremental, colored diff in unified format or '
|
|
520
|
+ 'side by side with auto pager. Read diff from diff '
|
|
521
|
+ '(patch) file if given, or stdin if redirected, or '
|
|
522
|
+ 'diff produced by revision tool if in a %s workspace') \
|
|
523
|
+ % '/'.join(supported_vcs)
|
515
|
524
|
|
516
|
525
|
parser = optparse.OptionParser(usage=usage, description=description)
|
517
|
526
|
parser.add_option('-s', '--side-by-side', action='store_true',
|
|
@@ -529,6 +538,8 @@ if __name__ == '__main__':
|
529
|
538
|
elif sys.stdin.isatty():
|
530
|
539
|
diff_hdl = revision_control_diff()
|
531
|
540
|
if not diff_hdl:
|
|
541
|
+ sys.stderr.write(('*** Not in a supported workspace, supported '
|
|
542
|
+ 'are: %s\n\n') % ', '.join(supported_vcs))
|
532
|
543
|
parser.print_help()
|
533
|
544
|
sys.exit(1)
|
534
|
545
|
else:
|