Repository relative paths in Mercurial .hgrc file
Asked Answered
G

1

10

I'm trying to create a shared hgrc file with common extensions for Mercurial, so my coworkers can get a consistent experience and find useful tools. Enabling extensions that don't ship with Mercurial, though, is causing issues.

My main repo's hgrc points to a source-controlled, shared .hgrc file:

\Repo.hg\hgrc

%include ..\tools\hg\dev.hgrc

The shared dev.hgrc then enables extensions we keep source-controlled:

\Repo\tools\hg\dev.hgrc

[extensions]
hgshelve=tools\hg\hgshelve\hgshelve.py
fold=tools\hg\hgfold\fold.py

The problem is those extensions are only found when hg is run from the root Repo directory. Running it from a subdirectory gives errors:

E:\Repo\src>hg
*** failed to import extension hgshelve from tools\hg\hgshelve\hgshelve.py: [Errno 2] No such file or directory
*** failed to import extension fold from tools\hg\hgfold\fold.py: [Errno 2] No such file or directory

I want to refer to the repository's root without relying on anything except the relative path structure.

I've looked in the manual, but don't see any repository relative path options there.

Gild answered 18/4, 2011 at 17:0 Comment(5)
We did a very similar thing at our company. Unfortunately we didn't find a solution to this and just worked around the problem. Everyone clones our hgtools repo to the same location $HOME/.hg-scripts/hgtools and then they %include that file in their $HOME/.hgrc file. All of the paths in the shared hgrc are full paths of the form $HOME/.hg-scripts/hgtools/... It's working for us, but it's not very elegant.Brazen
Thanks Mark. Nice to know that we're not alone.Gild
You guys will never get these things fixed if you don't write to the "real" Mercurial community: [email protected] -- while we are some developers that try to help out here, the majority of the Mercurial developers only read the mailinglists. (I think we should have a way to specify repository-relative paths, it would enable a lot of nice ways to use the %include directive.)Vatican
Thanks for the pointer. Pretty clear from mercurial.selenic.com/wiki/MailingLists that that's the right way to get heard by the Mercurial folks--they even mention StackOverflow by name...Gild
Did you ever email the list or get an answer to this question?Telugu
B
0

It's not quite what you're looking for, but if your systems are puppet, chef, or package controlled you can easily gin up a package that drops files in /etc/mercurial/hgrc.d/ anything in there is executed for all users on every run. You could put the extension .py files and the hgrc snippets to enable them down there.

Binnings answered 4/5, 2011 at 2:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.