diff mercurial/bundle2.py @ 50392:385a4f8056e5

bundle: include required phases when saving a bundle (issue6794) We now properly computes and includes phases above secret in bundle, previously, they would be skipped, and then the code computing them would crash. Note that from this changeset, we also include the heads associated with the changegroup's "target" phase. This turned out to be necessary to ensure the movement of changeset included in the bundle, but already known locally. This explain why lines for "secret" heads appears in multiple tests.
author Jason R. Coombs <jaraco@jaraco.com>, Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 09 Mar 2023 01:26:04 +0100
parents f1887500f3ec
children bcf54837241d
line wrap: on
line diff
--- a/mercurial/bundle2.py	Wed Mar 08 17:33:33 2023 +0100
+++ b/mercurial/bundle2.py	Thu Mar 09 01:26:04 2023 +0100
@@ -1750,12 +1750,16 @@
             part.addparam(
                 b'nbchanges', b'%d' % cg.extras[b'clcount'], mandatory=False
             )
-        if opts.get(b'phases') and repo.revs(
-            b'%ln and secret()', outgoing.ancestorsof
-        ):
-            part.addparam(
-                b'targetphase', b'%d' % phases.secret, mandatory=False
-            )
+        if opts.get(b'phases'):
+            target_phase = phases.draft
+            for head in outgoing.ancestorsof:
+                target_phase = max(target_phase, repo[head].phase())
+            if target_phase > phases.draft:
+                part.addparam(
+                    b'targetphase',
+                    b'%d' % target_phase,
+                    mandatory=False,
+                )
     if repository.REPO_FEATURE_SIDE_DATA in repo.features:
         part.addparam(b'exp-sidedata', b'1')