开发者

subrepos - Does Mercurial's subrepositories can be used to push multiple project in a repository?

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:

pushi开发者_如何学编程ng 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜