diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -57,13 +57,13 @@ class diffopts(object): defaultopts = diffopts() -def wsclean(opts, text): +def wsclean(opts, text, blank=True): if opts.ignorews: text = re.sub('[ \t]+', '', text) elif opts.ignorewsamount: text = re.sub('[ \t]+', ' ', text) text = re.sub('[ \t]+\n', '\n', text) - if opts.ignoreblanklines: + if blank and opts.ignoreblanklines: text = re.sub('\n+', '', text) return text @@ -183,6 +183,10 @@ def bunidiff(t1, t2, l1, l2, header1, he # below finds the spaces between those matching sequences and translates # them into diff output. # + if opts.ignorews or opts.ignorewsamount: + t1 = wsclean(opts, t1, False) + t2 = wsclean(opts, t2, False) + diff = bdiff.blocks(t1, t2) hunk = None for i, s1 in enumerate(diff): @@ -208,7 +212,7 @@ def bunidiff(t1, t2, l1, l2, header1, he if not old and not new: continue - if opts.ignorews or opts.ignorewsamount or opts.ignoreblanklines: + if opts.ignoreblanklines: if wsclean(opts, "".join(old)) == wsclean(opts, "".join(new)): continue diff --git a/tests/test-diff-ignore-whitespace.out b/tests/test-diff-ignore-whitespace.out --- a/tests/test-diff-ignore-whitespace.out +++ b/tests/test-diff-ignore-whitespace.out @@ -181,11 +181,9 @@ diff -r 540c40a65b78 foo --- a/foo +++ b/foo @@ -1,2 +1,3 @@ --hello world --goodbye world -+hello world + hello world + -+goodbye world + goodbye world hg diff -Bb >>> four diffs showing changed whitespace <<< hg diff @@ -212,18 +210,16 @@ diff -r 540c40a65b78 foo +++ b/foo @@ -1,2 +1,2 @@ -hello world --goodbye world +helloworld -+goodbye world + goodbye world hg diff -Bb diff -r 540c40a65b78 foo --- a/foo +++ b/foo @@ -1,2 +1,2 @@ -hello world --goodbye world +helloworld -+goodbye world + goodbye world hg diff -w >>> five diffs showing changed whitespace <<< hg diff @@ -256,34 +252,30 @@ diff -r 540c40a65b78 foo +++ b/foo @@ -1,2 +1,5 @@ -hello world --goodbye world +helloworld + + + -+goodbye world + goodbye world hg diff -Bb diff -r 540c40a65b78 foo --- a/foo +++ b/foo @@ -1,2 +1,5 @@ -hello world --goodbye world +helloworld + + + -+goodbye world + goodbye world hg diff -w diff -r 540c40a65b78 foo --- a/foo +++ b/foo @@ -1,2 +1,5 @@ --hello world --goodbye world -+helloworld + hello world + + + -+goodbye world + goodbye world hg diff -wB diff --git a/tests/test-mq-qdiff.out b/tests/test-mq-qdiff.out --- a/tests/test-mq-qdiff.out +++ b/tests/test-mq-qdiff.out @@ -58,9 +58,8 @@ diff -r 35fb829491c1 lines 2 3 4 --hello world + hello world -goodbye world -+hello world + goodbye world 7 8