mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
mdiff: carriage return (\r) is also ignorable whitespace
This commit is contained in:
parent
e484985865
commit
35ef3c1409
@ -67,10 +67,10 @@ defaultopts = diffopts()
|
||||
|
||||
def wsclean(opts, text, blank=True):
|
||||
if opts.ignorews:
|
||||
text = re.sub('[ \t]+', '', text)
|
||||
text = re.sub('[ \t\r]+', '', text)
|
||||
elif opts.ignorewsamount:
|
||||
text = re.sub('[ \t]+', ' ', text)
|
||||
text = re.sub('[ \t]+\n', '\n', text)
|
||||
text = re.sub('[ \t\r]+', ' ', text)
|
||||
text = text.replace(' \n', '\n')
|
||||
if blank and opts.ignoreblanklines:
|
||||
text = re.sub('\n+', '', text)
|
||||
return text
|
||||
|
@ -390,3 +390,57 @@ Test whitespace changes and blank lines:
|
||||
|
||||
$ hg ndiff -wB
|
||||
|
||||
|
||||
Test \r (carriage return) as used in "DOS" line endings:
|
||||
|
||||
$ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo
|
||||
|
||||
$ hg ndiff
|
||||
diff -r 540c40a65b78 foo
|
||||
--- a/foo
|
||||
+++ b/foo
|
||||
@@ -1,2 +1,3 @@
|
||||
-hello world
|
||||
-goodbye world
|
||||
+hello world
|
||||
+
|
||||
+goodbye
world
|
||||
world
|
||||
|
||||
No completely blank lines to ignore:
|
||||
|
||||
$ hg ndiff --ignore-blank-lines
|
||||
diff -r 540c40a65b78 foo
|
||||
--- a/foo
|
||||
+++ b/foo
|
||||
@@ -1,2 +1,3 @@
|
||||
-hello world
|
||||
-goodbye world
|
||||
+hello world
|
||||
+
|
||||
+goodbye
world
|
||||
world
|
||||
|
||||
Only new line noticed:
|
||||
|
||||
$ hg ndiff --ignore-space-change
|
||||
diff -r 540c40a65b78 foo
|
||||
--- a/foo
|
||||
+++ b/foo
|
||||
@@ -1,2 +1,3 @@
|
||||
hello world
|
||||
+
|
||||
goodbye world
|
||||
|
||||
$ hg ndiff --ignore-all-space
|
||||
diff -r 540c40a65b78 foo
|
||||
--- a/foo
|
||||
+++ b/foo
|
||||
@@ -1,2 +1,3 @@
|
||||
hello world
|
||||
+
|
||||
goodbye world
|
||||
|
||||
New line not noticed when space change ignored:
|
||||
|
||||
$ hg ndiff --ignore-blank-lines --ignore-all-space
|
||||
|
Loading…
Reference in New Issue
Block a user