Mercurial > public > mercurial-scm > hg-stable
diff mercurial/cmdutil.py @ 33616:5ac845ca059a stable
commit: don't let failed commit with --addremove update dirstate (issue5645)
Differential Revision: https://phab.mercurial-scm.org/D204
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 31 Jul 2017 14:54:57 -0700 |
parents | 4cd4344a53c4 |
children | 377e8ddaebef 86aca74a063b |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Mon Jul 31 14:54:08 2017 -0700 +++ b/mercurial/cmdutil.py Mon Jul 31 14:54:57 2017 -0700 @@ -26,6 +26,7 @@ changelog, copies, crecord as crecordmod, + dirstateguard, encoding, error, formatter, @@ -2888,14 +2889,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():