##// END OF EJS Templates
mdiff: add a --ignore-space-at-eol option...
David Soria Parra -
r34015:da07367d default
parent child Browse files
Show More
@@ -123,6 +123,8 b' diffwsopts = ['
123 123 _('ignore changes in the amount of white space')),
124 124 ('B', 'ignore-blank-lines', None,
125 125 _('ignore changes whose lines are all blank')),
126 ('Z', 'ignore-space-at-eol', None,
127 _('ignore changes in whitespace at EOL')),
126 128 ]
127 129
128 130 diffopts2 = [
@@ -313,6 +313,9 b' related options for the diff command.'
313 313 ``ignorews``
314 314 Ignore white space when comparing lines.
315 315
316 ``ignorewseol``
317 Ignore white space at the end of a line when comparing lines.
318
316 319 ``ignorewsamount``
317 320 Ignore changes in the amount of white space.
318 321
@@ -63,6 +63,7 b' class diffopts(object):'
63 63 'index': 0,
64 64 'ignorews': False,
65 65 'ignorewsamount': False,
66 'ignorewseol': False,
66 67 'ignoreblanklines': False,
67 68 'upgrade': False,
68 69 'showsimilarity': False,
@@ -97,6 +98,8 b' def wsclean(opts, text, blank=True):'
97 98 text = bdiff.fixws(text, 0)
98 99 if blank and opts.ignoreblanklines:
99 100 text = re.sub('\n+', '\n', text).strip('\n')
101 if opts.ignorewseol:
102 text = re.sub(r'[ \t\r\f]+\n', r'\n', text)
100 103 return text
101 104
102 105 def splitblock(base1, lines1, base2, lines2, opts):
@@ -199,7 +202,7 b' def allblocks(text1, text2, opts=None, l'
199 202 """
200 203 if opts is None:
201 204 opts = defaultopts
202 if opts.ignorews or opts.ignorewsamount:
205 if opts.ignorews or opts.ignorewsamount or opts.ignorewseol:
203 206 text1 = wsclean(opts, text1, False)
204 207 text2 = wsclean(opts, text2, False)
205 208 diff = bdiff.blocks(text1, text2)
@@ -2282,6 +2282,7 b' def difffeatureopts(ui, opts=None, untru'
2282 2282 'ignorewsamount')
2283 2283 buildopts['ignoreblanklines'] = get('ignore_blank_lines',
2284 2284 'ignoreblanklines')
2285 buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol')
2285 2286 if formatchanging:
2286 2287 buildopts['text'] = opts and opts.get('text')
2287 2288 binary = None if opts is None else opts.get('binary')
@@ -218,10 +218,10 b' Show an error if we use --options with a'
218 218 Show all commands + options
219 219 $ hg debugcommands
220 220 add: include, exclude, subrepos, dry-run
221 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
221 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
222 222 clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
223 223 commit: addremove, close-branch, amend, secret, edit, interactive, include, exclude, message, logfile, date, user, subrepos
224 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
224 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
225 225 export: output, switch-parent, rev, text, git, binary, nodates
226 226 forget: include, exclude
227 227 init: ssh, remotecmd, insecure
@@ -407,8 +407,23 b' Test \\r (carriage return) as used in "DO'
407 407 +goodbye\r (no-eol) (esc)
408 408 world
409 409
410 Test \r (carriage return) as used in "DOS" line endings:
411
412 $ printf 'hello world \r\n\t\ngoodbye world\n' >foo
413
414 $ hg ndiff --ignore-space-at-eol
415 diff -r 540c40a65b78 foo
416 --- a/foo
417 +++ b/foo
418 @@ -1,2 +1,3 @@
419 hello world
420 +\t (esc)
421 goodbye world
422
410 423 No completely blank lines to ignore:
411 424
425 $ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo
426
412 427 $ hg ndiff --ignore-blank-lines
413 428 diff -r 540c40a65b78 foo
414 429 --- a/foo
@@ -553,6 +553,7 b' Test command without options'
553 553 -w --ignore-all-space ignore white space when comparing lines
554 554 -b --ignore-space-change ignore changes in the amount of white space
555 555 -B --ignore-blank-lines ignore changes whose lines are all blank
556 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
556 557 -U --unified NUM number of lines of context to show
557 558 --stat output diffstat-style summary of changes
558 559 --root DIR produce diffs relative to subdirectory
@@ -79,6 +79,7 b' help record (record)'
79 79 -w --ignore-all-space ignore white space when comparing lines
80 80 -b --ignore-space-change ignore changes in the amount of white space
81 81 -B --ignore-blank-lines ignore changes whose lines are all blank
82 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
82 83
83 84 (some details hidden, use --verbose to show complete help)
84 85
@@ -152,6 +153,7 b' help (mq present)'
152 153 -w --ignore-all-space ignore white space when comparing lines
153 154 -b --ignore-space-change ignore changes in the amount of white space
154 155 -B --ignore-blank-lines ignore changes whose lines are all blank
156 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
155 157 --mq operate on patch repository
156 158
157 159 (some details hidden, use --verbose to show complete help)
@@ -62,6 +62,7 b' Record help'
62 62 -w --ignore-all-space ignore white space when comparing lines
63 63 -b --ignore-space-change ignore changes in the amount of white space
64 64 -B --ignore-blank-lines ignore changes whose lines are all blank
65 -Z --ignore-space-at-eol ignore changes in whitespace at EOL
65 66
66 67 (some details hidden, use --verbose to show complete help)
67 68
General Comments 0
You need to be logged in to leave comments. Login now