# HG changeset patch # User Matt Harbison # Date 2017-03-24 04:32:31 # Node ID e219e355e0889f6f91b2266a49b3593f71de89c9 # Parent 3813c6b7337c9aadac7a5ff5f03ae3ea3d61da9b censor: use context manager for lock management diff --git a/hgext/censor.py b/hgext/censor.py --- a/hgext/censor.py +++ b/hgext/censor.py @@ -32,7 +32,6 @@ from mercurial.node import short from mercurial import ( error, - lock as lockmod, registrar, revlog, scmutil, @@ -52,13 +51,8 @@ testedwith = 'ships-with-hg-core' ('t', 'tombstone', '', _('replacement tombstone data'), _('TEXT'))], _('-r REV [-t TEXT] [FILE]')) def censor(ui, repo, path, rev='', tombstone='', **opts): - wlock = lock = None - try: - wlock = repo.wlock() - lock = repo.lock() + with repo.wlock(), repo.lock(): return _docensor(ui, repo, path, rev, tombstone, **opts) - finally: - lockmod.release(lock, wlock) def _docensor(ui, repo, path, rev='', tombstone='', **opts): if not path: