Question

In the Mercurial API, is there any way to read the configuration values associated with a repository that you're accessing over HTTPS? The repository's ui object doesn't seem to hold them.

Was it helpful?

Solution

The short answer is "no". There is no way to read the config values from a repo over HTTP using the Mercurial API. These values are never transmitted over the network. A more detailed explanation follows.


The ui.ui() class provides access to system, user and local repository config values.

>>> from mercurial import hg, ui
>>> u = ui.ui()
>>> u.configlist('ui', 'username')
['Your', 'Name', '<your@email.com>']

The constructor for a repository object requires a ui object and a path to be provided.

The values from ui are copied into the repo object.

If path is a local repository, then the config settings for that repository may be accessed via repo.ui. However if path is a URL, the API does not query the remote server for config settings. In that case, repo.ui only includes the system and user settings.

>>> repo = hg.repository(ui.ui(), '.')
>>> repo.ui.configlist('paths', 'default')
['https://www.mercurial-scm.org/repo/hg']

... start an hg serve session at http://localhost:8000 ...

>>> repo = hg.repository(ui.ui(), 'http://localhost:8000')
>>> repo.ui.configlist('paths', 'default')
[]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top