Check whether a configuration key is set globally, rather than on the current repository
Matt Mackall
mpm at selenic.com
Thu Feb 23 18:25:57 UTC 2012
On Thu, 2012-02-23 at 17:23 +0100, Angel Ezquerra Moreu wrote:
> Hi,
>
> I am working on an extension and I need to tell if a given
> configuration key is set globally, but is not set on the current
> repository's configuration file.
>
> The reason is that I want to use the global configuration as a
> fallback, and I want the extension to behave differently depending on
> whether the setting that is being used is the fallback, versus the
> case in which the setting has been explicitly set on the current
> repository.
Sounds like too much magic.
> As far as I know, there is no way to read the "current repo"
> configuration only using the mercurial ui API. The "config" methods of
> the repo.ui object try to read from the current repo config, and if
> they fail they seamlessly read from the global configuration (which is
> what you'd want 99.9...% of the time).
>
> Yet in my very particular case this is not what I need. The only way
> that I've come up with is to read both from the current repo.ui object
> and from the global ui object, and if both configuration values match
> assume that the configuration key is set globally. However this would
> not detect the case in which the same configuration value is set both
> globally and on the current repo.
You can check the path information in the config key (see hg showconfig
--debug).
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list