# HG changeset patch # User FUJIWARA Katsunori # Date 1453497481 -32400 # Node ID 2f117c29932597d6771d50c6d565011d0992f5a3 # Parent f157ef7b17411553e100089245c43c0a4bbe41b1 evolve: remove meaningless transaction nesting Before this patch, functions below nest transaction scope, even though they are invoked only inside a transaction scope created at _solveone(). - _solvebumped() - _solvedivergent() - relocate() via _solveunstable() or _solvebumped() Transaction nesting is useful for localizing "success" (e.g. one scope per commit inside wider scope for multiple committing). But such nesting is redundant for _solveone(), because there is no code path, which causes failure after successfully closing inner transaction(s). In addition to it, this nesting makes it complicated to close current transaction successfully with exception raising inside inner scope, like "hg shelve" at detection of conflicts. "tr.close()" is required at each outer scopes for such case. To remove meaningless transaction nesting, this patch replaces repo.transaction() in functions above by repo.currenttransaction(). This reuses transaction created at _solveone(). This patch also adds 'assert tr' after getting current running transaction, to avoid invocation of functions above without transaction. diff -r f157ef7b1741 -r 2f117c299325 hgext/evolve.py --- a/hgext/evolve.py Tue Jan 26 15:42:01 2016 -0800 +++ b/hgext/evolve.py Sat Jan 23 06:18:01 2016 +0900 @@ -946,7 +946,8 @@ repo.ui.note(_('The stale commit message reference to %s could ' 'not be updated\n') % sha1) - tr = repo.transaction('relocate') + tr = repo.currenttransaction() + assert tr is not None try: try: r = _evolvemerge(repo, orig, dest, pctx, keepbranch) @@ -967,9 +968,8 @@ raise oldbookmarks = repo.nodebookmarks(nodesrc) _finalizerelocate(repo, orig, dest, nodenew, tr) - tr.close() finally: - tr.release() + pass # TODO: remove this redundant try/finally block return nodenew def _bookmarksupdater(repo, oldid, tr): @@ -1839,7 +1839,8 @@ newid = tmpctx = None tmpctx = bumped # Basic check for common parent. Far too complicated and fragile - tr = repo.transaction('bumped-stabilize') + tr = repo.currenttransaction() + assert tr is not None bmupdate = _bookmarksupdater(repo, bumped.node(), tr) try: if not list(repo.set('parents(%d) and parents(%d)', bumped, prec)): @@ -1905,10 +1906,9 @@ obsolete.createmarkers(repo, [(tmpctx, (repo[newid],))], flag=obsolete.bumpedfix) bmupdate(newid) - tr.close() repo.ui.status(_('committed as %s\n') % node.short(newid)) finally: - tr.release() + pass # TODO: remove this redundant try/finally block # reroute the working copy parent to the new changeset repo.dirstate.beginparentchange() repo.dirstate.setparents(newid, node.nullid) @@ -2017,7 +2017,8 @@ """) if progresscb: progresscb() emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit') - tr = repo.transaction('stabilize-divergent') + tr = repo.currenttransaction() + assert tr is not None try: repo.ui.setconfig('ui', 'allowemptycommit', True) repo.dirstate.beginparentchange() @@ -2032,10 +2033,8 @@ new = repo['.'] obsolete.createmarkers(repo, [(other, (new,))]) phases.retractboundary(repo, tr, other.phase(), [new.node()]) - tr.close() finally: repo.ui.restoreconfig(emtpycommitallowed) - tr.release() def divergentdata(ctx): """return base, other part of a conflict