changeset 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 42ad7cc645a4
children 158dddc635ff
files mercurial/cmdutil.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Wed Aug 16 00:25:20 2017 +0530
+++ b/mercurial/cmdutil.py	Mon Aug 14 23:26:51 2017 -0700
@@ -2998,9 +2998,10 @@
     dsguard = None
     # extract addremove carefully -- this function can be called from a command
     # that doesn't support addremove
+    if opts.get('addremove'):
+        dsguard = dirstateguard.dirstateguard(repo, 'commit')
     try:
-        if opts.get('addremove'):
-            dsguard = dirstateguard.dirstateguard(repo, 'commit')
+        if dsguard:
             if scmutil.addremove(repo, matcher, "", opts) != 0:
                 raise error.Abort(
                     _("failed to mark all new/missing files as added/removed"))