Adding hook on lookup

Yuya Nishihara yuya at tcha.org
Sun Jul 29 01:55:48 UTC 2018


On Sat, 28 Jul 2018 17:37:58 +0200, Cédric Krier wrote:
> On 2018-07-28 18:09, Yuya Nishihara wrote:
> > On Thu, 26 Jul 2018 09:53:46 +0200, Cédric Krier wrote:
> > > Until recently, I used the extension hgwebcachingproxy [1] to maintain
> > > local repositories as cache for our CI machines. But the extension does
> > > not work anymore with latest mercurial versions.
> > > So I found an easy replacement solution to maintain an up to date cache
> > > repository locally by using a hook like this (I do not need automatic
> > > creation):
> > > 
> > >     [hooks]
> > >     preoutgoing = hg pull
> > > 
> > > It works very well for `hg clone <path>` but it does not with a revision
> > > `hg clone -r <rev> <path>` (how our CI is cloning).
> > > With revision option, it does not work because a lookup is performed
> > > before the preoutgoing hook is triggered and so if the revision has not
> > > yet been pull, it raises an error.
> > > For now, I patched mercurial to trigger a hook on lookup command. Do you
> > > think it makes sense to have this hook in standard? If yes, what should
> > > be the name of this hook, 'lookup'?
> > 
> > I don't have a direct answer to your question, but maybe you can use the
> > "share.pool" feature to manage local cache of repositories.
> 
> Thanks, I know the share feature. It is very useful and I use it locally
> very often for branching.
> But it is not useful for my CI case. I may not have give enough
> information about the architecture. Our CI machine is on a different
> location than our mercurial server. The CI machine uses drone.io to
> build on each commit in a new docker image. So the first build step is
> to clone the repository with:
> 
>     hg clone -r 123456789 https://hg.tryton.org/trytond

Just to be clear, I meant "share.pool", not "hg share" command. If there's
a way to attach the pool directory on the CI machine to new docker instance
(by --mount, -v/--volume or NFS), "share.pool" can be used to keep the cache
sync with the master repository.

> To limit the load on the mercurial server, we redirect the https
> traffic on the build machine which serves a mirror of hg.tryton.org. So
> with the hooks, we just have to fetch the latest changeset locally once
> instead of downloading the full repository. With this setup we have
> reduced the bandwidth consumption per month of about 50Go.



More information about the Mercurial mailing list