# HG changeset patch # User Bryan O'Sullivan # Date 2016-01-15 21:14:46 # Node ID a5eae47aa1f895efff95898fda3f8a0dae0b1502 # Parent bdaf433192f0395a2e81cd9fe94c494ee11ab152 with: use context manager for wlock in debugrebuilddirstate diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3124,8 +3124,7 @@ def debugrebuilddirstate(ui, repo, rev, 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 @@ def debugrebuilddirstate(ui, repo, rev, changedfiles = manifestonly | dsnotadded dirstate.rebuild(ctx.node(), ctx.manifest(), changedfiles) - finally: - wlock.release() @command('debugrebuildfncache', [], '') def debugrebuildfncache(ui, repo):