2010-11-28 67 views
25

有沒有辦法在Git中列出Mercurial中的遠程分支?在Mercurial中列出遠程分支

git branch -r 

我想列出遠程機器(例如到​​位桶)在樹枝上,所以使用:

hg branches -R `hg showconfig paths.default` --color false 

失敗,中止:倉庫不在本地

回答

18

不,這是不可能的列出遠程存儲庫的分支,而不將其克隆到本地。

如果通過SSH訪問具有遠程存儲庫的機器,則可以直接使用Mercurial:ssh server hg -R path/to/repo branches

如果版本送達hgweb,然後跳轉列表可以從獲取,使用原始風格,方便解析:https://www.mercurial-scm.org/repo/hg/branches?style=raw

到位桶都有自己的API,它是可能得到的樹枝見their help並進行查詢喜歡就好https://api.bitbucket.org/1.0/repositories/mirror/mercurial/branches/

+0

是的,這就是我所懷疑的。感謝有關hgweb和bitbucket的信息。 – Raoul 2010-12-08 14:10:17

+0

我想知道爲什麼mercurial這樣設計?我可以使用`hg id -r `獲得特定分支的修訂,但不能獲得所有分支的列表。 – neverov 2012-06-22 15:14:48

18

善變的API的URL允許它:

from mercurial import ui, hg, node 

peer = hg.peer(ui.ui(), {}, 'http://hg.python.org/cpython') 
for name, rev in peer.branchmap().items(): 
    print name, node.short(rev[0]) 

上面的代碼中產生:

default aaa68dce117e 
legacy-trunk b77918288f7d 
3.2 4787b9b2f860 
3.0 4cd9f5e89061 
3.1 5a6fa1b8767f 
2.3 364638d6434d 
2.2 61b0263d6881 
2.1 e849d484029f 
2.0 5fd74354d73b 
2.7 260f3ad7af4b 
2.6 f130ce67387d 
2.5 b48e1b48e670 
2.4 ceec209b26d4 
1

爲了擴大對@ gvalkov的回答,您可以讓這個真正的擴展寫入文件rheads.py

from mercurial import hg, commands, cmdutil, node 
cmdtable = {} 
command = cmdutil.command(cmdtable) 
@command('rheads', commands.remoteopts, 'hg rheads [SOURCE]') 
def rheads(ui, repo, source='default', **opts): 
    """print (possibly remote) heads 

    Prints a series of lines consisting of hashes and branch names. 
    Specify a local or remote repository, defaulting to the configured remote. 
    """ 
    other = hg.peer(ui or repo, opts, ui.expandpath(source)) 
    for tag, heads in other.branchmap().iteritems(): 
     for h in heads: 
      ui.write("%s %s\n" % (node.short(h), tag)) 

~/.hgrc配置了

[extensions] 
rheads = …/rheads.py 

你可以像運行:

hg rheads 

我試圖使它可在任何存儲庫外部調用,只需指定URL作爲參數的命令,但不能得到語法工作:

commands.norepo += " rheads" 
1

也許你正在尋找hg incoming -B這相當奏效爲了我。這顯示書籤。