D422: mdiff: add a --ignore-space-at-eol option
dsp (David Soria Parra)
phabricator at mercurial-scm.org
Wed Aug 23 22:39:59 EDT 2017
dsp updated this revision to Diff 1240.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D422?vs=1022&id=1240
REVISION DETAIL
https://phab.mercurial-scm.org/D422
AFFECTED FILES
mercurial/cmdutil.py
mercurial/help/config.txt
mercurial/mdiff.py
mercurial/patch.py
tests/test-completion.t
tests/test-diff-ignore-whitespace.t
tests/test-help.t
tests/test-qrecord.t
tests/test-record.t
CHANGE DETAILS
diff --git a/tests/test-record.t b/tests/test-record.t
--- a/tests/test-record.t
+++ b/tests/test-record.t
@@ -62,6 +62,7 @@
-w --ignore-all-space ignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines ignore changes whose lines are all blank
+ -e --ignore-space-at-eol ignore changes in whitespace at EOL
(some details hidden, use --verbose to show complete help)
diff --git a/tests/test-qrecord.t b/tests/test-qrecord.t
--- a/tests/test-qrecord.t
+++ b/tests/test-qrecord.t
@@ -79,6 +79,7 @@
-w --ignore-all-space ignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines ignore changes whose lines are all blank
+ -e --ignore-space-at-eol ignore changes in whitespace at EOL
(some details hidden, use --verbose to show complete help)
@@ -152,6 +153,7 @@
-w --ignore-all-space ignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines ignore changes whose lines are all blank
+ -e --ignore-space-at-eol ignore changes in whitespace at EOL
--mq operate on patch repository
(some details hidden, use --verbose to show complete help)
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -553,6 +553,7 @@
-w --ignore-all-space ignore white space when comparing lines
-b --ignore-space-change ignore changes in the amount of white space
-B --ignore-blank-lines ignore changes whose lines are all blank
+ -e --ignore-space-at-eol ignore changes in whitespace at EOL
-U --unified NUM number of lines of context to show
--stat output diffstat-style summary of changes
--root DIR produce diffs relative to subdirectory
diff --git a/tests/test-diff-ignore-whitespace.t b/tests/test-diff-ignore-whitespace.t
--- a/tests/test-diff-ignore-whitespace.t
+++ b/tests/test-diff-ignore-whitespace.t
@@ -407,8 +407,16 @@
+goodbye\r (no-eol) (esc)
world
+Test \r (carriage return) as used in "DOS" line endings:
+
+ $ printf 'hello world \r\ngoodbye world\n' >foo
+
+ $ hg ndiff --ignore-space-at-eol
+
No completely blank lines to ignore:
+ $ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo
+
$ hg ndiff --ignore-blank-lines
diff -r 540c40a65b78 foo
--- a/foo
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -218,10 +218,10 @@
Show all commands + options
$ hg debugcommands
add: include, exclude, subrepos, dry-run
- annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
+ annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, skip, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, include, exclude, template
clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
- diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, root, include, exclude, subrepos
+ diff: rev, change, text, git, binary, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, ignore-space-at-eol, unified, stat, root, include, exclude, subrepos
export: output, switch-parent, rev, text, git, binary, nodates
forget: include, exclude
init: ssh, remotecmd, insecure
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2282,6 +2282,7 @@
'ignorewsamount')
buildopts['ignoreblanklines'] = get('ignore_blank_lines',
'ignoreblanklines')
+ buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol')
if formatchanging:
buildopts['text'] = opts and opts.get('text')
binary = None if opts is None else opts.get('binary')
diff --git a/mercurial/mdiff.py b/mercurial/mdiff.py
--- a/mercurial/mdiff.py
+++ b/mercurial/mdiff.py
@@ -63,6 +63,7 @@
'index': 0,
'ignorews': False,
'ignorewsamount': False,
+ 'ignorewseol': False,
'ignoreblanklines': False,
'upgrade': False,
'showsimilarity': False,
@@ -97,6 +98,8 @@
text = bdiff.fixws(text, 0)
if blank and opts.ignoreblanklines:
text = re.sub('\n+', '\n', text).strip('\n')
+ if opts.ignorewseol:
+ text = re.sub(r'\s+\n', r'\n', text)
return text
def splitblock(base1, lines1, base2, lines2, opts):
@@ -199,7 +202,7 @@
"""
if opts is None:
opts = defaultopts
- if opts.ignorews or opts.ignorewsamount:
+ if opts.ignorews or opts.ignorewsamount or opts.ignorewseol:
text1 = wsclean(opts, text1, False)
text2 = wsclean(opts, text2, False)
diff = bdiff.blocks(text1, text2)
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -313,6 +313,9 @@
``ignorews``
Ignore white space when comparing lines.
+``ignorewseol``
+ Ignore white space at the end of a line when comparing lines.
+
``ignorewsamount``
Ignore changes in the amount of white space.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -123,6 +123,8 @@
_('ignore changes in the amount of white space')),
('B', 'ignore-blank-lines', None,
_('ignore changes whose lines are all blank')),
+ ('e', 'ignore-space-at-eol', None,
+ _('ignore changes in whitespace at EOL')),
]
diffopts2 = [
To: dsp, #hg-reviewers, quark
Cc: akushner, martinvonz, quark, mercurial-devel
More information about the Mercurial-devel
mailing list