quark updated this revision to Diff 830.
quark edited the summary of this revision.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D340?vs=770&id=830

REVISION DETAIL
  https://phab.mercurial-scm.org/D340

AFFECTED FILES
  hgext/rebase.py
  tests/test-rebase-obsolete.t

CHANGE DETAILS

diff --git a/tests/test-rebase-obsolete.t b/tests/test-rebase-obsolete.t
--- a/tests/test-rebase-obsolete.t
+++ b/tests/test-rebase-obsolete.t
@@ -1104,11 +1104,9 @@
   note: not rebasing 2:b18e25de2cf5 "D" (D), already in destination as 
1:112478962961 "B"
   rebasing 3:7fb047a69f22 "E" (E)
   rebasing 5:66f1a38021c9 "F" (F tip)
-  warning: rebasing 5:66f1a38021c9 may inlcude unwanted changes from revision 2
+  note: rebase of 5:66f1a38021c9 created no changes to commit
 
   $ hg log -G
-  o  7:502540f44880 F
-  |
   o  6:533690786a86 E
   |
   | x    5:66f1a38021c9 F
@@ -1125,6 +1123,48 @@
   
   $ cd ..
 
+Rebase merge where both parents have successors in destination
+
+  $ hg init p12-succ-in-dest
+  $ cd p12-succ-in-dest
+  $ hg debugdrawdag <<'EOS'
+  >   E   F
+  >  /|  /|  # replace: A -> C
+  > A B C D  # replace: B -> D
+  > | |
+  > X Y
+  > EOS
+  $ hg rebase -r A+B+E -d F
+  note: not rebasing 4:a3d17304151f "A" (A), already in destination as 
0:96cc3511f894 "C"
+  note: not rebasing 5:b23a2cc00842 "B" (B), already in destination as 
1:058c1e1fb10a "D"
+  rebasing 7:dac5d11c5a7d "E" (E tip)
+  warning: rebasing 7:dac5d11c5a7d may inlcude unwanted changes from revision 
3, 5
+  $ hg manifest -r tip
+  B
+  C
+  D
+  Y
+  $ hg log -G -T '{rev}:{node|short} {desc|firstline} +{file_adds}\n'
+  o  8:3306ff4ff997 E +B Y
+  |
+  | x    7:dac5d11c5a7d E +B Y
+  | |\
+  o \ \    6:e0c929a964ce F +C
+  |\ \ \
+  | | | x  5:b23a2cc00842 B +B
+  | | | |
+  | | x |  4:a3d17304151f A +A
+  | | | |
+  | | | o  3:59c792af609c Y +Y
+  | | |
+  | | o  2:ba2b7fa7166d X +X
+  | |
+  | o  1:058c1e1fb10a D +D
+  |
+  o  0:96cc3511f894 C +C
+  
+  $ cd ..
+
 Test that bookmark is moved and working dir is updated when all changesets have
 equivalents in destination
   $ hg init rbsrepo && cd rbsrepo
diff --git a/hgext/rebase.py b/hgext/rebase.py
--- a/hgext/rebase.py
+++ b/hgext/rebase.py
@@ -1095,6 +1095,27 @@
 
     repo.ui.debug(" future parents are %d and %d\n" % tuple(newps))
 
+    # If there are multiple merge base candidates, try to remove one of them.
+    # Prefer obsoleted ones with successor in destination. Otherwise we might
+    # re-introduce unwanted obsoleted changes. For example,
+    #
+    #     C      # rebase -r A+B+C -d D
+    #    /|      # Suppose A has content "+A", B has "+B", D has "+D".
+    #   A B   D  # replace: A is replaced by D
+    #
+    # B gets moved on top of D, A gets skipped, C gets moved on top of B':
+    #
+    #         C' # When choosing merge base for C, A and B are candidates.
+    #         |  # If we choose B, the difference between C and B are "+A",
+    #     C   B' # and C' will have the content "+A", which is suboptimal
+    #    /|   |  # because it re-introduces obsoleted content. If we choose
+    #   A B   D  # A as merge base, it works as expected - C' may be empty.
+    if len(bases) > 1:
+        newbases = [r for r in bases
+                    if any(isancestor(s, dest) for s in successorrevs(repo, 
r))]
+        if len(newbases) == 1:
+            bases = newbases
+
     # Decide a merge base
     base = None
     if len(bases) == 1:



To: quark, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to