--- a/mercurial/cmdutil.py Wed Aug 02 19:49:57 2017 +0200
+++ b/mercurial/cmdutil.py Thu Aug 10 14:23:41 2017 -0400
@@ -26,6 +26,7 @@
changelog,
copies,
crecord as crecordmod,
+ dirstateguard,
encoding,
error,
formatter,
@@ -2889,14 +2890,23 @@
message = logmessage(ui, opts)
matcher = scmutil.match(repo[None], pats, opts)
+ dsguard = None
# extract addremove carefully -- this function can be called from a command
# that doesn't support addremove
- if opts.get('addremove'):
- if scmutil.addremove(repo, matcher, "", opts) != 0:
- raise error.Abort(
- _("failed to mark all new/missing files as added/removed"))
-
- return commitfunc(ui, repo, message, matcher, opts)
+ try:
+ if opts.get('addremove'):
+ dsguard = dirstateguard.dirstateguard(repo, 'commit')
+ if scmutil.addremove(repo, matcher, "", opts) != 0:
+ raise error.Abort(
+ _("failed to mark all new/missing files as added/removed"))
+
+ r = commitfunc(ui, repo, message, matcher, opts)
+ if dsguard:
+ dsguard.close()
+ return r
+ finally:
+ if dsguard:
+ dsguard.release()
def samefile(f, ctx1, ctx2):
if f in ctx1.manifest():