Patchwork [1,of,5,V2] rebase: clear updatestate during rebase --abort in more cases

login
register
mail settings
Submitter Durham Goode
Date March 8, 2017, 12:37 a.m.
Message ID <4eb06495f778ecce2b36.1488933453@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/18974/
State Accepted
Headers show

Comments

Durham Goode - March 8, 2017, 12:37 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1488925148 28800
#      Tue Mar 07 14:19:08 2017 -0800
# Node ID 4eb06495f778ecce2b3644e0d50585495f26162b
# Parent  7433b3bc55eebfa9149280339b406bd4cec64efb
rebase: clear updatestate during rebase --abort in more cases

Previously, rebase --abort would only call update if you were on a node that had
already been rebased. This meant that if the rebase failed during the rebase of
the first commit, the working copy would be left dirty (with a .hg/updatestate
file) and rebase --abort would not have update to clean it up.

The fix is to also perform an update if you're still on the target node or on
the original working copy node (since the working copy may be dirty, we still
need to do the update). We don't want to perform an update in all cases though
because of issue4009.

A subsequent patch makes this case much more common, since it causes the entire
rebase transaction to rollback during unexpected exceptions. This causes the
existing test-rebase-abort.t to cover this case.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1156,8 +1156,11 @@  def abort(repo, originalwd, target, stat
             if rebased:
                 strippoints = [
                         c.node() for c in repo.set('roots(%ld)', rebased)]
-                shouldupdate = len([
-                        c.node() for c in repo.set('. & (%ld)', rebased)]) > 0
+
+            updateifonnodes = set(rebased)
+            updateifonnodes.add(target)
+            updateifonnodes.add(originalwd)
+            shouldupdate = repo['.'].rev() in updateifonnodes
 
             # Update away from the rebase if necessary
             if shouldupdate or needupdate(repo, state):