changeset 1593:2f117c299325

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 23 Jan 2016 06:18:01 +0900
parents f157ef7b1741
children de43a3e6b358
files hgext/evolve.py
diffstat 1 files changed, 8 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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