Mercurial:获取有关存储库的信息而不克隆它们
几天前,我开始尝试 Mercurial,一切都很顺利,直到我决定尝试编写一个小程序,该程序从远程服务器获取存储库列表和每个存储库的变更集 ID 列表,允许用户选择存储库并变更集,克隆它并更新到所选的修订版。这引发了两个问题:
- 有没有办法从服务器获取存储库列表(除了解析 HTML)?
- 有没有一种方法可以获取有关某个存储库的信息,例如标签、分支等,而无需先实际克隆它?
Few days ago I started experimenting with Mercurial, and everything went great, until I decided to try writting a small program, that gets the list of repositories and lists of changeset IDs for each repository from a remote server, allows the user to pick repository and changeset, clones it and updates to the chosen revision. This led to two questions:
- Is there a way to get a list of repositories from server (besides parsing HTML)?
- Is there a way to get information, such as tags, branches, etc. about one of the repositories, without actually cloning it first?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,Mercurial 的设计使您需要一个用于几乎所有命令的本地存储库。唯一能为您提供有关远程存储库信息的内置命令是
hg id
:要获取更多信息,您有时可以利用
的
:raw
模板hgweb这要求主机运行 Mercurial 附带的
hgweb
CGI 脚本。对于像 Bitbucket 这样的网站,您需要使用他们的 API。最后,如果您可以在远程存储库上启用扩展,那么就可以编写一个扩展,以可解析的格式公开您想要的信息。我曾经写过这样的扩展作为演示。
No, Mercurial is designed so that you need a local repository for almost all commands. The only built-in command that will give you information about a remote repository is
hg id
:To get hold of more information you can sometimes exploit the
raw
template forhgweb
:That requires that the host is running the
hgweb
CGI script that comes with Mercurial. For a site like Bitbucket you would need to use their API.Finally, if you can enable extensions on the remote repository, then it's possible to write an extension that exposes the information you want in a parsable format. I once wrote such an extension as a demo.