Following @Ry4an's suggestion, here is an example that works for me. I add this to my ~/.hgrc
file so it works everywhere.
[hooks]
# This hook adds "%include ../.hgrc" to .hg/hgrc if the .hgrc file exists in
# the top level. This allows one to store a set of paths for example.
# See
update = if [ -e .hgrc ] && touch .hg/hgrc \
&& ! grep -q '%include \.\./\.hgrc' .hg/hgrc; then \
echo '%include ../.hgrc' >> .hg/hgrc; \
fi
This hook adds the line %include ../.hgrc
to the .hg/hgrc
file iff the file .hgrc
exists in the top level of the repo. Note that by using the update
hook, we bypass the issue of the with post-clone
clone hook of having to try to figure out the directory name of the target clone from environmental variables.