Patchwork [4,of,8] histedit: properly handle --continue on empty fold

login
register
mail settings
Submitter Pierre-Yves David
Date April 16, 2013, 7:20 p.m.
Message ID <bc6d6eba699fa8c6705c.1366140033@yamac.lan>
Download mbox | patch
Permalink /patch/1360/
State Accepted
Commit c5c8613f265e563361640b2ab2ee4d6d77429d4e
Headers show

Comments

Pierre-Yves David - April 16, 2013, 7:20 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1366124305 -7200
# Node ID bc6d6eba699fa8c6705c6888bc823536b40172c0
# Parent  c84edaaf84839ccf18c8caf4118df0ed5c9110fe
histedit: properly handle --continue on empty fold

When all changes from the fold have been dropped, the --continue code was
confuse. This changeset now handle this case.

The test for this case existed but was broken.

Patch

diff --git a/hgext/histedit.py b/hgext/histedit.py
--- a/hgext/histedit.py
+++ b/hgext/histedit.py
@@ -616,18 +616,24 @@  def bootstrapcontinue(ui, repo, parentct
         # this happen e.g during conflicting pick where we revert content
         # to parent.
         replacements.append((ctx.node(), tuple(newchildren)))
 
     if action in ('f', 'fold'):
-        # finalize fold operation if applicable
-        if new is None:
-            new = newchildren[-1]
+        if newchildren:
+            # finalize fold operation if applicable
+            if new is None:
+                new = newchildren[-1]
+            else:
+                newchildren.pop()  # remove new from internal changes
+            parentctx, repl = finishfold(ui, repo, parentctx, ctx, new, opts,
+                                         newchildren)
+            replacements.extend(repl)
         else:
-            newchildren.pop()  # remove new from internal changes
-        parentctx, repl = finishfold(ui, repo, parentctx, ctx, new, opts,
-                                     newchildren)
-        replacements.extend(repl)
+            # newchildren is empty if the fold did not result in any commit
+            # this happen when all folded change are discarded during the
+            # merge.
+            replacements.append((ctx.node(), (parentctx.node(),)))
     elif newchildren:
         # otherwise update "parentctx" before proceeding to further operation
         parentctx = repo[newchildren[-1]]
     return parentctx, replacements
 
diff --git a/tests/test-histedit-fold.t b/tests/test-histedit-fold.t
--- a/tests/test-histedit-fold.t
+++ b/tests/test-histedit-fold.t
@@ -124,11 +124,11 @@  folded content is dropped during a merge
   
 
   $ cat > $EDITED <<EOF
   > pick 617f94f13c0f 1 +4
   > drop 888f9082bf99 2 +5
-  > pick 251d831eeec5 3 +6
+  > fold 251d831eeec5 3 +6
   > EOF
 
   $ HGEDITOR="cat \"$EDITED\" > " hg histedit 1
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   merging file