Local clones and phases, mq (Re: [PATCH 1 of 5 phases] phases: exclude secret when doing a local clone)

Matt Mackall mpm at selenic.com
Sat Jan 14 19:46:23 CST 2012

On Fri, 2012-01-13 at 02:42 +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> # Date 1326299187 -3600
> # Node ID 3f56f39a5135f2253bdd8c14afe1e52a08b96ffc
> # Parent  c47d69ce5208d5b5cfd2fb2f0f1d7a2b4795fbf5
> phases: exclude secret when doing a local clone
> This is achieved by denying copy clone when any secret changeset exist.

Queued, thanks.

But this reminds me of something that I've been meaning to discuss (but
haven't brought up for fear of muddying the waters further). If you have
a repo that you can clone via either copy or hardlink, then we might
want to consider loosening our semantics a bit. In particular, if you
have direct filesystem access to a repo, you can see all the secret
changesets, so they're really not secrets FROM YOU. Should we just go
ahead and clone everything keeping the same states in such a case?

One invariant you could claim for clone is that if you compare what
csets you can see in the src and dst, they should match. So if Bob looks
at Alice's hgweb, he gets all the changesets he can see (ie not her
secret ones). But if he clones from his own repo, he sees stuff go
missing. And then there's the intermediate case where he clones from
Alice over NFS: he can see Alice's secrets, but should he clone 

Related: when you clone a local repo with mq patches, you currently get
a repo with all the mq patches effectively qfinished. If we make mq
csets secret and then refuse to clone them locally, our clone is even
less complete. Arguably we should instead clone the mq state/queue (and
corresponding phases) locally.

So enforcing phases here means local clones are a) less useful b) slower
and c) heavier than they could be.

I'm honestly not sure what the right answer is here, and we can probably
revisit this in the future.

> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -626,6 +626,10 @@
>      def local(self):
>          return self
> +    def cancopy(self):
> +        return (repo.repository.cancopy(self)
> +                and not self._phaseroots[phases.secret])
> +
>      def join(self, f):
>          return os.path.join(self.path, f)
> diff --git a/tests/test-phases.t b/tests/test-phases.t
> --- a/tests/test-phases.t
> +++ b/tests/test-phases.t
> @@ -164,6 +164,17 @@
>    4 changesets found
>    $ cd ..
> +Test secret changeset are not cloned
> +(during local clone)
> +
> +  $ hg clone -qU initialrepo clone-dest
> +  $ hglog -R clone-dest
> +  4 0 B'
> +  3 0 D
> +  2 0 C
> +  1 0 B
> +  0 0 A
> +
>  Test revset
>    $ cd initialrepo

Mathematics is the supreme nostalgia of our time.

More information about the Mercurial-devel mailing list