Patchwork [2,of,3] histedit: pop action after the action is completed

login
register
mail settings
Submitter Durham Goode
Date March 9, 2017, 12:33 a.m.
Message ID <265484e77411893d910f.1489019619@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/19042/
State Superseded
Headers show

Comments

Durham Goode - March 9, 2017, 12:33 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1489019264 28800
#      Wed Mar 08 16:27:44 2017 -0800
# Node ID 265484e77411893d910f2eff4efe02cfe6abd5b7
# Parent  c9195d0e227ad2c3b4544a9352dd59ccd0336d36
histedit: pop action after the action is completed

We only want to pop the action after the action is completed, since if the
action aborts part way through we want it to remain at the front of the list so
continue/abort will start with it.

Previously we relied on the fact that we only serialized the state file at the
beginning of the action, so the pop wasn't serialized until the next iteration
of the loop. In a future patch we will be adding a large transaction around this
area, which means if we pop the list early it might get serialized if the action
throws a user InterventionRequired error, at which point the action is not in
the list anymore. So let's only pop it once the action is really truly done.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -1107,7 +1107,7 @@  def _continuehistedit(ui, repo, state):
     pos = 0
     while state.actions:
         state.write()
-        actobj = state.actions.pop(0)
+        actobj = state.actions[0]
         pos += 1
         ui.progress(_("editing"), pos, actobj.torule(),
                     _('changes'), total)
@@ -1116,6 +1116,7 @@  def _continuehistedit(ui, repo, state):
         parentctx, replacement_ = actobj.run()
         state.parentctxnode = parentctx.node()
         state.replacements.extend(replacement_)
+        state.actions.pop(0)
     state.write()
     ui.progress(_("editing"), None)