mercurial/cmdutil.py
branchstable
changeset 41977 4ea21df312ec
parent 41206 6acbe86c6490
child 41985 b1bc6e5f5249
equal deleted inserted replaced
41975:406519302520 41977: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