views:

75

answers:

1

I'm trying to determine how people use "branch repositories" while also using subrepos.

Let's say I have repo Main containing a solution file (.NET), and populated with subrepos A, B, C:

/Main
    - A
    - B
    - C
    MainSolution.sln

A, B, and C, while being shared between other "Main" repos, are very tightly integrated into Main project. Thus, a major feature to the Main repo will require modifications to the subrepos (i.e., they are shared libraries, but are very actively developed).

Now it is time to add a feature. This feature is too big for one person to handle, and thus the code will need to be pushed to the central repo so others can help. We'd also need to be able to go back to the last "stable" code before the feature development began in case a bugfix is needed. I believe I have two options at this point: (1) create a named branch in the Main repo, or (2) create a new clone of Main. Since there are subrepos, both of these options have repercussions not present typically.

Option 1) Creating a named branch will, I presume, allow modifications to the subrepos to be committed/pushed, but only other people who have also updated to that branch in their clone of Main will be affected, since the .hgsubstate file is tracked. However, the subrepos will get a new head, and thus the (possibly) experimental feature would end up getting pushed to the central repo. Am I understanding this correctly?

Option 2) There are numerous advocates for the "don't use named branches, use 'branch repositories'", which are literally clones of the main repo, but named differently and existing on the central server. This is a little appealing to me, as it seems to keep things separated (and thus detached from disaster as co-workers --and myself!-- are still learning Mercurial). But this workflow seems completely broken when subrepositories are involved, since creating a clone of the Main repo does not create new, separated clones of the subrepos. It's a new clone, but it's still pointing at the same subrepos, and thus changes made to them will find their way back into the subrepos! I realize this is by design, and it's one of the really cool things (to me) about Mercurial. But how on earth do people use this branch repository workflow with subrepositories? It is completely inconceivable that, for each feature/experiment/version/whatever, I'm going to create a new clone (on the central server) of the Main repo, AND create clones (on the central server) of the subrepos, AND modify all the .hgrc/.hgsub paths to point to the proper central repos.

At this point, I'm just trying to understand HOW people work on a complicated project and use subrepos with branch repositories. Any thoughts?

A: 

I prefer named branches for features that will most likely eventually get merged into the default branch. It is much easier to switch branches than switch repos.

With named branches you never need to worry about accidentally pushing your unstable branch of development into the stable repo. The named branch is already there, but won't be retrieved via an update unless a developer asks for it.

Mark Borgerding
Two things.When you say a named branch won't be retreived unless a dev asks for it, do you mean the dev's working copy won't be modified unless that branch is checked out, or are you referring to something else? It was my understanding that all branches were pushed/pulled automatically.Also, the root question isn't really about whether to use named branches vs branch repos, but rather how one uses branch repositories when also using subrepositories.But thanks for the response!
Andrew
Named branch(es) will be retrieved with a "hg pull", but the developers working directories will not be updated to a different branch without them explicitly updating to it e.g. "hg up -r <branchname>". It seems to me that the best path to take is the one that is hardest for a developer to mess up. The "genie out of the bottle" problem that occurs when separate branch repos get accidentally pushed together makes me believe that named branches in a single repo are preferable. YMMV.Admittedly, I probably missed some of the added complexity that comes with subrepos. Best of luck!
Mark Borgerding