diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -983,14 +983,11 @@ def _markchanges(repo, unknown, deleted, '''Marks the files in unknown as added, the files in deleted as removed, and the files in renames as copied.''' wctx = repo[None] - wlock = repo.wlock() - try: + with repo.wlock(): wctx.forget(deleted) wctx.add(unknown) for new, old in renames.iteritems(): wctx.copy(old, new) - finally: - wlock.release() def dirstatecopy(ui, repo, wctx, src, dst, dryrun=False, cwd=None): """Update the dirstate to reflect the intent of copying src to dst. For