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