使用Bitbucket的子仓库功能

5

尝试将子存储库推送到Bitbucket时,我遇到了这个错误:

D:\Work\agile.crm.framework>hg push
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7
c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cace
rts config setting)
http authorization required
realm: Bitbucket.org HTTP
user: the_drow
password:
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7
c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cace
rts config setting)
pushing to https://the_drow@bitbucket.org/the_drow/agile.crm.framework
pushing subrepo Logging to https://the_drow@bitbucket.org/the_drow/agile.crm.fra
mework/Logging
warning: bitbucket.org certificate with fingerprint 81:2b:08:90:dc:d3:71:ee:e0:7
c:b4:75:ce:9b:6c:48:94:56:a1:fe not verified (check hostfingerprints or web.cace
rts config setting)
abort: HTTP Error 404: NOT FOUND

我遇到了这个描述如何解决问题的链接,但我不明白该怎么做。 我应该把我的Logging子仓库放置在D:\Work\吗? 关于Mercurial子路径我应该做什么?这样做能让我本地克隆吗?
编辑: 根据要求,以下是我的.hgsub文件的内容。
Logging = Logging

你能发布一下你的.hgsub文件内容吗? - Tim Henigan
我认为除了你标记为正确的答案之外,还有更好的答案。你不应该根据某个网站的限制来决定放置存储库的位置。只需使用特殊目的的重写规则来适应该网站的特定限制即可。 - Omnifarious
2个回答

13

正如您在发布的链接中所指出的那样,"您必须使子存储库成为主存储库的同级目录。"

因此,在BitBucket上,您需要以下结构:

https://bitbucket.org/the_drow/agile.crm.framework
https://bitbucket.org/the_drow/Logging

那么你在 agile.crm.framework 目录中的 .hgsub 文件需要包含以下内容:

Logging = ../Logging


2
那我必须打开另一个存储库吗?这有点违背了这里的目的。 - the_drow
6
@the_drow:添加子仓库意味着该子仓库是一个具有自己历史记录的独立 [项目|库|其他]。如果您不打算在多个项目中使用Logging仓库,则它本应不是子仓库。如果您确实想在许多项目之间共享它,则需要为其分配自己的空间。 - Tim Henigan

9

我要翻译一个老问题,因为我认为我有更好的解决方案。我理解为什么@the_drow对原始的接受答案有问题,因为使用Logging = ../Logging时,您的本地机器必须将Logging子存储库作为包含/主存储库的同级。从组织的角度来看,这有点违背了子存储库的目的。然而,如果您使用subpaths功能,您可以让Mercurial在推送时为您重写URI:

external/my_subrepo = external/my_subrepo

[subpaths]
([https://|ssh://hg@])bitbucket\.org/moswald/my_project/external/my_subrepo = \1bitbucket.org/moswald/my_subrepo

现在,我的本地副本存储在my_project中的my_subrepo 子仓库内,但是当我提交到Bitbucket时,它会被重定向到真正的子仓库。实际上,你可以使用这个重写功能指向几乎任何地方,因为Mercurial理解Git和SVN。我有很多Bitbucket存储库,其中包含其他作者使用Github的子仓库。

2
小心!这让我困惑了:只有第一个URL中的句号被转义!等号左边:bitbucket.org - 等号右边:bitbucket.org - martind2112
好的,没错。是的,这个确实很难准确地搞定。:+1: - moswald

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接