with: use context manager for transaction in qimport
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:47 -0800
changeset 27865 f6979b8f33c1
parent 27864 4b8e3ffee94f
child 27866 f54bf1f41566
with: use context manager for transaction in qimport
hgext/mq.py
--- a/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
+++ b/hgext/mq.py	Fri Jan 15 13:14:47 2016 -0800
@@ -2079,8 +2079,7 @@
                 lastparent = None
 
             diffopts = self.diffopts({'git': git})
-            tr = repo.transaction('qimport')
-            try:
+            with repo.transaction('qimport') as tr:
                 for r in rev:
                     if not repo[r].mutable():
                         raise error.Abort(_('revision %d is not mutable') % r,
@@ -2121,9 +2120,6 @@
                     self.parseseries()
                     self.applieddirty = True
                     self.seriesdirty = True
-                tr.close()
-            finally:
-                tr.release()
 
         for i, filename in enumerate(files):
             if existing: