|
@@ -128,9 +128,7 @@ class Diff(object):
|
128
|
128
|
yield self._markup_common(' ' + old[1])
|
129
|
129
|
|
130
|
130
|
def markup_side_by_side(self, width):
|
131
|
|
- """width of 0 means infinite width, None means auto detect. Returns a
|
132
|
|
- generator
|
133
|
|
- """
|
|
131
|
+ """Returns a generator"""
|
134
|
132
|
def _normalize(line):
|
135
|
133
|
return line.replace('\t', ' ' * 8).replace('\n', '')
|
136
|
134
|
|
|
@@ -147,7 +145,8 @@ class Diff(object):
|
147
|
145
|
return markup
|
148
|
146
|
|
149
|
147
|
# Setup line width and number width
|
150
|
|
- if not width: width = 80
|
|
148
|
+ if width <= 0:
|
|
149
|
+ width = 80
|
151
|
150
|
(start, offset) = self._hunks[-1].get_old_addr()
|
152
|
151
|
max1 = start + offset - 1
|
153
|
152
|
(start, offset) = self._hunks[-1].get_new_addr()
|
|
@@ -430,13 +429,10 @@ if __name__ == '__main__':
|
430
|
429
|
parser = optparse.OptionParser(usage)
|
431
|
430
|
parser.add_option('-s', '--side-by-side', action='store_true',
|
432
|
431
|
help=('show in side-by-side mode'))
|
433
|
|
- parser.add_option('-w', '--width', type='int', default=None,
|
434
|
|
- help='set line width (side-by-side mode only)')
|
|
432
|
+ parser.add_option('-w', '--width', type='int', default=80,
|
|
433
|
+ help='set line width (side-by-side mode only), default is 80')
|
435
|
434
|
opts, args = parser.parse_args()
|
436
|
435
|
|
437
|
|
- if opts.width and opts.width < 0:
|
438
|
|
- opts.width = 0
|
439
|
|
-
|
440
|
436
|
if len(args) >= 1:
|
441
|
437
|
diff_hdl = open(args[0], 'r')
|
442
|
438
|
elif sys.stdin.isatty():
|