Mercurial > public > mercurial-scm > hg
diff mercurial/mdiff.py @ 34013:da07367d683b
mdiff: add a --ignore-space-at-eol option
Add an option that only ignores whitespaces at EOL. The name of the option is
the same as Git.
.. feature::
Added `--ignore-space-at-eol` diff option to ignore whitespace differences
at line endings.
Differential Revision: https://phab.mercurial-scm.org/D422
author | David Soria Parra <davidsp@fb.com> |
---|---|
date | Tue, 29 Aug 2017 18:20:50 -0700 |
parents | 1b6946f87c50 |
children | 1d804c22c671 |
line wrap: on
line diff
--- a/mercurial/mdiff.py Fri Aug 25 11:20:34 2017 -0700 +++ b/mercurial/mdiff.py Tue Aug 29 18:20:50 2017 -0700 @@ -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'[ \t\r\f]+\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)