evolve: have dirstate collaborate with transaction
authorPierre-Yves David <pierre-yves.david@fb.com>
Fri, 30 Oct 2015 16:04:19 +0000
changeset 1514 324cd13838f1
parent 1513 4f7e0e0318a5
child 1515 9729fdcc1fab
evolve: have dirstate collaborate with transaction With 3.6, dirstate update can work with transaction to ensure proper rollback. We do it if the mercurial version permit it.
README
hgext/evolve.py
--- a/README	Fri Oct 09 16:21:30 2015 -0700
+++ b/README	Fri Oct 30 16:04:19 2015 +0000
@@ -55,6 +55,7 @@
 
 - split: add a new command to split changesets
 - add some progress data during changesets discovery
+- take advantage of dirstate/transaction collaboration
 
 5.2.1 --
 
--- a/hgext/evolve.py	Fri Oct 09 16:21:30 2015 -0700
+++ b/hgext/evolve.py	Fri Oct 30 16:04:19 2015 +0000
@@ -961,7 +961,7 @@
         except util.Abort, exc:
             repo.dirstate.beginparentchange()
             repo.setparents(repo['.'].node(), nullid)
-            repo.dirstate.write()
+            writedirstate(repo.dirstate, tr)
             # fix up dirstate for copies and renames
             copies.duplicatecopies(repo, dest.rev(), orig.p1().rev())
             repo.dirstate.endparentchange()
@@ -1022,6 +1022,15 @@
     except AttributeError:
         return repo._bookmarkcurrent
 
+### dirstate compatibility layer < hg 3.6
+
+def writedirstate(dirstate, tr):
+    if dirstate.write.func_defaults is not None: # mercurial 3.6 and above
+        return dirstate.write(tr)
+    return dirstate.write()
+
+
+
 ### new command
 #############################
 metadataopts = [