First, I have a very large cvs repository and I’m trying to switch things over to mercurial. The cvs repository consists of several directories, sort of like the situation in this question. However, each subdirectory is not an entire independent project. Each project uses a subset of the whole but their intersections are not empty.
Here’s an example to clarify:
/cvsroot
.../core
.../feature-1
.../feature-2
Project 1 uses core and feature-1; project 2 uses core and feature-2. I don’t want people who work on project 2 to have the feature-1 directory in their working copies, because it’s actually a set of about 30 directories and a not insignificant amount of space.
Is there a way to deal with this easily (or, alternatively, well) with mercurial? I thought about using a separate repository for the intersection, but that’s suboptimal. It means doing an extra pull and extra updates and probably writing a bunch of scripts to manage it.
My other alternative was replicating the intersection in each. That’s no good though because it’s likely to cause the common code to fork, since different people work on different parts of it.
Using Mercurial subrepositories should help here. I would define
core,feature-1, andfeature-2as independent repositories and then link them together using the subrepository feature. Project 1 would pull incoreandfeature-1, while Project 2 would pull incoreandfeature-2. Each of the underlying repos only exists once, so different projects are effectively sharing them.You can configure the subrepos so that when Project 1 performs a commit and push, it pushes to both
coreandfeature-1, or you can require the user to commit to them explicitly by navigating into the directory and treating them like a normal repo.Finally, you can only create subrepos on a repository level. In other words, you can’t create them on a per file level.