with: use context manager for transaction in pushphase
authorBryan O'Sullivan <bryano@fb.com>
Fri, 15 Jan 2016 13:14:49 -0800
changeset 27874 4ff0e2347ae6
parent 27873 60ea60fea5f3
child 27875 add2ba16430e
with: use context manager for transaction in pushphase
mercurial/phases.py
--- a/mercurial/phases.py	Fri Jan 15 13:14:49 2016 -0800
+++ b/mercurial/phases.py	Fri Jan 15 13:14:49 2016 -0800
@@ -409,12 +409,8 @@
         newphase = abs(int(newphasestr)) # let's avoid negative index surprise
         oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise
         if currentphase == oldphase and newphase < oldphase:
-            try:
-                tr = repo.transaction('pushkey-phase')
+            with repo.transaction('pushkey-phase') as tr:
                 advanceboundary(repo, tr, newphase, [bin(nhex)])
-                tr.close()
-            finally:
-                tr.release()
             return 1
         elif currentphase == newphase:
             # raced, but got correct result