subrepos - Mercurial 的子存储库是否可用于在存储库中推送多个项目?

发布于 2024-12-03 11:50:07 字数 1204 浏览 3 评论 0 原文

我有 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 addhg 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

看来我误解了子存储库的工作原理...

是否使用子存储库坚持我的用例?我想做的事情可以怎样做?

I have 3 projects:

D:\Projects\ProjectA\src\packA
D:\Projects\ProjectB\src\packB
D:\Projects\ProjectC\src\packC

I want to store the 3 packages of these 3 projects in a same distant repository.

I tried to clone the 3 packages in the clone of my distant repository:

D:\mercurial\DistantRepo\packA
D:\mercurial\DistantRepo\packB
D:\mercurial\DistantRepo\packC

Then I declared these 3 packages as subrepositories in my .hgsub file:

packA = D:/Project/ProjectA/src/packA
packB = D:/Project/ProjectB/src/packB
packC = D:/Project/ProjectC/src/packC

I called the hg add and hg commit commands.

But when I try to push the files to my distant repository, the .hgsub and .hgsubstate files are pushed to my distant repository, but the following happen to my packages:

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

It seems I misunderstood how subrepositories work...

Does the use of subrepositories stick to my use case? How what I want to do may be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

慵挽 2024-12-10 11:50:07

未发现任何更改

pushing subrepo packA to D:/Projects/ProjectA/src/packA
searching for changes
no changes found

这意味着 packA 中没有 D:/Projects/ProjectA/src/packA 中尚未存在的变更集。如果

  • packA 中确实没有新内容,
  • 那么您已经将 packA 推送到 D:/Projects/ProjectA/src/packA

如果在怀疑问题 hg outguing D:/Projects/ProjectA/src/packA inside packA 目录以确定。该命令不应给出任何输出(=没有任何内容可发送)。

路径

这些子存储库被推送到 D:/Projects/Project[ABC]/src/pack[ABC] ,因为您在 .hgsub 文件中为 Mercurial 提供了这些绝对 URL。最好将 .hgsub 更改为如下所示:

packA = packA
packB = packB
packC = packC

# You can also insert something like packA = ProjectA/src/packA, the point
# is to declare all subrepos as subdirectories of the main repo

并更改服务器,以便它

  • 处提供原始产品
  • 在 / ProjectA/src/packA at /packA
  • ProjectB/src/packB at /packB
  • ProjectC/src/packC at / packC

这是一个 推荐模式,因为您可以轻松地拥有此存储库的本地镜像克隆,而您在使用本地镜像的相对和绝对 URL 时会遇到麻烦(这是可能的,但很麻烦)。

作为旁注,您还可以考虑使用依赖项跟踪外部存储库(称为“thin shell存储库< /a>” 在 hg wiki 中),它将您的 pack* 存储库以及产品存储库嵌入为子存储库,因为它更清楚每个软件所属的位置。

编辑

在 Mercurial 中,每个产品只能拥有一个存储库,并且每个存储库位于服务器上的 URL 上。这意味着您需要为主产品和子存储库设置不同的远程存储库,因为您无法将不同子存储库的内容与产品存储库一起存储。

可以将这些不同的存储库hg pull -f合并到一个存储库中,但我建议不要这种做法。经过这样的拉取之后,在该存储库的历史中导航非常困难,因为不同来源的历史是混合的(例如,每次有人时,此存储库的尖端修订版都会在不同来源之间交换)推入其中)。仅当不同的子存储库共享一些共同的历史记录时才应使用此方法,但当它们没有任何共同点时最好将它们分开。

No changes found

pushing subrepo packA to D:/Projects/ProjectA/src/packA
searching for changes
no changes found

This means that there are no changesets in packA which are not already in D:/Projects/ProjectA/src/packA. This is OK if

  • There is really no new stuff in packA
  • you already pushed packA to D:/Projects/ProjectA/src/packA

If in doubt issue hg outguing D:/Projects/ProjectA/src/packA inside of the packA 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:

packA = packA
packB = packB
packC = packC

# You can also insert something like packA = ProjectA/src/packA, the point
# is to declare all subrepos as subdirectories of the main repo

and change the server so that it serves

  • the original product at /
  • ProjectA/src/packA at /packA
  • ProjectB/src/packB at /packB
  • ProjectC/src/packC at /packC

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文