changeset 50393:f95ab2c53303

outgoing: fix common-heads computation from `missingroots` argument When initializing a `outgoing` object, the `common set` can be defined explicitly (with the `commonheads` argument`) or implicitly (with the missingroots arguments). It turns out the logic to compute `commonheads` from `missingroots` is buggy, as it does not consider the parents of enough changesets. Previously, it only considered parents of "missingroots` items, while it need to consider all parents of missing. Here is an example: F |\ C E | | B D |/ A If we use [E] as missing-roots, the missing set is [E, F], and the common-heads are [C, D]. However you cannot only consider the parent of [E] to find them, as [C] is not a parent of [E]. This already fix the bundle generated in one test, and it would prevent many other to misbehave with future change from this series.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 10 Mar 2023 04:04:10 +0100
parents 385a4f8056e5
children 7a017cd07a1e
files mercurial/discovery.py tests/test-rebase-conflicts.t
diffstat 2 files changed, 6 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/discovery.py	Thu Mar 09 01:26:04 2023 +0100
+++ b/mercurial/discovery.py	Fri Mar 10 04:04:10 2023 +0100
@@ -104,14 +104,14 @@
         if ancestorsof is None:
             ancestorsof = cl.heads()
         if missingroots:
-            discbases = []
-            for n in missingroots:
-                discbases.extend([p for p in cl.parents(n) if p != repo.nullid])
             # TODO remove call to nodesbetween.
             # TODO populate attributes on outgoing instance instead of setting
             # discbases.
             csets, roots, heads = cl.nodesbetween(missingroots, ancestorsof)
             included = set(csets)
+            discbases = []
+            for n in csets:
+                discbases.extend([p for p in cl.parents(n) if p != repo.nullid])
             ancestorsof = heads
             commonheads = [n for n in discbases if n not in included]
         elif not commonheads:
--- a/tests/test-rebase-conflicts.t	Thu Mar 09 01:26:04 2023 +0100
+++ b/tests/test-rebase-conflicts.t	Fri Mar 10 04:04:10 2023 +0100
@@ -296,9 +296,8 @@
   bundle2-output-part: "cache:rev-branch-cache" (advisory) streamed payload
   bundle2-output-part: "phase-heads" 24 bytes payload
   saved backup bundle to $TESTTMP/issue4041/.hg/strip-backup/e31216eec445-15f7a814-rebase.hg
-  3 changesets found
+  2 changesets found
   list of changesets:
-  4c9fbe56a16f30c0d5dcc40ec1a97bbe3325209c
   19c888675e133ab5dff84516926a65672eaf04d9
   c1ffa3b5274e92a9388fe782854e295d2e8d0443
   bundle2-output-bundle: "HG20", 3 parts total
@@ -309,15 +308,14 @@
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "changegroup" (params: 1 mandatory 1 advisory) supported
   adding changesets
-  add changeset 4c9fbe56a16f
   add changeset 19c888675e13
   add changeset c1ffa3b5274e
   adding manifests
   adding file changes
   adding f1.txt revisions
-  bundle2-input-part: total payload size 1761
+  bundle2-input-part: total payload size 1255
   bundle2-input-part: "cache:rev-branch-cache" (advisory) supported
-  bundle2-input-part: total payload size 74
+  bundle2-input-part: total payload size 54
   bundle2-input-part: "phase-heads" supported
   bundle2-input-part: total payload size 24
   bundle2-input-bundle: 3 parts total