Patchwork [2,of,2,STABLE] histedit: fix --continue when rules are finished

login
register
mail settings
Submitter Durham Goode
Date May 7, 2015, 9:01 p.m.
Message ID <408af58cba08728e37df.1431032462@dev2000.prn2.facebook.com>
Download mbox | patch
Permalink /patch/8954/
State Accepted
Headers show

Comments

Durham Goode - May 7, 2015, 9:01 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1430520307 25200
#      Fri May 01 15:45:07 2015 -0700
# Node ID 408af58cba08728e37df99510ad9fe66125be028
# Parent  ed5036b584c85b9cb63bfd0b6f0146a5e9316ab0
histedit: fix --continue when rules are finished

If histedit failed after all the rules were complete (for instance, if there was
an exception in the cleanup phase), you couldn't --continue because it was
unable to pop a rule. Let's just skip the rule execution phase of --continue if
there are no more rules.
Augie Fackler - May 8, 2015, 2:54 p.m.
On Thu, May 07, 2015 at 02:01:02PM -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1430520307 25200
> #      Fri May 01 15:45:07 2015 -0700
> # Node ID 408af58cba08728e37df99510ad9fe66125be028
> # Parent  ed5036b584c85b9cb63bfd0b6f0146a5e9316ab0
> histedit: fix --continue when rules are finished

Both look good, queued for stable.

>
> If histedit failed after all the rules were complete (for instance, if there was
> an exception in the cleanup phase), you couldn't --continue because it was
> unable to pop a rule. Let's just skip the rule execution phase of --continue if
> there are no more rules.
>
> diff --git a/hgext/histedit.py b/hgext/histedit.py
> --- a/hgext/histedit.py
> +++ b/hgext/histedit.py
> @@ -893,21 +893,22 @@ def _histedit(ui, repo, state, *freeargs
>
>  def bootstrapcontinue(ui, state, opts):
>      repo = state.repo
> -    action, currentnode = state.rules.pop(0)
> +    if state.rules:
> +        action, currentnode = state.rules.pop(0)
>
> -    actobj = actiontable[action].fromrule(state, currentnode)
> +        actobj = actiontable[action].fromrule(state, currentnode)
>
> -    s = repo.status()
> -    if s.modified or s.added or s.removed or s.deleted:
> -        actobj.continuedirty()
>          s = repo.status()
>          if s.modified or s.added or s.removed or s.deleted:
> -            raise util.Abort(_("working copy still dirty"))
> +            actobj.continuedirty()
> +            s = repo.status()
> +            if s.modified or s.added or s.removed or s.deleted:
> +                raise util.Abort(_("working copy still dirty"))
>
> -    parentctx, replacements = actobj.continueclean()
> +        parentctx, replacements = actobj.continueclean()
>
> -    state.parentctxnode = parentctx.node()
> -    state.replacements.extend(replacements)
> +        state.parentctxnode = parentctx.node()
> +        state.replacements.extend(replacements)
>
>      return state
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -893,21 +893,22 @@  def _histedit(ui, repo, state, *freeargs
 
 def bootstrapcontinue(ui, state, opts):
     repo = state.repo
-    action, currentnode = state.rules.pop(0)
+    if state.rules:
+        action, currentnode = state.rules.pop(0)
 
-    actobj = actiontable[action].fromrule(state, currentnode)
+        actobj = actiontable[action].fromrule(state, currentnode)
 
-    s = repo.status()
-    if s.modified or s.added or s.removed or s.deleted:
-        actobj.continuedirty()
         s = repo.status()
         if s.modified or s.added or s.removed or s.deleted:
-            raise util.Abort(_("working copy still dirty"))
+            actobj.continuedirty()
+            s = repo.status()
+            if s.modified or s.added or s.removed or s.deleted:
+                raise util.Abort(_("working copy still dirty"))
 
-    parentctx, replacements = actobj.continueclean()
+        parentctx, replacements = actobj.continueclean()
 
-    state.parentctxnode = parentctx.node()
-    state.replacements.extend(replacements)
+        state.parentctxnode = parentctx.node()
+        state.replacements.extend(replacements)
 
     return state