[PATCH] subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)

Augie Fackler raf at durin42.com
Mon Oct 16 16:31:48 EDT 2017


On Mon, Oct 16, 2017 at 11:36:22PM +0900, Yuya Nishihara wrote:
> On Mon, 16 Oct 2017 09:21:24 -0400, Matt Harbison wrote:
> > # HG changeset patch
> > # User Matt Harbison <matt_harbison at yahoo.com>
> > # Date 1508122082 14400
> > #      Sun Oct 15 22:48:02 2017 -0400
> > # Node ID d0c2b68fedb27184337af6392ecc1f03dab39522
> > # Parent  718adb1bf3a9a1ee509a803c7512c14296a1db79
> > subrepo: share instead of clone if the parent repo is shared (issue5675) (BC)
>
> Generally looks good to me, but a few questions.
>
> > --- a/mercurial/hg.py
> > +++ b/mercurial/hg.py
> > @@ -255,6 +255,7 @@
> >      r = repository(ui, destwvfs.base)
> >      postshare(srcrepo, r, bookmarks=bookmarks, defaultpath=defaultpath)
> >      _postshareupdate(r, update, checkout=checkout)
> > +    return r
> >
> >  def postshare(sourcerepo, destrepo, bookmarks=True, defaultpath=None):
> >      """Called after a new shared repo is created.
> > diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
> > --- a/mercurial/subrepo.py
> > +++ b/mercurial/subrepo.py
> > @@ -857,28 +857,40 @@
> >
> >      def _get(self, state):
> >          source, revision, kind = state
> > +        parentrepo = self._repo._subparent
> > +
> >          if revision in self._repo.unfiltered():
> > -            return True
> > +            # Allow shared subrepos tracked at null to setup the sharedpath
> > +            if revision != node.nullhex or not parentrepo.shared():
>
> 'revisions != node.nullhex' looks a bit tricky, which seemed to assume a
> certain sequence how the current subrepo clone works under the hood.
>
> Can we check 'len(self._repo) != 0' instead?

That seems like a safer check to me.


More information about the Mercurial-devel mailing list