evolve: store the obsmarkers to be deleted in evolvestate
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 11 Jun 2018 20:13:36 +0530
changeset 3831 987e335dbe11
parent 3830 e0a20dc69126
child 3832 fb821ed44f86
evolve: store the obsmarkers to be deleted in evolvestate Sometimes, we don't create a new node and obsolete one of the old node in favour of an existing node. When user calls, `hg evolve --abort`, we need to strip that obsmarker to go back in the same old state. The obsmarker created for new node are stripped when the new nodes are stripped. This patch start storing such obsmarkers in the evolvestate so that we can delete them later if required. Right now we just store successsor and predecessor information, we might need a better obsmarker serialization techinque in future to make it more robust.
hgext3rd/evolve/evolvecmd.py
--- a/hgext3rd/evolve/evolvecmd.py	Mon Jun 11 15:52:11 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Jun 11 20:13:36 2018 +0530
@@ -516,6 +516,8 @@
     emtpycommitallowed = repo.ui.backupconfig('ui', 'allowemptycommit')
     tr = repo.currenttransaction()
     assert tr is not None
+    # whether to store the obsmarker in the evolvestate
+    storemarker = False
     try:
         repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve')
         with repo.dirstate.parentchange():
@@ -551,14 +553,21 @@
         cmdrewrite.amend(ui, repo, message=desc, logfile='')
         # XXX: we can get rid of this len() call also by creating a new commit
         if oldlen == len(repo):
+            # no changes
             new = divergent
-            # no changes
+            storemarker = True
         else:
             new = repo['.']
             newnode = new.node()
 
         # creating markers and moving phases post-resolution
         obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
+        if storemarker:
+            # storing the marker in the evolvestate
+            # we just store the precursors and successor pair for now, we might
+            # want to store more data and serialize obsmarker in a better way in
+            # future
+            evolvestate['obsmarkers'].append((other.node(), new.node()))
         phases.retractboundary(repo, tr, other.phase(), [new.node()])
         return (True, newnode)
     finally: