我想列出所有使用Mercurial和Python的项目。我下载了"import hglib“包,但在文档、函数等中找不到...这对我有帮助。有人会知道怎么做呢?
PS:我在这个链接中找到了一些信息:- https://www.mercurial-scm.org/wiki/MercurialApi - http://pythonhosted.org/hgapi/index.html#hgapi.hgapi.Repo.command
但这不是我要找的..。
发布于 2017-05-12 15:14:41
所以,我从你的问题中理解的是,你可能想要列出mercurial存储库中的嵌套存储库。在更简单的术语中,您必须使用mercurial森林,并且您希望在下面列出子代码库,并且似乎有一个名为hgnested的python包是为处理mercurial森林而编写的。
我拿了一小段代码,用它来满足我们的需求,这就是我想出来的。
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>)
但是还有另一种方法,你需要递归地访问所有子目录,并查找是否存在.hg文件。
注意:如果您想要列出来自远程存储库的存储库,请确保该远程服务器中安装了hgnested包,且您传递的存储库路径是mercurial林头。
https://stackoverflow.com/questions/39871252
复制相似问题