comparison mercurial/cmdutil.py @ 33823:5d286eb7009f

commit: move dirstateguard creation out of try-block This is just a simple refactoring to make the next patch simpler. If the dirstateguard constructor raises an exception, the finally-block won't do anything anyway, so this is functionally equivalent (and there is no except-block). Differential Revision: https://phab.mercurial-scm.org/D405
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 14 Aug 2017 23:26:51 -0700
parents db6b666ce1e6
children 158dddc635ff
comparison
equal deleted inserted replaced
33822:42ad7cc645a4 33823:5d286eb7009f
2996 matcher = scmutil.match(repo[None], pats, opts) 2996 matcher = scmutil.match(repo[None], pats, opts)
2997 2997
2998 dsguard = None 2998 dsguard = None
2999 # extract addremove carefully -- this function can be called from a command 2999 # extract addremove carefully -- this function can be called from a command
3000 # that doesn't support addremove 3000 # that doesn't support addremove
3001 if opts.get('addremove'):
3002 dsguard = dirstateguard.dirstateguard(repo, 'commit')
3001 try: 3003 try:
3002 if opts.get('addremove'): 3004 if dsguard:
3003 dsguard = dirstateguard.dirstateguard(repo, 'commit')
3004 if scmutil.addremove(repo, matcher, "", opts) != 0: 3005 if scmutil.addremove(repo, matcher, "", opts) != 0:
3005 raise error.Abort( 3006 raise error.Abort(
3006 _("failed to mark all new/missing files as added/removed")) 3007 _("failed to mark all new/missing files as added/removed"))
3007 3008
3008 r = commitfunc(ui, repo, message, matcher, opts) 3009 r = commitfunc(ui, repo, message, matcher, opts)