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