1

We are faced with a situation where we are maintaining two code bases in the same repository. The folder structure looks like this:

/WebRoot/

In our default branch the /WebRoot/ is very different from the /WebRoot/ in the Stable branch. The goal is to move /WebRoot/ from the Stable branch to /WebRoot/ in default branch. And the current default /WebRoot/ will become /WebRootX/. So in the end, all code will be in default and we won't have to switch back and forth between default and Stable branches when making changes in the two different code bases.

|      |      | 
|      |      |
|      --------
|      |      QA
|      |
-------|
|     Stable
|

default

I'm thinking that we have to use hg convert to move the Stable code out to a different (temp) repository. Then rename the default WebRoot to WebRootX. Then import the Stable /WebRoot/ folder back in.

I have done several tests and I'm not getting the desired results. I have tried using hg convert with the branchmap ("Stable default") to get the Stable branch out to a temp repository, but that's not working. I'm seeing code from default in there.

What is the best way to accomplish this?

4

1 回答 1

2

Before trying anything below first back up your repo.

Now you can try this: in the default branch, rename WebRoot to WebRootX. Commit this change.

Still in the default branch, merge in the stable branch using the internal:fail merge tool (what git calls a merge strategy):

hg merge --tool internal:fail stable

At this point, your working copy is in a state that, if committed, Mercurial will accept as a successful merge. But before you commit, you want to tell Mercurial to revert the entire WebRoot directory structure to its state in the stable branch, while at the same time not reverting anything that in the WebRootX directory structure:

hg revert --all -r stable -IWebRoot* -XWebRootX*

At this point you should have the WebRootX directory structure as it was in the default branch, while at the same time having the WebRoot directory structure as it was in the stable branch, and also preserving both their histories.

I have to warn you though I just roughly tested this out in a dummy repo and I'm not sure what results you'll get in a 'real' repo.

Some ideas from here.

于 2013-09-30T04:01:14.690 回答