diff -r bdaf433192f0 -r a5eae47aa1f8 mercurial/commands.py --- a/mercurial/commands.py Fri Jan 15 13:14:46 2016 -0800 +++ b/mercurial/commands.py Fri Jan 15 13:14:46 2016 -0800 @@ -3124,8 +3124,7 @@ check the actual file content. """ ctx = scmutil.revsingle(repo, rev) - wlock = repo.wlock() - try: + with repo.wlock(): dirstate = repo.dirstate changedfiles = None # See command doc for what minimal does. @@ -3138,8 +3137,6 @@ changedfiles = manifestonly | dsnotadded dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) - finally: - wlock.release() @command('debugrebuildfncache', [], '') def debugrebuildfncache(ui, repo):