Patchwork [STABLE] rebase: fix working copy location after a --collapse (issue4080)

login
register
mail settings
Submitter Durham Goode
Date Nov. 2, 2013, 12:09 a.m.
Message ID <a08ed9678dead79c9a2c.1383350952@dev350.prn1.facebook.com>
Download mbox | patch
Permalink /patch/2836/
State Accepted
Commit ea81f8b2364e2e643577d18ef8369fce4c67f47e
Headers show

Comments

Durham Goode - Nov. 2, 2013, 12:09 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1383350886 25200
#      Fri Nov 01 17:08:06 2013 -0700
# Branch stable
# Node ID a08ed9678dead79c9a2c104dca74e848bfa1e974
# Parent  1d7a36ff2615e6e12ce65681db4e07622e7b60d1
rebase: fix working copy location after a --collapse (issue4080)

Rebasing with --collapse would leave the working copy on the parent of the
collapsed commit, instead of on the collapsed commit.  This fixes that.  Also
fixes a few tests that already covered this area but had bad data.

This also fixes issue3716 where bookmarks are not kept across rebases with
--collapse. I updated the test to cover that case as well.
Matt Mackall - Nov. 6, 2013, 10:07 p.m.
On Fri, 2013-11-01 at 17:09 -0700, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1383350886 25200
> #      Fri Nov 01 17:08:06 2013 -0700
> # Branch stable
> # Node ID a08ed9678dead79c9a2c104dca74e848bfa1e974
> # Parent  1d7a36ff2615e6e12ce65681db4e07622e7b60d1
> rebase: fix working copy location after a --collapse (issue4080)

Queued for stable, thanks.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -345,6 +345,9 @@ 
                 commitmsg = ui.edit(commitmsg, repo.ui.username())
             newrev = concludenode(repo, rev, p1, external, commitmsg=commitmsg,
                                   extrafn=extrafn, editor=editor)
+            for oldrev in state.iterkeys():
+                if state[oldrev] > nullmerge:
+                    state[oldrev] = newrev
 
         if 'qtip' in repo.tags():
             updatemq(repo, state, skipped, **opts)
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -57,11 +57,11 @@ 
   saved backup bundle to $TESTTMP/a1/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglogp
-  o  5:secret 'Collapsed revision
+  @  5:secret 'Collapsed revision
   |  * B
   |  * C
   |  * D'
-  @  4:draft 'H'
+  o  4:draft 'H'
   |
   | o  3:draft 'G'
   |/|
@@ -737,12 +737,13 @@ 
   $ touch b
   $ hg commit -Am b
   adding b
+  $ hg book foo
   $ hg rebase -d 0 -r "1::2" --collapse -m collapsed
   saved backup bundle to $TESTTMP/collapseaddremove/.hg/strip-backup/*-backup.hg (glob)
-  $ hg tglog
-  o  1: 'collapsed'
+  $ hg log -G --template "{rev}: '{desc}' {bookmarks}"
+  @  1: 'collapsed' foo
   |
-  @  0: 'base'
+  o  0: 'base'
   
   $ hg manifest --rev tip
   b
diff --git a/tests/test-rebase-detach.t b/tests/test-rebase-detach.t
--- a/tests/test-rebase-detach.t
+++ b/tests/test-rebase-detach.t
@@ -329,11 +329,11 @@ 
   saved backup bundle to $TESTTMP/a6/.hg/strip-backup/*-backup.hg (glob)
 
   $ hg tglog
-  o  8: 'Collapsed revision
+  @  8: 'Collapsed revision
   |  * I
   |  * Merge
   |  * J'
-  @  7: 'H'
+  o  7: 'H'
   |
   | o  6: 'G'
   |/|