D5834: commit/revert: if interactive, look elsewhere for whitespace settings (BC)
spectral (Kyle Lippincott)
phabricator at mercurial-scm.org
Mon Feb 4 20:39:36 UTC 2019
spectral created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Previously, when doing `commit -i`, we respected `diff.ignorews` and other
whitespace-related settings, which is probably unexpected. The primary reason
for this is to support hgext.record's commandline options, it's probably
accidental that the `[diff]` settings were also considered. See comments on
issue6042 and https://phab.mercurial-scm.org/D5490. This can cause problems (issue5839, issue6042).
It is assumed by the author that the `[diff]` section is primarily for *viewing*
diffs, and that it is unlikely what people intend when attempting to commit or
revert.
With this change, if a user wants the behavior, they can clone their `[diff]`
settings to `commands.commit.interactive.<setting>`. This is thus a mild BC
change, but one I suspect is not going to be relied on by anyone.
Note: while doing a partial commit/revert, we do not know what command the user
is actually running. This means that the split extension, which ends up calling
into this code, will respect the `commands.commit.interactive.<setting>`
settings, and not a hypothetical `commands.split.interactive.<setting>`. This
*also* means that setting `commands.commit.interactive.ignoreblanklines`, for
example, will still cause issue5839. Considering the highly unlikely chance that
a user actually sets `commands.commit.interactive.<setting>`, the author deems
this risk acceptable.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D5834
AFFECTED FILES
mercurial/cmdutil.py
mercurial/configitems.py
CHANGE DETAILS
diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -201,6 +201,7 @@
coreconfigitem('color', 'pagermode',
default=dynamicdefault,
)
+_registerdiffopts(section='commands', configprefix='commit.interactive.')
coreconfigitem('commands', 'grep.all-files',
default=False,
)
@@ -213,6 +214,7 @@
coreconfigitem('commands', 'resolve.mark-check',
default='none',
)
+_registerdiffopts(section='commands', configprefix='revert.interactive.')
coreconfigitem('commands', 'show.aliasprefix',
default=list,
)
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -282,7 +282,9 @@
status = repo.status(match=match)
if not force:
repo.checkcommitpatterns(wctx, vdirs, match, status, fail)
- diffopts = patch.difffeatureopts(ui, opts=opts)
+ diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True,
+ section='commands',
+ configprefix='commit.interactive.')
diffopts.nodates = True
diffopts.git = True
diffopts.showfunc = True
@@ -3126,7 +3128,9 @@
# Prompt the user for changes to revert
torevert = [f for f in actions['revert'][0] if f not in excluded_files]
m = scmutil.matchfiles(repo, torevert)
- diffopts = patch.difffeatureopts(repo.ui)
+ diffopts = patch.difffeatureopts(repo.ui, whitespace=True,
+ section='commands',
+ configprefix='revert.interactive.')
diffopts.nodates = True
diffopts.git = True
operation = 'discard'
To: spectral, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list