Check whether a configuration key is set globally, rather than on the current repository

Angel Ezquerra Moreu angel.ezquerra at gmail.com
Thu Feb 23 10:23:34 CST 2012


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.

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.

Is there any other better solution?

Thanks,

Angel


More information about the Mercurial-devel mailing list