|
@@ -377,7 +377,7 @@ class UnifiedDiff(Diff):
|
377
|
377
|
|
378
|
378
|
def is_hunk_meta(self, line):
|
379
|
379
|
"""Minimal valid hunk meta is like '@@ -1 +1 @@', note extra chars
|
380
|
|
- might occur after the ending @@, e.g. in git log. '## ' uaually
|
|
380
|
+ might occur after the ending @@, e.g. in git log. '## ' usually
|
381
|
381
|
indicates svn property changes in output from `svn log --diff`
|
382
|
382
|
"""
|
383
|
383
|
return (line.startswith('@@ -') and line.find(' @@') >= 8) or \
|
|
@@ -484,6 +484,12 @@ class DiffParser(object):
|
484
|
484
|
header[3].startswith('*** ') and
|
485
|
485
|
header[3].rstrip().endswith(' ****')):
|
486
|
486
|
self._type = 'context'
|
|
487
|
+
|
|
488
|
+ # For context diff, try use `filterdiff` to translate it to unified
|
|
489
|
+ # format and provide a new stream
|
|
490
|
+ #
|
|
491
|
+ # TODO
|
|
492
|
+
|
487
|
493
|
return
|
488
|
494
|
|
489
|
495
|
for n in range(size):
|
|
@@ -492,15 +498,11 @@ class DiffParser(object):
|
492
|
498
|
self._type = 'unified'
|
493
|
499
|
break
|
494
|
500
|
else:
|
495
|
|
- if size < 5:
|
496
|
|
- # It's safe to consider as udiff if patch stream contains no
|
497
|
|
- # more than 4 lines. happens with `git diff` on a file that
|
498
|
|
- # only has perm bits changes or `svn diff` with property
|
499
|
|
- # changes.
|
500
|
|
- #
|
501
|
|
- self._type = 'unified'
|
502
|
|
- else:
|
503
|
|
- raise RuntimeError('unknown diff type')
|
|
501
|
+ # `filterdiff` translate unknown diff to nothing, fall through to
|
|
502
|
+ # unified diff give cdiff a chance to show everything as headers
|
|
503
|
+ #
|
|
504
|
+ sys.stderr.write("*** unknown format, fall through to 'unified'\n")
|
|
505
|
+ self._type = 'unified'
|
504
|
506
|
|
505
|
507
|
def get_diff_generator(self):
|
506
|
508
|
"""parse all diff lines, construct a list of Diff objects"""
|