Patchwork [main-line-of-work] subrepo: detect issue3871 case earlier so it apply to bundle2

login
register
mail settings
Submitter Pierre-Yves David
Date May 28, 2015, 8:08 p.m.
Message ID <a6113fe627b29a2d027a.1432843700@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9340/
State Accepted
Headers show

Comments

Pierre-Yves David - May 28, 2015, 8:08 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 a6113fe627b29a2d027a8247fc379ff8b934060f
# 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 changeset are still draft on the destination

In that case we do not push phases information (to publish the draft changesets)
because it could break simple cycle of 'clone/pull/push' of subrepos. We have to
detect this case earlier to have bundle2 respecting it.

We change the test to check the behavior for both bundle1 and bundle2.
Yuya Nishihara - May 29, 2015, 1:59 p.m.
On Thu, 28 May 2015 13:08:20 -0700, 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 a6113fe627b29a2d027a8247fc379ff8b934060f
> # Parent  f5088cab7b299553177fa0c2ad36b6abbb566b8e
> subrepo: detect issue3871 case earlier so it apply to bundle2

I believe it is "issue3781".

http://bz.selenic.com/show_bug.cgi?id=3781

> We are doing some strange special casing of phase push when:
> 
> - the source is a subrepo
> - the destination is publishing
> - some changeset are still draft on the destination
> 
> In that case we do not push phases information (to publish the draft changesets)
> because it could break simple cycle of 'clone/pull/push' of subrepos. We have to
> detect this case earlier to have bundle2 respecting it.
> 
> We change the test to check the behavior for both bundle1 and bundle2.
Augie Fackler - May 29, 2015, 2:36 p.m.
On Thu, May 28, 2015 at 01:08:20PM -0700, 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 a6113fe627b29a2d027a8247fc379ff8b934060f
> # Parent  f5088cab7b299553177fa0c2ad36b6abbb566b8e
> subrepo: detect issue3871 case earlier so it apply to bundle2

Queued with the bug number fixed (thanks to yuja for spotting it).

>
> We are doing some strange special casing of phase push when:
>
> - the source is a subrepo
> - the destination is publishing
> - some changeset are still draft on the destination
>
> In that case we do not push phases information (to publish the draft changesets)
> because it could break simple cycle of 'clone/pull/push' of subrepos. We have to
> detect this case earlier to have bundle2 respecting it.
>
> We change the test to check the behavior for both bundle1 and bundle2.
>
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

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