changeset 1024:9d538ebf3985

evolve: add a tr arguement to retractboundary Mercurial core is adding a transaction argument to its phase movement function. We do the same. If Mercurial appears to be an old version (without the extra args) we call it the old way.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 06 Aug 2014 17:05:57 -0700
parents 7c8e3941241f
children 0fcddde7dae6
files hgext/evolve.py
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/evolve.py	Wed Aug 06 18:10:00 2014 -0700
+++ b/hgext/evolve.py	Wed Aug 06 17:05:57 2014 -0700
@@ -96,8 +96,12 @@
 #####################################################################
 
 
-def retractboundary(repo, targetphase, nodes):
-    return phases.retractboundary(repo, targetphase, nodes)
+def retractboundary(repo, tr, targetphase, nodes):
+    """Older mercurial version does not move phase within a transaction"""
+    try:
+        return phases.retractboundary(repo, tr, targetphase, nodes)
+    except TypeError:
+        return phases.retractboundary(repo, targetphase, nodes)
 
 
 #####################################################################
@@ -870,7 +874,7 @@
             raise
         oldbookmarks = repo.nodebookmarks(nodesrc)
         if nodenew is not None:
-            retractboundary(repo, destphase, [nodenew])
+            retractboundary(repo, tr, destphase, [nodenew])
             createmarkers(repo, [(repo[nodesrc], (repo[nodenew],))])
             for book in oldbookmarks:
                 repo._bookmarks[book] = nodenew
@@ -1463,7 +1467,7 @@
             createmarkers(repo, [(tmpctx, ())])
             newid = prec.node()
         else:
-            retractboundary(repo, bumped.phase(), [newid])
+            retractboundary(repo, tr, bumped.phase(), [newid])
             createmarkers(repo, [(tmpctx, (repo[newid],))],
                                    flag=obsolete.bumpedfix)
         bmupdate(newid)
@@ -1568,7 +1572,7 @@
         else:
             new = repo['.']
         createmarkers(repo, [(other, (new,))])
-        retractboundary(repo, other.phase(), [new.node()])
+        retractboundary(repo, tr, other.phase(), [new.node()])
         tr.close()
     finally:
         tr.release()
@@ -1969,7 +1973,7 @@
                              hint=_("use --all to uncommit all files"))
         # Move local changes on filtered changeset
         createmarkers(repo, [(old, (repo[newid],))])
-        retractboundary(repo, oldphase, [newid])
+        retractboundary(repo, tr, oldphase, [newid])
         repo.dirstate.setparents(newid, node.nullid)
         _uncommitdirstate(repo, old, match)
         updatebookmarks(newid)
@@ -2055,7 +2059,7 @@
                 newmapping[ctx.node()] = new
                 if not duplicate:
                     createmarkers(repo, [(ctx, (repo[new],))])
-                retractboundary(repo, ctx.phase(), [new])
+                retractboundary(repo, tr, ctx.phase(), [new])
                 if ctx in repo[None].parents():
                     repo.dirstate.setparents(new, node.nullid)
             tr.close()
@@ -2158,7 +2162,7 @@
             newid, unusedvariable = rewrite(repo, root, allctx, head,
                                             [root.p1().node(), root.p2().node()],
                                             commitopts=commitopts)
-            retractboundary(repo, targetphase, [newid])
+            retractboundary(repo, tr, targetphase, [newid])
             createmarkers(repo, [(ctx, (repo[newid],))
                                  for ctx in allctx])
             tr.close()