subrepos - Mercurial 的子存储库是否可用于在存储库中推送多个项目?
我有 3 个项目:
D:\Projects\ProjectA\src\packA
D:\Projects\ProjectB\src\packB
D:\Projects\ProjectC\src\packC
我想将这 3 个项目的 3 个包存储在同一个远程存储库中。
我尝试在远程存储库的克隆中克隆这 3 个包:
D:\mercurial\DistantRepo\packA
D:\mercurial\DistantRepo\packB
D:\mercurial\DistantRepo\packC
然后我在 .hgsub 文件中将这 3 个包声明为子存储库:
packA = D:/Project/ProjectA/src/packA
packB = D:/Project/ProjectB/src/packB
packC = D:/Project/ProjectC/src/packC
我调用了 hg add
和 hg commit
命令。
但是,当我尝试将文件推送到我的远程存储库时,.hgsub 和 .hgsubstate 文件被推送到我的远程存储库,但我的包发生以下情况:
pushing to https://my.distant.repo
pushing subrepo packA to D:/Projects/ProjectA/src/packA
searching for changes
no changes found
pushing subrepo packB to D:/Projects/ProjectB/src/packB
searching for changes
no changes found
pushing subrepo packC to D:/Projects/ProjectC/src/packC
searching for changes
no changes found
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 1 changesets with 2 changes to 2 files
看来我误解了子存储库的工作原理...
是否使用子存储库坚持我的用例?我想做的事情可以怎样做?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
未发现任何更改
这意味着
packA
中没有D:/Projects/ProjectA/src/packA
中尚未存在的变更集。如果packA
中确实没有新内容,packA
推送到D:/Projects/ProjectA/src/packA
如果在怀疑问题
hg outguing D:/Projects/ProjectA/src/packA
insidepackA
目录以确定。该命令不应给出任何输出(=没有任何内容可发送)。路径
这些子存储库被推送到
D:/Projects/Project[ABC]/src/pack[ABC]
,因为您在 .hgsub 文件中为 Mercurial 提供了这些绝对 URL。最好将 .hgsub 更改为如下所示:并更改服务器,以便它
这是一个 推荐模式,因为您可以轻松地拥有此存储库的本地镜像克隆,而您在使用本地镜像的相对和绝对 URL 时会遇到麻烦(这是可能的,但很麻烦)。
作为旁注,您还可以考虑使用依赖项跟踪外部存储库(称为“thin shell存储库< /a>” 在 hg wiki 中),它将您的 pack* 存储库以及产品存储库嵌入为子存储库,因为它更清楚每个软件所属的位置。
编辑
在 Mercurial 中,每个产品只能拥有一个存储库,并且每个存储库位于服务器上的 URL 上。这意味着您需要为主产品和子存储库设置不同的远程存储库,因为您无法将不同子存储库的内容与产品存储库一起存储。
可以将这些不同的存储库
hg pull -f
合并到一个存储库中,但我建议不要这种做法。经过这样的拉取之后,在该存储库的历史中导航非常困难,因为不同来源的历史是混合的(例如,每次有人时,此存储库的尖端修订版都会在不同来源之间交换)推入其中)。仅当不同的子存储库共享一些共同的历史记录时才应使用此方法,但当它们没有任何共同点时最好将它们分开。No changes found
This means that there are no changesets in
packA
which are not already inD:/Projects/ProjectA/src/packA
. This is OK ifpackA
packA
toD:/Projects/ProjectA/src/packA
If in doubt issue
hg outguing D:/Projects/ProjectA/src/packA
inside of thepackA
directory to get sure. This command should give no output(=nothing to send).Paths
These subrepos are pushed to
D:/Projects/Project[ABC]/src/pack[ABC]
since you gave mercurial these absolute urls in the .hgsub file. It might be better to change .hgsub to read like the following:and change the server so that it serves
This is a recommended pattern, since you can easily have local mirror-clones of this repo, while you get trouble with relative and absolute URLs with local mirrors (it is possible, but cumbersome).
As a side note you might also consider to use a dependency-tracking outer repository ( called "thin shell repository" in the hg wiki), which embeds your pack* repos as well as the product repo as subrepos, since than it is more clear where each piece of software belongs to.
edit
In mercurial you can have only one repository per product, and on the server on URL per repository. This means that you need to set up different remote repositories for your main product and the subrepos, since you can't store the content of different subrepositories along with the product repository.
There is the possibility to
hg pull -f
these different repositories into one, but I advice against this practice. After such a pull it is very difficult to navigate in the history of this repository, since the history of the different sources are mixed (for example the tip revision of this repo swaps between the different sources every time someone pushes into it). You should only use this method, when the different subrepos share some common history, but it is better to keep them separated when they have nothing in common.