[PATCH 2 of 4] dispatch: load shared source repository config in share-safe mode
Pulkit Goyal
7895pulkit at gmail.com
Fri Nov 20 08:47:05 UTC 2020
On Sat, Oct 17, 2020 at 9:15 AM Yuya Nishihara <yuya at tcha.org> wrote:
>
> On Fri, 16 Oct 2020 18:54:38 +0530, Pulkit Goyal wrote:
> > On Fri, Oct 16, 2020 at 6:48 PM Yuya Nishihara <yuya at tcha.org> wrote:
> > >
> > > On Fri, 16 Oct 2020 18:08:04 +0530, Pulkit Goyal wrote:
> > > > On Fri, Oct 16, 2020 at 4:27 PM Yuya Nishihara <yuya at tcha.org> wrote:
> > > > >
> > > > > On Fri, 16 Oct 2020 13:26:32 +0530, Pulkit Goyal wrote:
> > > > > > # HG changeset patch
> > > > > > # User Pulkit Goyal <7895pulkit at gmail.com>
> > > > > > # Date 1600435358 -19800
> > > > > > # Fri Sep 18 18:52:38 2020 +0530
> > > > > > # Node ID 03bb891ad7fffc564b5af73f8887c41f4eb0a7f3
> > > > > > # Parent 90e0e681dc5b94b1636417b7f5da75762a88572f
> > > > > > # EXP-Topic share-safe
> > > > > > dispatch: load shared source repository config in share-safe mode
> > > > >
> > > > > > +def _readsharedsourceconfig(ui, path):
> > > > > > + """if the current repository is shared one, this tries to read
> > > > > > + .hg/hgrc of shared source if we are in share-safe mode
> > > > > > +
> > > > > > + Config read is loaded into the ui object passed
> > > > > > +
> > > > > > + This should be called before reading .hg/hgrc or the main repo
> > > > > > + as that overrides config set in shared source"""
> > > > > > + try:
> > > > > > + with open(os.path.join(path, b".hg", b"requires"), "rb") as fp:
> > > > > > + requirements = set(fp.read().splitlines())
> > > > > > + if not (
> > > > > > + requirementsmod.SHARESAFE_REQUIREMENT in requirements
> > > > > > + and requirementsmod.SHARED_REQUIREMENT in requirements
> > > > > > + ):
> > > > > > + return
> > > > > > + hgvfs = vfs.vfs(os.path.join(path, b".hg"))
> > > > > > + sharedvfs = localrepo._getsharedvfs(hgvfs, requirements)
> > > > > > + ui.readconfig(sharedvfs.join(b"hgrc"), path)
> > > > >
> > > > > Maybe relative paths need to be resolved against shared wdir path, not the
> > > > > path of the current repo.
> > > >
> > > > Here, path of the current repo = shared wdir path.
> > > >
> > > > Let's say we have a repo `main` and we share it as `sharedrepo`. This
> > > > patch implements reading of `.hg/hgrc` of main repository when hg is
> > > > run in `sharedrepo`.
> > >
> > > I meant paths in main_repo_root/.hg/hgrc should be resolved relative to
> > > main_repo_root, not the current repo root.
> >
> > Isn't we are doing that by first getting the sharedvfs (which returns
> > main_repo_root/.hg) and join with that. Or you mean
> > `localrepo._getsharedvfs()` is not doing the correct thing?
>
> The path of the config file is correct, but its data are resolved against
> the "path" of the current repo by ui.readconfig(..., root=path). Since the
> config file is placed inside the main repo, relative paths in that config
> file should be resolved as if the file were read in the main repo.
Understood now, thank you! Will send a followup.
More information about the Mercurial-devel
mailing list