changeset 27863:ed59ae8b025e

with: use context manager for transaction in mercurial_sink
author Bryan O'Sullivan <bryano@fb.com>
date Fri, 15 Jan 2016 13:14:47 -0800
parents b2145c195f24
children 4b8e3ffee94f
files hgext/convert/hg.py
diffstat 1 files changed, 1 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/convert/hg.py	Fri Jan 15 13:14:47 2016 -0800
+++ b/hgext/convert/hg.py	Fri Jan 15 13:14:47 2016 -0800
@@ -323,9 +323,7 @@
             self.repo.ui.setconfig('phases', 'new-commit',
                                    phases.phasenames[commit.phase], 'convert')
 
-            tr = self.repo.transaction("convert")
-
-            try:
+            with self.repo.transaction("convert") as tr:
                 node = hex(self.repo.commitctx(ctx))
 
                 # If the node value has changed, but the phase is lower than
@@ -336,9 +334,6 @@
                     if ctx.phase() < phases.draft:
                         phases.retractboundary(self.repo, tr, phases.draft,
                                                [ctx.node()])
-                tr.close()
-            finally:
-                tr.release()
 
             text = "(octopus merge fixup)\n"
             p2 = node