diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1750,12 +1750,16 @@ def _addpartsfromopts(ui, repo, bundler, 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') diff --git a/mercurial/phases.py b/mercurial/phases.py --- a/mercurial/phases.py +++ b/mercurial/phases.py @@ -827,10 +827,8 @@ def subsetphaseheads(repo, subset): cl = repo.changelog headsbyphase = {i: [] for i in allphases} - # No need to keep track of secret phase; any heads in the subset that - # are not mentioned are implicitly secret. - for phase in allphases[:secret]: - revset = b"heads(%%ln & %s())" % phasenames[phase] + for phase in allphases: + revset = b"heads(%%ln & _phase(%d))" % phase headsbyphase[phase] = [cl.node(r) for r in repo.revs(revset, subset)] return headsbyphase diff --git a/tests/test-bundle-phases.t b/tests/test-bundle-phases.t --- a/tests/test-bundle-phases.t +++ b/tests/test-bundle-phases.t @@ -44,6 +44,7 @@ Set up repo with linear history cache:rev-branch-cache -- {} (mandatory: False) phase-heads -- {} (mandatory: True) 26805aba1e600a82e93661149f2313866a221a7b draft + 9bc730a19041f9ec7cb33c626e811aa233efb18c secret $ hg strip --no-backup C Phases show on incoming, and are also restored when pulling. Secret commits @@ -374,6 +375,7 @@ Restore bundle of entire repo phase-heads -- {} (mandatory: True) dc0947a82db884575bb76ea10ac97b08536bfa03 public 03ca77807e919db8807c3749086dc36fb478cac0 draft + 4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 secret $ hg strip --no-backup A $ hg unbundle -q bundle $ rm bundle @@ -398,6 +400,7 @@ Restore bundle of entire repo 4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 cache:rev-branch-cache -- {} (mandatory: False) phase-heads -- {} (mandatory: True) + 4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 secret $ rm bundle $ hg bundle --base A -r D bundle @@ -411,6 +414,7 @@ Restore bundle of entire repo cache:rev-branch-cache -- {} (mandatory: False) phase-heads -- {} (mandatory: True) dc0947a82db884575bb76ea10ac97b08536bfa03 public + 4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 secret $ rm bundle $ hg bundle --base 'B + C' -r 'D + E' bundle @@ -423,4 +427,5 @@ Restore bundle of entire repo cache:rev-branch-cache -- {} (mandatory: False) phase-heads -- {} (mandatory: True) 03ca77807e919db8807c3749086dc36fb478cac0 draft + 4e4f9194f9f181c57f62e823e8bdfa46ab9e4ff4 secret $ rm bundle diff --git a/tests/test-bundle-type.t b/tests/test-bundle-type.t --- a/tests/test-bundle-type.t +++ b/tests/test-bundle-type.t @@ -383,6 +383,7 @@ unfortunate that the phase information f 66e2c4b43e0cf8f0bdff0733a0b97ce57874e35d public a8c3a1ed30eb71f03f476c5fa7ead831ef991a55 draft 2ea90778052ba7558fab36e3fd5d149512ff986b draft + b9f5f740a8cd76700020e3903ee55ecff78bd3e5 secret bzip2-v2;cg.version=03 adding changesets diff --git a/tests/test-phase-archived.t b/tests/test-phase-archived.t --- a/tests/test-phase-archived.t +++ b/tests/test-phase-archived.t @@ -181,8 +181,6 @@ Strips the other (lower rev-num) head The archived changeset should still be hidden $ hg log -G -T '{rev} {node|short} [{phase}] {desc|firstline}\n' - o 2 f90bf4e57854 [draft] some more commit (known-bad-output !) - | (known-bad-output !) @ 1 d1e73e428f29 [draft] unbundletesting | o 0 c1863a3840c6 [draft] root @@ -191,8 +189,7 @@ The archived changeset should still be h It may still be around: $ hg log --hidden -G -T '{rev} {node|short} [{phase}] {desc|firstline}\n' - o 2 f90bf4e57854 [draft] some more commit (known-bad-output !) - o 2 f90bf4e57854 [archived] some more commit (missing-correct-output !) + o 2 f90bf4e57854 [archived] some more commit | @ 1 d1e73e428f29 [draft] unbundletesting |