changeset 19017:c5c8613f265e

histedit: properly handle --continue on empty fold When all changes from the fold have been dropped, the --continue code was confused. This changeset handles this case. The test for this case existed but was broken.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Tue, 16 Apr 2013 16:58:25 +0200
parents 27ec54f2946e
children 730614b9b352
files hgext/histedit.py tests/test-histedit-fold.t
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/histedit.py	Tue Apr 16 20:50:17 2013 +0200
+++ b/hgext/histedit.py	Tue Apr 16 16:58:25 2013 +0200
@@ -618,14 +618,20 @@
         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]]
--- a/tests/test-histedit-fold.t	Tue Apr 16 20:50:17 2013 +0200
+++ b/tests/test-histedit-fold.t	Tue Apr 16 16:58:25 2013 +0200
@@ -141,7 +141,7 @@
   $ 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