# HG changeset patch # User Martin von Zweigbergk # Date 1555695152 25200 # Node ID f6b9c409c12e75c8420b43242f85009c994c0e82 # Parent e489c10add3735411ed07579b0ec0bc774a36f3e evolve: use context manager for transactions diff -r e489c10add37 -r f6b9c409c12e hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Fri Apr 19 10:52:16 2019 -0700 +++ b/hgext3rd/evolve/evolvecmd.py Fri Apr 19 10:32:32 2019 -0700 @@ -1882,16 +1882,11 @@ # no backup of evolved cset versions needed repair.strip(repo.ui, repo, strippoints, False) - tr = None - try: - tr = repo.transaction('evolve') + with repo.transaction('evolve') as tr: # restoring bookmarks at there original place bmchanges = evolvestate['bookmarkchanges'] if bmchanges: repo._bookmarks.applychanges(repo, tr, bmchanges) - tr.close() - finally: - tr.release() evolvestate.delete() ui.status(_('evolve aborted\n')) @@ -1957,9 +1952,7 @@ def _continuecontentdivergent(ui, repo, evolvestate, progresscb): """function to continue the interrupted content-divergence resolution.""" - tr = None - try: - tr = repo.transaction('evolve') + with repo.transaction('evolve'): divergent = evolvestate['divergent'] base = evolvestate['base'] repo = repo.unfiltered() @@ -2002,10 +1995,7 @@ prec = repo[publicnode] bumped = repo[newnode] ret = _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped) - tr.close() return ret - finally: - tr.release() def _completephasedivergent(ui, repo, evolvestate): """function to complete the interrupted phase-divergence resolution. @@ -2013,10 +2003,8 @@ First completes the relocation of the commit and then process resolving phase-divergence""" - tr = None - try: - # need to start transaction for bookmark changes - tr = repo.transaction('evolve') + # need to start transaction for bookmark changes + with repo.transaction('evolve'): node = _completerelocation(ui, repo, evolvestate) evolvestate['temprevs'].append(node) # resolving conflicts can lead to empty wdir and node can be None in @@ -2029,9 +2017,6 @@ prec = repo[evolvestate['precursor']] retvalue = _resolvephasedivergent(ui, repo, prec, newctx) evolvestate['replacements'][ctx.node()] = retvalue[1] - tr.close() - finally: - tr.release() def _completeorphan(ui, repo, evolvestate): """function to complete the interrupted orphan resolution"""