Patchwork [STABLE] rebase: ignore negative state when updating back to original wc parent

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 2, 2014, 8:21 p.m.
Message ID <dcda24083017b829f38f.1417551690@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6957/
State Accepted
Commit 57d35d3c1cf170513cc150c5021f5e3e0d7cdafb
Headers show

Comments

Pierre-Yves David - Dec. 2, 2014, 8:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1417547198 28800
#      Tue Dec 02 11:06:38 2014 -0800
# Branch stable
# Node ID dcda24083017b829f38f8f58a96704f3a72e4961
# Parent  2b1ffaaab01f4068f4e1b1291654bf49d334d5d9
rebase: ignore negative state when updating back to original wc parent

The state mapping also contains some magic negative value (detached parent,
ignored revision). Blindly reading state leads to unfortunate usage of such
value as update destination. We now filter them out.

We do minor alteration of the test to catch this.
Matt Mackall - Dec. 2, 2014, 9:58 p.m.
On Tue, 2014-12-02 at 12:21 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1417547198 28800
> #      Tue Dec 02 11:06:38 2014 -0800
> # Branch stable
> # Node ID dcda24083017b829f38f8f58a96704f3a72e4961
> # Parent  2b1ffaaab01f4068f4e1b1291654bf49d334d5d9
> rebase: ignore negative state when updating back to original wc parent

Queued for stable, thanks.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -447,10 +447,13 @@  def rebase(ui, repo, **opts):
             targetnode = repo[target].node()
 
         # restore original working directory
         # (we do this before stripping)
         newwd = state.get(originalwd, originalwd)
+        if newwd < 0:
+            # original directory is a parent of rebase set root or ignored
+            newwd = originalwd
         if newwd not in [c.rev() for c in repo[None].parents()]:
             ui.note(_("update back to initial working directory parent\n"))
             hg.updaterepo(repo, newwd, False)
 
         if not keepf:
diff --git a/tests/test-rebase-scenario-global.t b/tests/test-rebase-scenario-global.t
--- a/tests/test-rebase-scenario-global.t
+++ b/tests/test-rebase-scenario-global.t
@@ -298,12 +298,16 @@  Check rebasing public changeset
 
   $ hg rebase -d 5 -b 6 --keep
 
 Check rebasing mutable changeset
 Source phase greater or equal to destination phase: new changeset get the phase of source:
+  $ hg id -n
+  5
   $ hg rebase -s9 -d0
   saved backup bundle to $TESTTMP/a7/.hg/strip-backup/2b23e52411f4-backup.hg (glob)
+  $ hg id -n # check we updated back to parent
+  5
   $ hg log --template "{phase}\n" -r 9
   draft
   $ hg rebase -s9 -d1
   saved backup bundle to $TESTTMP/a7/.hg/strip-backup/2cb10d0cfc6c-backup.hg (glob)
   $ hg log --template "{phase}\n" -r 9