with: use context manager for wlock in sign
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:46 -0800
changeset 27814 a72735028336
parent 27813 ff20fe74e5c6
child 27815 16cfbbc69800
with: use context manager for wlock in sign
hgext/gpg.py
--- a/hgext/gpg.py	Fri Jan 15 13:14:46 2016 -0800
+++ b/hgext/gpg.py	Fri Jan 15 13:14:46 2016 -0800
@@ -9,7 +9,6 @@
 from mercurial import util, commands, match, cmdutil, error
 from mercurial import node as hgnode
 from mercurial.i18n import _
-from mercurial import lock as lockmod
 
 cmdtable = {}
 command = cmdutil.command(cmdtable)
@@ -223,12 +222,8 @@
 
     See :hg:`help dates` for a list of formats valid for -d/--date.
     """
-    wlock = None
-    try:
-        wlock = repo.wlock()
+    with repo.wlock():
         return _dosign(ui, repo, *revs, **opts)
-    finally:
-        lockmod.release(wlock)
 
 def _dosign(ui, repo, *revs, **opts):
     mygpg = newgpg(ui, **opts)