evolve: use the new evolvestate class in place of old methods
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 10 Jan 2018 15:57:43 +0530
changeset 3392 62f33ed3c36c
parent 3391 d2fc2c2783f8
child 3393 a29d063d09e1
evolve: use the new evolvestate class in place of old methods Earlier we had three methods, which used to handle all the storage around the evolvestate but in previous patch we have introduced an evolvestate class wrapper which can serve for all our needs. This patch replaces the existing usage of the evolvestate with the new class introduced. Upcoming patches will start using the class at more places.
hgext3rd/evolve/__init__.py
--- a/hgext3rd/evolve/__init__.py	Wed Jan 10 14:53:01 2018 +0530
+++ b/hgext3rd/evolve/__init__.py	Wed Jan 10 15:57:43 2018 +0530
@@ -313,6 +313,7 @@
     compat,
     debugcmd,
     cmdrewrite,
+    evolvestate,
     exthelper,
     metadata,
     obscache,
@@ -849,8 +850,8 @@
         raise
 
 def summaryhook(ui, repo):
-    state = _evolvestateread(repo)
-    if state is not None:
+    state = evolvestate.evolvestate(repo)
+    if state:
         # i18n: column positioning for "hg summary"
         ui.status(_('evolve: (evolve --continue)\n'))
 
@@ -1580,9 +1581,10 @@
 
     # Continuation handling
     if contopt:
-        state = _evolvestateread(repo)
-        if state is None:
+        state = evolvestate.evolvestate(repo)
+        if not state:
             raise error.Abort('no evolve to continue')
+        state.load()
         orig = repo[state['current']]
         with repo.wlock(), repo.lock():
             ctx = orig
@@ -1606,7 +1608,7 @@
                                    date=date, extra=extra)
 
             obsolete.createmarkers(repo, [(ctx, (repo[node],))])
-            _evolvestatedelete(repo)
+            state.delete()
             return
 
     cmdutil.bailifchanged(repo)
@@ -1791,7 +1793,9 @@
         try:
             relocate(repo, orig, target, pctx, keepbranch)
         except MergeFailure:
-            _evolvestatewrite(repo, {'current': orig.node()})
+            ops = {'current': orig.node()}
+            state = evolvestate.evolvestate(repo, opts=ops)
+            state.save()
             repo.ui.write_err(_('evolve failed!\n'))
             repo.ui.write_err(
                 _("fix conflict and run 'hg evolve --continue'"