hgext/mq.py
changeset 27832 1e38b9d731c4
parent 27831 62f3126ef678
child 27847 71853c0ba592
--- a/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
+++ b/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
@@ -2316,8 +2316,7 @@
 
     Returns 0 if import succeeded.
     """
-    lock = repo.lock() # cause this may move phase
-    try:
+    with repo.lock(): # cause this may move phase
         q = repo.mq
         try:
             imported = q.qimport(
@@ -2326,8 +2325,6 @@
                 rev=opts.get('rev'), git=opts.get('git'))
         finally:
             q.savedirty()
-    finally:
-        lock.release()
 
     if imported and opts.get('push') and not opts.get('rev'):
         return q.push(repo, imported[-1])