changeset 27840:dc237afacbd4

with: use context manager for wlock in transplant
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:47 -0800
parents 7ec3cb246291
children 83995fdde225
files hgext/transplant.py
diffstat 1 files changed, 1 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/transplant.py	Fri Jan 15 13:14:47 2016 -0800
+++ b/hgext/transplant.py	Fri Jan 15 13:14:47 2016 -0800
@@ -20,7 +20,6 @@
 from mercurial import bundlerepo, hg, merge, match
 from mercurial import patch, revlog, scmutil, util, error, cmdutil
 from mercurial import revset, templatekw, exchange
-from mercurial import lock as lockmod
 
 class TransplantError(error.Abort):
     pass
@@ -575,12 +574,8 @@
     and then resume where you left off by calling :hg:`transplant
     --continue/-c`.
     '''
-    wlock = None
-    try:
-        wlock = repo.wlock()
+    with repo.wlock():
         return _dotransplant(ui, repo, *revs, **opts)
-    finally:
-        lockmod.release(wlock)
 
 def _dotransplant(ui, repo, *revs, **opts):
     def incwalk(repo, csets, match=util.always):