Relative Path Names for extensions in hgrc

A. S. Budden abudden at gmail.com
Tue Apr 10 11:49:37 CDT 2012


On 8 April 2012 20:31, Mads Kiilerich <mads at kiilerich.com> wrote:
> A. S. Budden wrote, On 04/08/2012 08:18 PM:
>
>> All,
>>
>> It would be really useful (for me) if I could use relative path names
>> when loading extensions in hgrc.
>
>
> This is almost TL;DR and hard to quote properly. But as far as I can see you
> are only discussing global configuration - not configuration specific or
> relative to the actual repo.

That's correct.

> In general regarding the subject of relative paths in hgrc: There seems to
> be some inconsistencies in this area, and Matt requested an audit in
> http://markmail.org/message/fcgvz5zij62triwk . The core issue is to figure
> out what relative paths are relative to.

Sounds like a complex job.

> One backward compatible workaround could be to introduce some
> '$HG_CONFIGFILE' pseudo variable that could be used to specify that an
> otherwise relative path is relative to the config file it is specified in.
> (Yes, that is almost what you proposed.) (Another handy and potentially
> dangerous variable could perhaps be $HG_ROOT.)

$HG_CONFIGFILE would certainly work for me (or $HG_CONFIGFILEDIR so I
don't need some sort of dirname() somewhere?).  Given the discussion
in the mailing list thread you linked to, do you think this would be a
welcome patch?  I'm guessing (possibly incorrectly) that it is simply
a case of adding something to os.environ so it should be trivial to
implement (as long as it is parsed immediately and not after all files
have been %included).  If it is not parsed immediately, it would
presumably be a case of a simple r'\$HG_CONFIGFILEDIR\b' regexp
substitution.

> See also http://selenic.com/hg/rev/4e3eda05189b regarding silent failing
> imports. The commit message is not very helpful, but you might be able to
> find some mailing list discussion. I suggest starting a new thread if you
> want to discuss that particular behaviour.

I'm not that bothered: now I know about it I have created a file
called (literally) $HOSTNAME.hgrc with "It appears that HOSTNAME has
not been set or exported in bashrc." in: if HOSTNAME isn't exported I
get

    hg: parse error at /home/al/config/hg_config/$HOSTNAME.hgrc:1: It
appears that HOSTNAME has not been set or exported in bashrc.

which at least tells me what's wrong!  Interestingly, I expected it to
be expanded as .hgrc rather than $HOSTNAME.hgrc if $HOSTNAME is unset,
but apparently not.

Al

-- 
http://www.cgtk.co.uk


More information about the Mercurial-devel mailing list