Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 41574:66399f2e92aa
commit: if interactive, look elsewhere for whitespace settings (BC)
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 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.
Differential Revision: https://phab.mercurial-scm.org/D5834
author | Kyle Lippincott <spectral@google.com> |
---|---|
date | Thu, 31 Jan 2019 14:47:34 -0800 |
parents | 3a01ce246ece |
children | 15f63ac122ea |
comparison
equal
deleted
inserted
replaced
41573:78b270a55dc6 | 41574:66399f2e92aa |
---|---|
280 match.bad = fail | 280 match.bad = fail |
281 | 281 |
282 status = repo.status(match=match) | 282 status = repo.status(match=match) |
283 if not force: | 283 if not force: |
284 repo.checkcommitpatterns(wctx, vdirs, match, status, fail) | 284 repo.checkcommitpatterns(wctx, vdirs, match, status, fail) |
285 diffopts = patch.difffeatureopts(ui, opts=opts) | 285 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True, |
286 section='commands', | |
287 configprefix='commit.interactive.') | |
286 diffopts.nodates = True | 288 diffopts.nodates = True |
287 diffopts.git = True | 289 diffopts.git = True |
288 diffopts.showfunc = True | 290 diffopts.showfunc = True |
289 originaldiff = patch.diff(repo, changes=status, opts=diffopts) | 291 originaldiff = patch.diff(repo, changes=status, opts=diffopts) |
290 originalchunks = patch.parsepatch(originaldiff) | 292 originalchunks = patch.parsepatch(originaldiff) |
3124 newlyaddedandmodifiedfiles = set() | 3126 newlyaddedandmodifiedfiles = set() |
3125 if interactive: | 3127 if interactive: |
3126 # Prompt the user for changes to revert | 3128 # Prompt the user for changes to revert |
3127 torevert = [f for f in actions['revert'][0] if f not in excluded_files] | 3129 torevert = [f for f in actions['revert'][0] if f not in excluded_files] |
3128 m = scmutil.matchfiles(repo, torevert) | 3130 m = scmutil.matchfiles(repo, torevert) |
3129 diffopts = patch.difffeatureopts(repo.ui) | 3131 diffopts = patch.difffeatureopts(repo.ui, whitespace=True, |
3132 section='commands', | |
3133 configprefix='revert.interactive.') | |
3130 diffopts.nodates = True | 3134 diffopts.nodates = True |
3131 diffopts.git = True | 3135 diffopts.git = True |
3132 operation = 'discard' | 3136 operation = 'discard' |
3133 reversehunks = True | 3137 reversehunks = True |
3134 if node != parent: | 3138 if node != parent: |