使用python api列出Mercurial repo中的所有Mercurial项目

使用python api列出Mercurial repo中的所有Mercurial项目,python,mercurial,Python,Mercurial,我想列出所有使用Mercurial和Python的项目。 我下载了“import hglib”软件包,但在文档、函数等中找不到。。。这对我有帮助。有人会知道怎么做 PS:我在这个链接中找到了一些信息: - - 但这不是我想要的…所以,我从你的问题中了解到的可能是,你想在mercurial回购中列出嵌套的存储库。更简单的说法是,您必须使用mercurial forest,并且您希望在下面列出子回购协议,似乎有一个名为hgnested的python包是为处理mercurial forest而编写的

我想列出所有使用Mercurial和Python的项目。 我下载了“import hglib”软件包,但在文档、函数等中找不到。。。这对我有帮助。有人会知道怎么做

PS:我在这个链接中找到了一些信息: - -


但这不是我想要的…

所以,我从你的问题中了解到的可能是,你想在mercurial回购中列出嵌套的存储库。更简单的说法是,您必须使用mercurial forest,并且您希望在下面列出子回购协议,似乎有一个名为hgnested的python包是为处理mercurial forest而编写的

我拿了一个补丁的代码,并用它来满足我们的需要,这就是我想出的

from mercurial import hg, ui
import hgnested

def getNestedRepos(ui, source, **opts):
    origsource = ui.expandpath(source)
    remotesource, remotebranch =hg.parseurl(origsource,opts.get('branch'))
    if hasattr(hg, 'peer'):
        remoterepo = hg.peer(ui, opts, remotesource)
        localrepo = remoterepo.local()
        if localrepo:
            remoterepo = localrepo
    else:
        remoterepo = hg.repository(hg.remoteui(ui, opts), remotesource)
    return remoterepo.nested

print getNestedRepos(ui.ui(), <path to mercurial forest>)
从mercurial导入hg,ui
导入hgnested
def getNestedRepos(用户界面,源代码,**选项):
origsource=ui.expandpath(源)
remotesource,remotebranch=hg.parseurl(origsource,opts.get('branch'))
如果hasattr(hg,peer'):
remoterepo=hg.peer(ui、opts、remotesource)
localrepo=remoterepo.local()
如果本地回购:
remoterepo=localrepo
其他:
remoterepo=hg.repository(hg.remoteui(ui,opts),remotesource)
返回remoterepo.nested
打印getNestedRepos(ui.ui(),)
但是还有另一种方法,您需要递归地访问所有子目录并查找.hg文件的存在


注意:如果要列出远程存储库中的repo,请确保该远程服务器中安装了hgnested软件包,并且您要传递的repo路径是mercurial forest head。

因此,我从您的问题中了解到的是,您可能想要列出mercurial repo中的嵌套存储库。更简单的说法是,您必须使用mercurial forest,并且您希望在下面列出子回购协议,似乎有一个名为hgnested的python包是为处理mercurial forest而编写的

我拿了一个补丁的代码,并用它来满足我们的需要,这就是我想出的

from mercurial import hg, ui
import hgnested

def getNestedRepos(ui, source, **opts):
    origsource = ui.expandpath(source)
    remotesource, remotebranch =hg.parseurl(origsource,opts.get('branch'))
    if hasattr(hg, 'peer'):
        remoterepo = hg.peer(ui, opts, remotesource)
        localrepo = remoterepo.local()
        if localrepo:
            remoterepo = localrepo
    else:
        remoterepo = hg.repository(hg.remoteui(ui, opts), remotesource)
    return remoterepo.nested

print getNestedRepos(ui.ui(), <path to mercurial forest>)
从mercurial导入hg,ui
导入hgnested
def getNestedRepos(用户界面,源代码,**选项):
origsource=ui.expandpath(源)
remotesource,remotebranch=hg.parseurl(origsource,opts.get('branch'))
如果hasattr(hg,peer'):
remoterepo=hg.peer(ui、opts、remotesource)
localrepo=remoterepo.local()
如果本地回购:
remoterepo=localrepo
其他:
remoterepo=hg.repository(hg.remoteui(ui,opts),remotesource)
返回remoterepo.nested
打印getNestedRepos(ui.ui(),)
但是还有另一种方法,您需要递归地访问所有子目录并查找.hg文件的存在

注意:如果要列出远程存储库中的repo,请确保该远程服务器中安装了hgnested软件包,并且要传递的repo路径是mercurial forest head