diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py index 00276525e2b72ee644a17e85deccef06cac11d96_bWVyY3VyaWFsL21kaWZmLnB5..3774e1453ef49cd65da9571704c180b9ef5ca5f6_bWVyY3VyaWFsL21kaWZmLnB5 100644 --- a/mercurial/mdiff.py +++ b/mercurial/mdiff.py @@ -72,7 +72,7 @@ text = re.sub('[ \t\r]+', ' ', text) text = text.replace(' \n', '\n') if blank and opts.ignoreblanklines: - text = re.sub('\n+', '', text) + text = re.sub('\n+', '\n', text).strip('\n') return text def diffline(revs, a, b, opts): diff --git a/tests/test-diff-ignore-whitespace.t b/tests/test-diff-ignore-whitespace.t index 00276525e2b72ee644a17e85deccef06cac11d96_dGVzdHMvdGVzdC1kaWZmLWlnbm9yZS13aGl0ZXNwYWNlLnQ=..3774e1453ef49cd65da9571704c180b9ef5ca5f6_dGVzdHMvdGVzdC1kaWZmLWlnbm9yZS13aGl0ZXNwYWNlLnQ= 100644 --- a/tests/test-diff-ignore-whitespace.t +++ b/tests/test-diff-ignore-whitespace.t @@ -442,3 +442,16 @@ New line not noticed when space change ignored: $ hg ndiff --ignore-blank-lines --ignore-all-space + +Do not ignore all newlines, only blank lines + + $ printf 'hello \nworld\ngoodbye world\n' > foo + $ hg ndiff --ignore-blank-lines + diff -r 540c40a65b78 foo + --- a/foo + +++ b/foo + @@ -1,2 +1,3 @@ + -hello world + +hello + +world + goodbye world