Patchwork [01,of,10,main-line-of-work,(some,two,digits,more,patches,to,go)] subrepo: detect issue3871 case earlier so it apply to bundle2

login
register
mail settings
Submitter Pierre-Yves David
Date May 29, 2015, 4:53 p.m.
Message ID <7f6e88e51d3adc11ce64.1432918382@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9361/
State Accepted
Headers show

Comments

Pierre-Yves David - May 29, 2015, 4:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1432732094 25200
#      Wed May 27 06:08:14 2015 -0700
# Node ID 7f6e88e51d3adc11ce648d2a95a0df08b4607fc7
# Parent  f5088cab7b299553177fa0c2ad36b6abbb566b8e
subrepo: detect issue3871 case earlier so it apply to bundle2

We are doing some strange special casing of phase push when:

- the source is a subrepo,
- the destination is publishing,
- some changesets are still draft on the destination.

In that case we do not push phases update (to publish the draft changesets)
because it could break simple cycle of 'clone/pull/push' with subrepos. We have
to detect this case earlier to have bundle2 respecting it. The old code is left
in place because in the bundle1 case we recompute phase update try to push them
anyway if the main push failed.

We change the test to check the behavior for both bundle1 and bundle2.
Pierre-Yves David - May 29, 2015, 5:31 p.m.
On 05/29/2015 09:53 AM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1432732094 25200
> #      Wed May 27 06:08:14 2015 -0700
> # Node ID 7f6e88e51d3adc11ce648d2a95a0df08b4607fc7
> # Parent  f5088cab7b299553177fa0c2ad36b6abbb566b8e
> subrepo: detect issue3871 case earlier so it apply to bundle2

bah, I failed my range definition and resent this one. Ignore it and 
starts at patch 2.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -303,10 +303,24 @@  def _pushdiscoveryphase(pushop):
     (computed for both success and failure case for changesets push)"""
     outgoing = pushop.outgoing
     unfi = pushop.repo.unfiltered()
     remotephases = pushop.remote.listkeys('phases')
     publishing = remotephases.get('publishing', False)
+    if (pushop.ui.configbool('ui', '_usedassubrepo', False)
+        and remotephases    # server supports phases
+        and not pushop.outgoing.missing # no changesets to be pushed
+        and publishing):
+        # When:
+        # - this is a subrepo push
+        # - and remote support phase
+        # - and no changeset are to be pushed
+        # - and remote is publishing
+        # We may be in issue 3871 case!
+        # We drop the possible phase synchronisation done by
+        # courtesy to publish changesets possibly locally draft
+        # on the remote.
+        remotephases = {'publishing': 'True'}
     ana = phases.analyzeremotephases(pushop.repo,
                                      pushop.fallbackheads,
                                      remotephases)
     pheads, droots = ana
     extracond = ''
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -1488,11 +1488,21 @@  Courtesy phases synchronisation to publi
   $ cd ../../issue3781
   $ cat >> .hg/hgrc << EOF
   > [paths]
   > default=../issue3781-dest/
   > EOF
-  $ hg push
+  $ hg push --config experimental.bundle2-exp=False
+  pushing to $TESTTMP/issue3781-dest (glob)
+  pushing subrepo s to $TESTTMP/issue3781-dest/s
+  searching for changes
+  no changes found
+  searching for changes
+  no changes found
+  [1]
+# clean the push cache
+  $ rm s/.hg/cache/storehash/*
+  $ hg push --config experimental.bundle2-exp=True
   pushing to $TESTTMP/issue3781-dest (glob)
   pushing subrepo s to $TESTTMP/issue3781-dest/s
   searching for changes
   no changes found
   searching for changes