changeset 3831:987e335dbe11

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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Mon, 11 Jun 2018 20:13:36 +0530
parents e0a20dc69126
children fb821ed44f86
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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: