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.
( )
quark | |
yuja |
hg-reviewers |
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.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Looks good to me. It seems to be a significant feature that is worth a release note. Maybe check https://www.mercurial-scm.org/wiki/ReleasenotesExtension and amend the commit message to include something like:
.. feature:: Added `--ignore-space-at-eol` diff option to ignore whitespace differences at line endings.
mercurial/help/config.txt | ||
---|---|---|
317 | Maybe remove only since otherwise it sounds ignorewseol must be used together with ignorews. |
Looks like you didn't run test-help.t. I'll fix it in flight, but please run all tests next time.
In D422#7795, @martinvonz wrote:Looks like you didn't run test-help.t. I'll fix it in flight, but please run all tests next time.
...and test-completion.t and test-qrecord.t
In D422#7797, @martinvonz wrote:In D422#7795, @martinvonz wrote:Looks like you didn't run test-help.t. I'll fix it in flight, but please run all tests next time.
...and test-completion.t and test-qrecord.t
...and test-record.t and test-duplicateoptions.py. This is getting a bit too many, especially since the last one is not trivial, so please send an update instead.
Maybe we should set up CI on Phabricator.
Yes, I've also suggested that. The concern was sandboxing, so we can run tests from untrusted people. I have no experience setting something like that up, but I'd be very happy if someone else could do it. It would be really nice to not have to run tests after applying a patch (if we're willing to live with the test failures we'd get every now and then due to conflicting changes).
@martinvonz - a reasonable first pass would be to whitelist known contributors for CI runs.
@martinvonz - a reasonable first pass would be to whitelist known contributors for CI runs.
That sounds reasonable. Still not my area of expertise, but I'd be happy to see it done.
mercurial/cmdutil.py | ||
---|---|---|
126–127 | I am happy to change '-Z'. The used the long opt name from git. I am happy either way, but I personally would prefer the git name. |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/cmdutil.py (2 lines) | |||
M | mercurial/help/config.txt (3 lines) | |||
M | mercurial/mdiff.py (5 lines) | |||
M | mercurial/patch.py (1 line) | |||
M | tests/test-completion.t (4 lines) | |||
M | tests/test-diff-ignore-whitespace.t (15 lines) | |||
M | tests/test-help.t (1 line) | |||
M | tests/test-qrecord.t (2 lines) | |||
M | tests/test-record.t (1 line) |
buildopts['index'] = hlen | buildopts['index'] = hlen | ||||
if whitespace: | if whitespace: | ||||
buildopts['ignorews'] = get('ignore_all_space', 'ignorews') | buildopts['ignorews'] = get('ignore_all_space', 'ignorews') | ||||
buildopts['ignorewsamount'] = get('ignore_space_change', | buildopts['ignorewsamount'] = get('ignore_space_change', | ||||
'ignorewsamount') | 'ignorewsamount') | ||||
buildopts['ignoreblanklines'] = get('ignore_blank_lines', | buildopts['ignoreblanklines'] = get('ignore_blank_lines', | ||||
'ignoreblanklines') | 'ignoreblanklines') | ||||
buildopts['ignorewseol'] = get('ignore_space_at_eol', 'ignorewseol') | |||||
if formatchanging: | if formatchanging: | ||||
buildopts['text'] = opts and opts.get('text') | buildopts['text'] = opts and opts.get('text') | ||||
binary = None if opts is None else opts.get('binary') | binary = None if opts is None else opts.get('binary') | ||||
buildopts['nobinary'] = (not binary if binary is not None | buildopts['nobinary'] = (not binary if binary is not None | ||||
else get('nobinary', forceplain=False)) | else get('nobinary', forceplain=False)) | ||||
buildopts['noprefix'] = get('noprefix', forceplain=False) | buildopts['noprefix'] = get('noprefix', forceplain=False) | ||||
return mdiff.diffopts(**pycompat.strkwargs(buildopts)) | return mdiff.diffopts(**pycompat.strkwargs(buildopts)) |
$ hg debugcomplete --options s | $ hg debugcomplete --options s | ||||
hg: command 's' is ambiguous: | hg: command 's' is ambiguous: | ||||
serve showconfig status summary | serve showconfig status summary | ||||
[255] | [255] | ||||
Show all commands + options | Show all commands + options | ||||
$ hg debugcommands | $ hg debugcommands | ||||
add: include, exclude, subrepos, dry-run | 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 | 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 | 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 | export: output, switch-parent, rev, text, git, binary, nodates | ||||
forget: include, exclude | forget: include, exclude | ||||
init: ssh, remotecmd, insecure | init: ssh, remotecmd, insecure | ||||
log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude | log: follow, follow-first, date, copies, keyword, rev, removed, only-merges, user, only-branch, branch, prune, patch, git, limit, no-merges, stat, graph, style, template, include, exclude | ||||
merge: force, rev, preview, tool | merge: force, rev, preview, tool | ||||
pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure | pull: update, force, rev, bookmark, branch, ssh, remotecmd, insecure | ||||
push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure | push: force, rev, bookmark, branch, new-branch, pushvars, ssh, remotecmd, insecure | ||||
remove: after, force, subrepos, include, exclude | remove: after, force, subrepos, include, exclude |
@@ -1,2 +1,3 @@ | @@ -1,2 +1,3 @@ | ||||
-hello world | -hello world | ||||
-goodbye world | -goodbye world | ||||
+hello world\r (esc) | +hello world\r (esc) | ||||
+\r (esc) | +\r (esc) | ||||
+goodbye\r (no-eol) (esc) | +goodbye\r (no-eol) (esc) | ||||
world | world | ||||
Test \r (carriage return) as used in "DOS" line endings: | |||||
$ printf 'hello world \r\n\t\ngoodbye world\n' >foo | |||||
$ hg ndiff --ignore-space-at-eol | |||||
diff -r 540c40a65b78 foo | |||||
--- a/foo | |||||
+++ b/foo | |||||
@@ -1,2 +1,3 @@ | |||||
hello world | |||||
+\t (esc) | |||||
goodbye world | |||||
No completely blank lines to ignore: | No completely blank lines to ignore: | ||||
$ printf 'hello world\r\n\r\ngoodbye\rworld\n' >foo | |||||
$ hg ndiff --ignore-blank-lines | $ hg ndiff --ignore-blank-lines | ||||
diff -r 540c40a65b78 foo | diff -r 540c40a65b78 foo | ||||
--- a/foo | --- a/foo | ||||
+++ b/foo | +++ b/foo | ||||
@@ -1,2 +1,3 @@ | @@ -1,2 +1,3 @@ | ||||
-hello world | -hello world | ||||
-goodbye world | -goodbye world | ||||
+hello world\r (esc) | +hello world\r (esc) |
--binary generate binary diffs in git mode (default) | --binary generate binary diffs in git mode (default) | ||||
--nodates omit dates from diff headers | --nodates omit dates from diff headers | ||||
--noprefix omit a/ and b/ prefixes from filenames | --noprefix omit a/ and b/ prefixes from filenames | ||||
-p --show-function show which function each change is in | -p --show-function show which function each change is in | ||||
--reverse produce a diff that undoes the changes | --reverse produce a diff that undoes the changes | ||||
-w --ignore-all-space ignore white space when comparing lines | -w --ignore-all-space ignore white space when comparing lines | ||||
-b --ignore-space-change ignore changes in the amount of white space | -b --ignore-space-change ignore changes in the amount of white space | ||||
-B --ignore-blank-lines ignore changes whose lines are all blank | -B --ignore-blank-lines ignore changes whose lines are all blank | ||||
-Z --ignore-space-at-eol ignore changes in whitespace at EOL | |||||
-U --unified NUM number of lines of context to show | -U --unified NUM number of lines of context to show | ||||
--stat output diffstat-style summary of changes | --stat output diffstat-style summary of changes | ||||
--root DIR produce diffs relative to subdirectory | --root DIR produce diffs relative to subdirectory | ||||
-I --include PATTERN [+] include names matching the given patterns | -I --include PATTERN [+] include names matching the given patterns | ||||
-X --exclude PATTERN [+] exclude names matching the given patterns | -X --exclude PATTERN [+] exclude names matching the given patterns | ||||
-S --subrepos recurse into subrepositories | -S --subrepos recurse into subrepositories | ||||
(some details hidden, use --verbose to show complete help) | (some details hidden, use --verbose to show complete help) |
-m --message TEXT use text as commit message | -m --message TEXT use text as commit message | ||||
-l --logfile FILE read commit message from file | -l --logfile FILE read commit message from file | ||||
-d --date DATE record the specified date as commit date | -d --date DATE record the specified date as commit date | ||||
-u --user USER record the specified user as committer | -u --user USER record the specified user as committer | ||||
-S --subrepos recurse into subrepositories | -S --subrepos recurse into subrepositories | ||||
-w --ignore-all-space ignore white space when comparing lines | -w --ignore-all-space ignore white space when comparing lines | ||||
-b --ignore-space-change ignore changes in the amount of white space | -b --ignore-space-change ignore changes in the amount of white space | ||||
-B --ignore-blank-lines ignore changes whose lines are all blank | -B --ignore-blank-lines ignore changes whose lines are all blank | ||||
-Z --ignore-space-at-eol ignore changes in whitespace at EOL | |||||
(some details hidden, use --verbose to show complete help) | (some details hidden, use --verbose to show complete help) | ||||
help (no mq, so no qrecord) | help (no mq, so no qrecord) | ||||
$ hg help qrecord | $ hg help qrecord | ||||
hg qrecord [OPTION]... PATCH [FILE]... | hg qrecord [OPTION]... PATCH [FILE]... | ||||
-d --date DATE add "Date: <DATE>" to patch | -d --date DATE add "Date: <DATE>" to patch | ||||
-I --include PATTERN [+] include names matching the given patterns | -I --include PATTERN [+] include names matching the given patterns | ||||
-X --exclude PATTERN [+] exclude names matching the given patterns | -X --exclude PATTERN [+] exclude names matching the given patterns | ||||
-m --message TEXT use text as commit message | -m --message TEXT use text as commit message | ||||
-l --logfile FILE read commit message from file | -l --logfile FILE read commit message from file | ||||
-w --ignore-all-space ignore white space when comparing lines | -w --ignore-all-space ignore white space when comparing lines | ||||
-b --ignore-space-change ignore changes in the amount of white space | -b --ignore-space-change ignore changes in the amount of white space | ||||
-B --ignore-blank-lines ignore changes whose lines are all blank | -B --ignore-blank-lines ignore changes whose lines are all blank | ||||
-Z --ignore-space-at-eol ignore changes in whitespace at EOL | |||||
--mq operate on patch repository | --mq operate on patch repository | ||||
(some details hidden, use --verbose to show complete help) | (some details hidden, use --verbose to show complete help) | ||||
$ cd a | $ cd a | ||||
Base commit | Base commit | ||||
-m --message TEXT use text as commit message | -m --message TEXT use text as commit message | ||||
-l --logfile FILE read commit message from file | -l --logfile FILE read commit message from file | ||||
-d --date DATE record the specified date as commit date | -d --date DATE record the specified date as commit date | ||||
-u --user USER record the specified user as committer | -u --user USER record the specified user as committer | ||||
-S --subrepos recurse into subrepositories | -S --subrepos recurse into subrepositories | ||||
-w --ignore-all-space ignore white space when comparing lines | -w --ignore-all-space ignore white space when comparing lines | ||||
-b --ignore-space-change ignore changes in the amount of white space | -b --ignore-space-change ignore changes in the amount of white space | ||||
-B --ignore-blank-lines ignore changes whose lines are all blank | -B --ignore-blank-lines ignore changes whose lines are all blank | ||||
-Z --ignore-space-at-eol ignore changes in whitespace at EOL | |||||
(some details hidden, use --verbose to show complete help) | (some details hidden, use --verbose to show complete help) | ||||
Select no files | Select no files | ||||
$ touch empty-rw | $ touch empty-rw | ||||
$ hg add empty-rw | $ hg add empty-rw | ||||
Regular diff chose -Z for the short option