Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 41330:4ea21df312ec stable 4.9.1
record: prevent commits that don't pick up dirty subrepo changes (issue6102)
This path covers interactive mode for commit, amend, and shelve, as well as the
deprecated record extension. Since shelf creation uses commit without -S in the
non-interactive case, aborting here should be OK. (I didn't check what happens
to non interactive shelve creation if `ui.commitsubrepos=True` is set.)
subrepoutil.precommit() will abort on a dirty subrepo if the config option isn't
set, but the hint recommends using --subrepos to commit. Since only the commit
command currently supports that option, the error has to be raised here to omit
the hint.
Doing the check before asking about all of the hunks in the MQ test seems like
an improvement on its own. There's probably an additional check on this path
that can be removed.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 16 Mar 2019 14:40:21 -0400 |
parents | 6acbe86c6490 |
children | b1bc6e5f5249 |
comparison
equal
deleted
inserted
replaced
41329:406519302520 | 41330:4ea21df312ec |
---|---|
5 # This software may be used and distributed according to the terms of the | 5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. | 6 # GNU General Public License version 2 or any later version. |
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import copy as copymod | |
10 import errno | 11 import errno |
11 import os | 12 import os |
12 import re | 13 import re |
13 | 14 |
14 from .i18n import _ | 15 from .i18n import _ |
268 merge = len(wctx.parents()) > 1 | 269 merge = len(wctx.parents()) > 1 |
269 if merge: | 270 if merge: |
270 raise error.Abort(_('cannot partially commit a merge ' | 271 raise error.Abort(_('cannot partially commit a merge ' |
271 '(use "hg commit" instead)')) | 272 '(use "hg commit" instead)')) |
272 | 273 |
274 status = repo.status(match=match) | |
275 | |
276 overrides = {(b'ui', b'commitsubrepos'): True} | |
277 | |
278 with repo.ui.configoverride(overrides, b'record'): | |
279 # subrepoutil.precommit() modifies the status | |
280 tmpstatus = scmutil.status(copymod.copy(status[0]), | |
281 copymod.copy(status[1]), | |
282 copymod.copy(status[2]), | |
283 copymod.copy(status[3]), | |
284 copymod.copy(status[4]), | |
285 copymod.copy(status[5]), | |
286 copymod.copy(status[6])) | |
287 | |
288 # Force allows -X subrepo to skip the subrepo. | |
289 subs, commitsubs, newstate = subrepoutil.precommit( | |
290 repo.ui, wctx, tmpstatus, match, force=True) | |
291 for s in subs: | |
292 if s in commitsubs: | |
293 dirtyreason = wctx.sub(s).dirtyreason(True) | |
294 raise error.Abort(dirtyreason) | |
295 | |
273 def fail(f, msg): | 296 def fail(f, msg): |
274 raise error.Abort('%s: %s' % (f, msg)) | 297 raise error.Abort('%s: %s' % (f, msg)) |
275 | 298 |
276 force = opts.get('force') | 299 force = opts.get('force') |
277 if not force: | 300 if not force: |
278 vdirs = [] | 301 vdirs = [] |
279 match.explicitdir = vdirs.append | 302 match.explicitdir = vdirs.append |
280 match.bad = fail | 303 match.bad = fail |
281 | 304 |
282 status = repo.status(match=match) | |
283 if not force: | 305 if not force: |
284 repo.checkcommitpatterns(wctx, vdirs, match, status, fail) | 306 repo.checkcommitpatterns(wctx, vdirs, match, status, fail) |
285 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) | 307 diffopts = patch.difffeatureopts(ui, opts=opts, whitespace=True) |
286 diffopts.nodates = True | 308 diffopts.nodates = True |
287 diffopts.git = True | 309 diffopts.git = True |