Patchwork [17,of,17] rebase: preserve parent order when rebasing

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 30, 2014, 7:08 p.m.
Message ID <b1e2ea57d2690d7d8299.1417374524@localhost.localdomain>
Download mbox | patch
Permalink /patch/6921/
State Changes Requested
Headers show

Comments

Mads Kiilerich - Nov. 30, 2014, 7:08 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1417374421 -3600
#      Sun Nov 30 20:07:01 2014 +0100
# Node ID b1e2ea57d2690d7d82998db04ec05d891e899f64
# Parent  639a274a5bd418594c9ad21766bf59cb5fcb3758
rebase: preserve parent order when rebasing

If the original p1 was outside the rebase set, it would end up as p2. Keeping
it as p1 is more correct.

Patch

diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -623,7 +623,7 @@  def computerebase(repo, rev, target, sta
                    p1'            p1'          p1',p2         p1',p2
 
     outside   target,rev|p1 target,rev|None  p2',rev|p2       abort
-                 target        target,p1       p2',p1       3 parents
+                 target        p1,target       p1,p2'       3 parents
     '''
     ctx = repo[rev]
 
@@ -687,10 +687,10 @@  def computerebase(repo, rev, target, sta
         return target, rev, p1, target, nullrev
     if p2 in targetancestors:
         repo.ui.debug(' p1 outside, p2 ancestor\n')
-        return target, rev, None, target, p1
+        return target, rev, None, p1, target
     if p2_ >= nullrev:
         repo.ui.debug(' p1 outside, p2 rebased\n')
-        return p2_, rev, p2, p2_, p1
+        return p2_, rev, p2, p1, p2_
     repo.ui.debug(' p1 outside, p2 outside\n')
     raise util.Abort(_('cannot use revision %d as base, result '
                        'would have 3 parents') % rev)
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -258,7 +258,7 @@  Check that the right ancestors is used w
   rebasing 10:2f2496ddf49d "merge" (tip)
   rebasing: 10:2f2496ddf49d 6/6 changesets (100.00%)
    p1 outside, p2 rebased
-   merging 11 and 10 using ancestor 9, setting parents 11 and 7
+   merging 11 and 10 using ancestor 9, setting parents 7 and 11
   rebase status stored
    already in target
    merge against 10:2f2496ddf49d
diff --git a/tests/test-rebase-newancestor.t b/tests/test-rebase-newancestor.t
--- a/tests/test-rebase-newancestor.t
+++ b/tests/test-rebase-newancestor.t
@@ -229,10 +229,10 @@  Test order of parents of rebased merged 
   rebasing 4:6990226659be "merge p1 3=outside p2 1=ancestor"
   saved backup bundle to $TESTTMP/parentorder/.hg/strip-backup/6990226659be-backup.hg (glob)
   $ hg tip
-  changeset:   5:cca50676b1c5
+  changeset:   5:ca24ade1b78e
   tag:         tip
+  parent:      3:f59da8fc0fcf
   parent:      2:a60552eb93fb
-  parent:      3:f59da8fc0fcf
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge p1 3=outside p2 1=ancestor