Show More
@@ -75,12 +75,13 b' def wsclean(opts, text, blank=True):' | |||||
75 | text = re.sub('\n+', '\n', text).strip('\n') |
|
75 | text = re.sub('\n+', '\n', text).strip('\n') | |
76 | return text |
|
76 | return text | |
77 |
|
77 | |||
78 |
def |
|
78 | def allblocks(text1, text2, opts=None, lines1=None, lines2=None): | |
79 | """Return changed blocks between text1 and text2, the blocks in-between |
|
79 | """Return (block, type) tuples, where block is an mdiff.blocks | |
80 | those emitted by bdiff.blocks. Take in account the whitespace normalization |
|
80 | line entry. type is '=' for blocks matching exactly one another | |
81 | rules defined by opts. |
|
81 | (bdiff blocks), '!' for non-matching blocks and '~' for blocks | |
82 | line1 and line2 are text1 and text2 split with splitnewlines() if they are |
|
82 | matching only after having filtered blank lines. | |
83 | already available. |
|
83 | line1 and line2 are text1 and text2 split with splitnewlines() if | |
|
84 | they are already available. | |||
84 | """ |
|
85 | """ | |
85 | if opts is None: |
|
86 | if opts is None: | |
86 | opts = defaultopts |
|
87 | opts = defaultopts | |
@@ -107,13 +108,15 b' def diffblocks(text1, text2, opts=None, ' | |||||
107 |
|
108 | |||
108 | # bdiff sometimes gives huge matches past eof, this check eats them, |
|
109 | # bdiff sometimes gives huge matches past eof, this check eats them, | |
109 | # and deals with the special first match case described above |
|
110 | # and deals with the special first match case described above | |
110 |
if |
|
111 | if old or new: | |
111 |
|
|
112 | type = '!' | |
112 |
|
113 | if opts.ignoreblanklines: | ||
113 | if opts.ignoreblanklines: |
|
114 | cold = wsclean(opts, "".join(old)) | |
114 |
|
|
115 | cnew = wsclean(opts, "".join(new)) | |
115 |
|
|
116 | if cold == cnew: | |
116 | yield s |
|
117 | type = '~' | |
|
118 | yield s, type | |||
|
119 | yield s1, '=' | |||
117 |
|
120 | |||
118 | def diffline(revs, a, b, opts): |
|
121 | def diffline(revs, a, b, opts): | |
119 | parts = ['diff'] |
|
122 | parts = ['diff'] | |
@@ -241,7 +244,9 b' def _unidiff(t1, t2, l1, l2, opts=defaul' | |||||
241 | # them into diff output. |
|
244 | # them into diff output. | |
242 | # |
|
245 | # | |
243 | hunk = None |
|
246 | hunk = None | |
244 |
for s in |
|
247 | for s, stype in allblocks(t1, t2, opts, l1, l2): | |
|
248 | if stype != '!': | |||
|
249 | continue | |||
245 | delta = [] |
|
250 | delta = [] | |
246 | a1, a2, b1, b2 = s |
|
251 | a1, a2, b1, b2 = s | |
247 | old = l1[a1:a2] |
|
252 | old = l1[a1:a2] |
General Comments 0
You need to be logged in to leave comments.
Login now