mercurial/cmdutil.py
changeset 33823 5d286eb7009f
parent 33783 db6b666ce1e6
child 33824 158dddc635ff
--- 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"))