Patchwork [15,of,25,RFC] phase: enforce internal phase support

login
register
mail settings
Submitter Boris Feld
Date June 7, 2018, 2:11 p.m.
Message ID <ef202521c3c3389198ff.1528380674@Laptop-Boris.lan>
Download mbox | patch
Permalink /patch/32009/
State Accepted
Headers show

Comments

Boris Feld - June 7, 2018, 2:11 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1527610399 -7200
#      Tue May 29 18:13:19 2018 +0200
# Node ID ef202521c3c3389198ff917e11dcb7847de3658d
# Parent  d6ac390e2ebdf51f095168fe314dd956db09e2b9
# EXP-Topic internal-phase
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ef202521c3c3
phase: enforce internal phase support

We should not use the internal phase for repository without the requirement.
Otherwise older client could have a look at the repository and see the internal
changesets.

For now we introduce a low level Programming error, more UI friendly error will
be introduced later.
Augie Fackler - June 25, 2018, 4:44 p.m.
> On Jun 7, 2018, at 10:11, Boris Feld <boris.feld@octobus.net> wrote:
> 
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1527610399 -7200
> #      Tue May 29 18:13:19 2018 +0200
> # Node ID ef202521c3c3389198ff917e11dcb7847de3658d
> # Parent  d6ac390e2ebdf51f095168fe314dd956db09e2b9
> # EXP-Topic internal-phase
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ef202521c3c3
> phase: enforce internal phase support

I'm going to drop this whole series for now, but many thanks for sending it. My comfort level is to make sure the internal phase gets a much higher number, so we've got room in the future for new phases (an "archived" phase has already been discussed, for example).

I've queued a few things from phabricator that make sense, and we'll come back to this series when you're ready. Sound good?

Thanks!
Boris FELD - July 2, 2018, 3:49 p.m.
Hello, coming back from vacation.

I've seen part of the series queued, is there a reason for the two last 
commits to not being queued yet?

Please drop the current RFC series, we will send the new series with a 
higher number for the internal phase after the refactoring series has 
fully landed.

On 25/06/2018 18:44, Augie Fackler wrote:
>
>> On Jun 7, 2018, at 10:11, Boris Feld <boris.feld@octobus.net> wrote:
>>
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1527610399 -7200
>> #      Tue May 29 18:13:19 2018 +0200
>> # Node ID ef202521c3c3389198ff917e11dcb7847de3658d
>> # Parent  d6ac390e2ebdf51f095168fe314dd956db09e2b9
>> # EXP-Topic internal-phase
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ef202521c3c3
>> phase: enforce internal phase support
> I'm going to drop this whole series for now, but many thanks for sending it. My comfort level is to make sure the internal phase gets a much higher number, so we've got room in the future for new phases (an "archived" phase has already been discussed, for example).
>
> I've queued a few things from phabricator that make sense, and we'll come back to this series when you're ready. Sound good?
>
> Thanks!
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Augie Fackler - July 2, 2018, 5 p.m.
> On Jul 2, 2018, at 11:49, Boris FELD <lothiraldan@gmail.com> wrote:
> 
> Hello, coming back from vacation.
> 
> I've seen part of the series queued, is there a reason for the two last commits to not being queued yet?

I just didn't have time to review. I'd appreciate it if you could rebase and update the remaining patches that are refactors (just to be on the safe side), and get more of the refactoring prep-work changes (if there are any) on phabricator so I can burn through them in a single batch once I have some time.

(This week is a holiday in the US, so reviewer bandwidth may be somewhat limited - I'll try to get to these tomorrow, but I can't make promises.)

> 
> Please drop the current RFC series, we will send the new series with a higher number for the internal phase after the refactoring series has fully landed.
> 
> On 25/06/2018 18:44, Augie Fackler wrote:
>> 
>>> On Jun 7, 2018, at 10:11, Boris Feld <boris.feld@octobus.net> wrote:
>>> 
>>> # HG changeset patch
>>> # User Boris Feld <boris.feld@octobus.net>
>>> # Date 1527610399 -7200
>>> #      Tue May 29 18:13:19 2018 +0200
>>> # Node ID ef202521c3c3389198ff917e11dcb7847de3658d
>>> # Parent  d6ac390e2ebdf51f095168fe314dd956db09e2b9
>>> # EXP-Topic internal-phase
>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ef202521c3c3
>>> phase: enforce internal phase support
>> I'm going to drop this whole series for now, but many thanks for sending it. My comfort level is to make sure the internal phase gets a much higher number, so we've got room in the future for new phases (an "archived" phase has already been discussed, for example).
>> 
>> I've queued a few things from phabricator that make sense, and we'll come back to this series when you're ready. Sound good?
>> 
>> Thanks!
>> 
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Boris FELD - July 2, 2018, 8:15 p.m.
On 02/07/2018 19:00, Augie Fackler wrote:
>
>> On Jul 2, 2018, at 11:49, Boris FELD <lothiraldan@gmail.com> wrote:
>>
>> Hello, coming back from vacation.
>>
>> I've seen part of the series queued, is there a reason for the two last commits to not being queued yet?
> I just didn't have time to review. I'd appreciate it if you could rebase and update the remaining patches that are refactors (just to be on the safe side), and get more of the refactoring prep-work changes (if there are any) on phabricator so I can burn through them in a single batch once I have some time.
>
> (This week is a holiday in the US, so reviewer bandwidth may be somewhat limited - I'll try to get to these tomorrow, but I can't make promises.)

The phabricator stack has been updated, the two remaining patches were 
the only one remaining ones of the refactoring series.

>
>> Please drop the current RFC series, we will send the new series with a higher number for the internal phase after the refactoring series has fully landed.
>>
>> On 25/06/2018 18:44, Augie Fackler wrote:
>>>> On Jun 7, 2018, at 10:11, Boris Feld <boris.feld@octobus.net> wrote:
>>>>
>>>> # HG changeset patch
>>>> # User Boris Feld <boris.feld@octobus.net>
>>>> # Date 1527610399 -7200
>>>> #      Tue May 29 18:13:19 2018 +0200
>>>> # Node ID ef202521c3c3389198ff917e11dcb7847de3658d
>>>> # Parent  d6ac390e2ebdf51f095168fe314dd956db09e2b9
>>>> # EXP-Topic internal-phase
>>>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>>>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ef202521c3c3
>>>> phase: enforce internal phase support
>>> I'm going to drop this whole series for now, but many thanks for sending it. My comfort level is to make sure the internal phase gets a much higher number, so we've got room in the future for new phases (an "archived" phase has already been discussed, for example).
>>>
>>> I've queued a few things from phabricator that make sense, and we'll come back to this series when you're ready. Sound good?
>>>
>>> Thanks!
>>>
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel@mercurial-scm.org
>>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -130,6 +130,10 @@  mutablephases = tuple(allphases[1:])
 remotehiddenphases = tuple(allphases[2:])
 localhiddenphases = tuple(allphases[3:])
 
+def supportinternal(repo):
+    """True if the internal phase can be used on a repository"""
+    return 'internal-phase' in repo.requirements
+
 def _readroots(repo, phasedefaults=None):
     """Read phase roots from disk
 
@@ -422,6 +426,9 @@  class phasecache(object):
     def _retractboundary(self, repo, tr, targetphase, nodes):
         # Be careful to preserve shallow-copied values: do not update
         # phaseroots values, replace them.
+        if targetphase == internal and not supportinternal(repo):
+            msg = 'this repository does not support the internal phase'
+            raise error.ProgrammingError(msg)
 
         repo = repo.unfiltered()
         currentroots = self.phaseroots[targetphase]
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -832,8 +832,38 @@  Try various actions. only the draft move
 Test for the "internal" phase
 =============================
 
-  $ hg init internal-phase
+Check we deny its usage on older repository
+
+  $ hg init no-internal-phase --config format.internal-phase=no
+  $ cd no-internal-phase
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  revlogv1
+  store
+  $ echo X > X
+  $ hg add X
+  $ hg status
+  A X
+  $ hg --config "phases.new-commit=3" commit -m "my test internal commit" 2>&1 | grep ProgrammingError
+  ** ProgrammingError: this repository does not support the internal phase
+      raise error.ProgrammingError(msg)
+  mercurial.error.ProgrammingError: this repository does not support the internal phase
+
+  $ cd ..
+
+Check it works fine with repository that supports it.
+
+  $ hg init internal-phase --config format.internal-phase=yes
   $ cd internal-phase
+  $ cat .hg/requires
+  dotencode
+  fncache
+  generaldelta
+  internal-phase
+  revlogv1
+  store
   $ mkcommit A
   test-debug-phase: new rev 0:  x -> 1
   test-hook-close-phase: 4a2df7238c3b48766b5e22fafbb8a2f506ec8256:   -> draft