Patchwork [3,of,4] bundle2: automatically add 'targetphase' parameter in writenewbundle

login
register
mail settings
Submitter Boris Feld
Date July 12, 2017, 3:39 p.m.
Message ID <5a2c6c050e33e4f2a571.1499873945@FB>
Download mbox | patch
Permalink /patch/22265/
State Accepted
Headers show

Comments

Boris Feld - July 12, 2017, 3:39 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499742723 -7200
#      Tue Jul 11 05:12:03 2017 +0200
# Node ID 5a2c6c050e33e4f2a571247f5d1e150a3ef1d295
# Parent  a600e69f8de0b75998a11502c3cb868936e6cb4a
# EXP-Topic tr.changes.phases
bundle2: automatically add 'targetphase' parameter in writenewbundle

If we are bundling secret changeset and the bundle will contain phase, we
request the changegroup to be applied as secret.

It will be useful for next patch as we are now sure that secrets changesets
are applied as secret and not applied as draft then forced to secret.

Patch

diff -r a600e69f8de0 -r 5a2c6c050e33 mercurial/bundle2.py
--- a/mercurial/bundle2.py	Tue Jul 11 05:11:52 2017 +0200
+++ b/mercurial/bundle2.py	Tue Jul 11 05:12:03 2017 +0200
@@ -1401,6 +1401,9 @@ 
     if 'clcount' in cg.extras:
         part.addparam('nbchanges', str(cg.extras['clcount']),
                       mandatory=False)
+    if opts.get('phases') and repo.revs('%ln and secret()',
+                                        outgoing.missingheads):
+        part.addparam('targetphase', '%d' % phases.secret, mandatory=False)
 
     addparttagsfnodescache(repo, bundler, outgoing)
 
diff -r a600e69f8de0 -r 5a2c6c050e33 tests/test-bundle-phases.t
--- a/tests/test-bundle-phases.t	Tue Jul 11 05:11:52 2017 +0200
+++ b/tests/test-bundle-phases.t	Tue Jul 11 05:12:03 2017 +0200
@@ -38,7 +38,7 @@ 
   3 changesets found
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
-  changegroup -- "sortdict([('version', '02'), ('nbchanges', '3')])"
+  changegroup -- "sortdict([('version', '02'), ('nbchanges', '3'), ('targetphase', '2')])"
       26805aba1e600a82e93661149f2313866a221a7b
       f585351a92f85104bff7c284233c338b10eb1df7
       9bc730a19041f9ec7cb33c626e811aa233efb18c
@@ -227,7 +227,7 @@ 
   5 changesets found
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
-  changegroup -- "sortdict([('version', '02'), ('nbchanges', '5')])"
+  changegroup -- "sortdict([('version', '02'), ('nbchanges', '5'), ('targetphase', '2')])"
       426bada5c67598ca65036d57d9e4b64b0c1ce7a0
       112478962961147124edd43549aedd1a335e44bf
       dc0947a82db884575bb76ea10ac97b08536bfa03
@@ -255,7 +255,7 @@ 
   2 changesets found
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
-  changegroup -- "sortdict([('version', '02'), ('nbchanges', '2')])"
+  changegroup -- "sortdict([('version', '02'), ('nbchanges', '2'), ('targetphase', '2')])"
       112478962961147124edd43549aedd1a335e44bf
       215e7b0814e1cac8e2614e7284f2a5dc266b4323
   phase-heads -- 'sortdict()'
@@ -265,7 +265,7 @@ 
   3 changesets found
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
-  changegroup -- "sortdict([('version', '02'), ('nbchanges', '3')])"
+  changegroup -- "sortdict([('version', '02'), ('nbchanges', '3'), ('targetphase', '2')])"
       112478962961147124edd43549aedd1a335e44bf
       dc0947a82db884575bb76ea10ac97b08536bfa03
       215e7b0814e1cac8e2614e7284f2a5dc266b4323
@@ -277,7 +277,7 @@ 
   2 changesets found
   $ hg debugbundle bundle
   Stream params: sortdict([('Compression', 'BZ')])
-  changegroup -- "sortdict([('version', '02'), ('nbchanges', '2')])"
+  changegroup -- "sortdict([('version', '02'), ('nbchanges', '2'), ('targetphase', '2')])"
       215e7b0814e1cac8e2614e7284f2a5dc266b4323
       03ca77807e919db8807c3749086dc36fb478cac0
   phase-heads -- 'sortdict()'