Mercurial API : reading config over https

标签 mercurial mercurial-api

在 Mercurial API 中,是否有任何方法可以读取与您通过 HTTPS 访问的存储库关联的配置值?存储库的 ui 对象似乎没有保存它们。

最佳答案

简短的回答是“不”。无法使用 Mercurial API 通过 HTTP 从存储库读取配置值。这些值永远不会通过网络传输。更详细的解释如下。


ui.ui() 类提供对系统、用户和本地存储库配置值的访问。

>>> from mercurial import hg, ui
>>> u = ui.ui()
>>> u.configlist('ui', 'username')
['Your', 'Name', '<<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e891879d9aa88d85898184c68b8785" rel="noreferrer noopener nofollow">[email protected]</a>>']

存储库对象的构造函数需要提供ui对象和path

ui 中的值被复制到存储库对象中。

如果 path 是本地存储库,则可以通过 repo.ui 访问该存储库的配置设置。但是,如果 path 是 URL,则 API 不会向远程服务器查询配置设置。在这种情况下,repo.ui 仅包含系统和用户设置。

>>> 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')
[]

关于 Mercurial API : reading config over https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10952853/

相关文章:

python - Mercurial API : how do I get the 40 digit revision hash from incoming command?

python - 我需要编写一个 python 脚本来提取给定 2 个日期的 Mercurial 存储库详细信息

python - 应该如何管理 '.hg/' 状态目录中的 hook 特定文件?

mercurial - 如何使用 'hg log' 列出一系列修订?

svn - 什么 VCS 允许我同时向多个待定提交添加更改?

version-control - 提交变更集后创建 hg 书签

python - 如何向 Mercurial 扩展中的现有命令添加命令选项?

mercurial - 必须是 root 才能推送/提交到 Mercurial 存储库

mercurial - 执行 hg update 后如何获得更详细的更改?