changeset 38446:e219e355e088

censor: use context manager for lock management
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 24 Mar 2017 00:32:31 -0400
parents 3813c6b7337c
children 36edfbac7281
files hgext/censor.py
diffstat 1 files changed, 1 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/censor.py	Thu Jun 21 22:33:42 2018 +0900
+++ b/hgext/censor.py	Fri Mar 24 00:32:31 2017 -0400
@@ -32,7 +32,6 @@
 
 from mercurial import (
     error,
-    lock as lockmod,
     registrar,
     revlog,
     scmutil,
@@ -52,13 +51,8 @@
      ('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: