##// END OF EJS Templates
mdiff: fix diff -b/B/w on mixed whitespace hunks (issue127)...
Patrick Mezard -
r9827:4fe9ca51 default
parent child Browse files
Show More
@@ -57,13 +57,13 b' class diffopts(object):'
57 57
58 58 defaultopts = diffopts()
59 59
60 def wsclean(opts, text):
60 def wsclean(opts, text, blank=True):
61 61 if opts.ignorews:
62 62 text = re.sub('[ \t]+', '', text)
63 63 elif opts.ignorewsamount:
64 64 text = re.sub('[ \t]+', ' ', text)
65 65 text = re.sub('[ \t]+\n', '\n', text)
66 if opts.ignoreblanklines:
66 if blank and opts.ignoreblanklines:
67 67 text = re.sub('\n+', '', text)
68 68 return text
69 69
@@ -183,6 +183,10 b' def bunidiff(t1, t2, l1, l2, header1, he'
183 183 # below finds the spaces between those matching sequences and translates
184 184 # them into diff output.
185 185 #
186 if opts.ignorews or opts.ignorewsamount:
187 t1 = wsclean(opts, t1, False)
188 t2 = wsclean(opts, t2, False)
189
186 190 diff = bdiff.blocks(t1, t2)
187 191 hunk = None
188 192 for i, s1 in enumerate(diff):
@@ -208,7 +212,7 b' def bunidiff(t1, t2, l1, l2, header1, he'
208 212 if not old and not new:
209 213 continue
210 214
211 if opts.ignorews or opts.ignorewsamount or opts.ignoreblanklines:
215 if opts.ignoreblanklines:
212 216 if wsclean(opts, "".join(old)) == wsclean(opts, "".join(new)):
213 217 continue
214 218
@@ -181,11 +181,9 b' diff -r 540c40a65b78 foo'
181 181 --- a/foo
182 182 +++ b/foo
183 183 @@ -1,2 +1,3 @@
184 -hello world
185 -goodbye world
186 +hello world
184 hello world
187 185 +
188 +goodbye world
186 goodbye world
189 187 hg diff -Bb
190 188 >>> four diffs showing changed whitespace <<<
191 189 hg diff
@@ -212,18 +210,16 b' diff -r 540c40a65b78 foo'
212 210 +++ b/foo
213 211 @@ -1,2 +1,2 @@
214 212 -hello world
215 -goodbye world
216 213 +helloworld
217 +goodbye world
214 goodbye world
218 215 hg diff -Bb
219 216 diff -r 540c40a65b78 foo
220 217 --- a/foo
221 218 +++ b/foo
222 219 @@ -1,2 +1,2 @@
223 220 -hello world
224 -goodbye world
225 221 +helloworld
226 +goodbye world
222 goodbye world
227 223 hg diff -w
228 224 >>> five diffs showing changed whitespace <<<
229 225 hg diff
@@ -256,34 +252,30 b' diff -r 540c40a65b78 foo'
256 252 +++ b/foo
257 253 @@ -1,2 +1,5 @@
258 254 -hello world
259 -goodbye world
260 255 +helloworld
261 256 +
262 257 +
263 258 +
264 +goodbye world
259 goodbye world
265 260 hg diff -Bb
266 261 diff -r 540c40a65b78 foo
267 262 --- a/foo
268 263 +++ b/foo
269 264 @@ -1,2 +1,5 @@
270 265 -hello world
271 -goodbye world
272 266 +helloworld
273 267 +
274 268 +
275 269 +
276 +goodbye world
270 goodbye world
277 271 hg diff -w
278 272 diff -r 540c40a65b78 foo
279 273 --- a/foo
280 274 +++ b/foo
281 275 @@ -1,2 +1,5 @@
282 -hello world
283 -goodbye world
284 +helloworld
276 hello world
285 277 +
286 278 +
287 279 +
288 +goodbye world
280 goodbye world
289 281 hg diff -wB
@@ -58,9 +58,8 b' diff -r 35fb829491c1 lines'
58 58 2
59 59 3
60 60 4
61 -hello world
61 hello world
62 62 -goodbye world
63 +hello world
64 63 + goodbye world
65 64 7
66 65 8
General Comments 0
You need to be logged in to leave comments. Login now