Mercurial > evolve
changeset 4593:f6b9c409c12e
evolve: use context manager for transactions
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 19 Apr 2019 10:32:32 -0700 |
parents | e489c10add37 |
children | fed1435757ba |
files | hgext3rd/evolve/evolvecmd.py |
diffstat | 1 files changed, 4 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- 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"""