changeset 15509:3774e1453ef4 stable

diff: --ignore-blank-lines was too enthusiastic It was ignoring changes from: ab to: a b
author Patrick Mezard <pmezard@gmail.com>
date Sun, 13 Nov 2011 21:37:14 +0100
parents 00276525e2b7
children 6cae68a361ed
files mercurial/mdiff.py tests/test-diff-ignore-whitespace.t
diffstat 2 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mdiff.py	Sat Nov 12 14:00:25 2011 +0100
+++ b/mercurial/mdiff.py	Sun Nov 13 21:37:14 2011 +0100
@@ -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):
--- a/tests/test-diff-ignore-whitespace.t	Sat Nov 12 14:00:25 2011 +0100
+++ b/tests/test-diff-ignore-whitespace.t	Sun Nov 13 21:37:14 2011 +0100
@@ -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