Mercurial:无需克隆即可获取有关存储库的信息 [英] Mercurial: get information about repositories without cloning them

查看:84
本文介绍了Mercurial:无需克隆即可获取有关存储库的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我开始尝试使用Mercurial,直到一切顺利,直到我决定尝试编写一个小程序,该程序可以从远程服务器获取存储库列表和每个存储库的变更集ID列表,从而使用户能够选择存储库和变更集,将其克隆并更新到所选修订版.这导致了两个问题:

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:

  1. 是否有一种方法可以从服务器获取存储库列表(除了解析HTML外)?
  2. 有没有一种方法可以获取有关其中一个存储库的信息,例如标签,分支等,而无需先将其克隆?

推荐答案

否,Mercurial的设计目的是使您几乎所有命令都需要一个 local 存储库.唯一可以为您提供有关远程存储库信息的内置命令是hg id:

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:

$ hg id https://bitbucket.org/aragost/javahg/
3b2711b26dbd

要获取更多信息,有时可以利用raw模板作为hgweb:

To get hold of more information you can sometimes exploit the raw template for hgweb:

$ wget -q -O - 'https://www.mercurial-scm.org/repo/hg/tags?style=raw' | head 
tip     a3a36bcf122e2ea4edbbe4ac44da59446cf0ee07
4.2.1   c850f0ed54c1d42f9aa079ad528f8127e5775217
4.2     bb96d4a497432722623ae60d9bc734a1e360179e
4.2-rc  616e788321cc4ae9975b7f0c54c849f36d82182b
4.1.3   77eaf9539499a1b8be259ffe7ada787d07857f80
4.1.2   ed5b25874d998ababb181a939dd37a16ea644435
4.1.1   25703b624d27e3917d978af56d6ad59331e0464a
4.1     e1526da1e6d84e03146151c9b6e6950fe9a83d7d
4.1-rc  a1dd2c0c479e0550040542e392e87bc91262517e
4.0.2   e69874dc1f4e142746ff3df91e678a09c6fc208c

这要求主机正在运行Mercurial随附的hgweb CGI脚本.对于类似Bitbucket的网站,您需要使用其API .

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.

这篇关于Mercurial:无需克隆即可获取有关存储库的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆