mercurial/repair.py
changeset 31626 0febf8e4e2ce
parent 31324 e712a9c35fd8
child 31645 7095e783958d
--- a/mercurial/repair.py	Fri Mar 24 19:52:43 2017 -0700
+++ b/mercurial/repair.py	Thu Mar 23 23:47:23 2017 -0400
@@ -214,15 +214,10 @@
 
         for m in updatebm:
             bm[m] = repo[newbmtarget].node()
-        lock = tr = None
-        try:
-            lock = repo.lock()
-            tr = repo.transaction('repair')
-            bm.recordchange(tr)
-            tr.close()
-        finally:
-            tr.release()
-            lock.release()
+
+        with repo.lock():
+            with repo.transaction('repair') as tr:
+                bm.recordchange(tr)
 
         # remove undo files
         for undovfs, undofile in repo.undofiles():