hgext/histedit.py
changeset 19017 c5c8613f265e
parent 18995 0023a6e49268
child 19018 730614b9b352
--- 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]]