列出 Mercurial 中的远程分支
有没有办法像 Git 一样在 Mercurial 中列出远程分支?
git branch -r
我想列出远程计算机(例如 Bitbucket)上的分支,因此使用:
hg branches -R `hg showconfig paths.default` --color false
失败并中止:存储库不是本地的
Is there a way to list remote branches in Mercurial like there in Git?
git branch -r
I want to list the branches on a remote machine (e.g. Bitbucket), so using:
hg branches -R `hg showconfig paths.default` --color false
fails with abort: repository not local
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Mercurial API 允许这样做:
上面的代码片段生成:
The mercurial API allows it:
The above snippet produces:
不,如果不将远程存储库克隆到本地,则无法列出远程存储库的分支。
如果可以通过 SSH 访问具有远程存储库的计算机,则可以直接使用 Mercurial:
ssh server hg -R path/to/repobranch
。如果存储库由 hgweb 提供服务,则可以使用原始样式从中获取分支列表以便于解析: https://www.mercurial-scm.org/repo/hg/branches?style=raw
BitBucket 有自己的 API,可以在其中获取分支,请参阅他们的帮助并对类似 https://api.bitbucket.org/1.0/repositories/mirror/mercurial/branches/
No, it is not possible to list branches of a remote repository without cloning it to local.
If there is SSH access to the machine having the remote repository, then Mercurial could be used directly:
ssh server hg -R path/to/repo branches
.If the repository is served with hgweb, then a list of branches can be fetched from that, using the raw style for easy parsing: https://www.mercurial-scm.org/repo/hg/branches?style=raw
BitBucket has its own API, where it is possible to get the branches, see their help and make a query like to a URL like https://api.bitbucket.org/1.0/repositories/mirror/mercurial/branches/
要扩展 @gvalkov 的答案,您可以通过编写文件
rheads.py
使其成为真正的扩展:在
~/.hgrc
中配置时,您可以像这样运行它:
我尝试使其成为可以在任何存储库外部调用的命令,只需指定 URL 作为参数,但无法使语法正常工作:
To expand on @gvalkov’s answer, you can make this a real extension by writing a file
rheads.py
:When configured in
~/.hgrc
withyou can run it like:
I tried to make it a command that can be invoked outside any repository, just specifying the URL as an argument, but could not get the syntax to work:
也许您正在寻找
hg传入-B
这对我来说效果很好。这会显示书签。maybe you are looking for
hg incoming -B
This worked quite well for me. This shows the bookmarks.请注意,这不会显示仅远程分支,它只会显示本地存储库知道的分支。
作为谷歌搜索“hg 命令时出现的唯一相关问题行列表分支”,我想我应该把它留在这里。当您运行以下命令时 -
hg log | grep “分支”| grep -v“摘要”| sort --unique
它输出;
Please note, this will not display remote only branches, it will only show branches that your local repository is aware of.
As the only relevant question to appear when googling "hg command line list branches", I thought I'd leave this here. When you run the following -
hg log | grep "branch" | grep -v "summary" | sort --unique
it outputs;