Jump to content

Swapping main and child branch


WDNichols

Recommended Posts

I have a main branch, representing work on a new version that has been abandoned.

 

There are child versions branched from the main branch each time a new major version is released. The most recent child branch is named "4.10". "4.9" is the name of the branch before that. Both branch directly from main.

 

Since the newest version has been abandoned, I would like to be able to swap the main branch and "4.10" branch with one another starting with the change set on main where "4.10" originally branched.

 

 

 

Let me provide an example. Suppose the main branch has change sets 1 through 20.

 

And a /main/4.10 branch was created off of change set 10. On that child branch, change sets 21 through 29 were checked in. 

 

After swapping the main and /main/4.10 branches as described above, this is what I expect:

 

The /main branch through change set 10 will be unchanged. But after that, the main branch will include change sets 21 through 29, and will NOT include change sets 11 through 20.

 

The /main/4.10 branch (or whatever the branch may now be called) will branch off the /main branch off of change set 10 (as before). But after that the /main/4.10 branch WILL include change sets 11 through 20 and will NOT include change sets 21 through 29.

 

 

Can this be done?

 
Link to comment
Share on other sites

Hi!

 

moving changesets is not possible, that's being said our resources for achieving what you want are the merge, subtractive merge and cherrypick.

 

Original situation:

post-112-0-67383100-1377602874_thumb.png

Original situation compressed:

post-112-0-79915200-1377602879_thumb.png

Target situation:

post-112-0-15253100-1377602865_thumb.png

Target situation compressed:

post-112-0-20347100-1377602870_thumb.png

 

Let's review what I did:

 

#1

Operation: Interval subtractive merge from 10 to 20 -> Result is cset 30 on main branch.

Result: The main branch is now NOT containing the changes from 11 to 20.

#2

Operation: Interval subtractive merge from 10 to 29 -> Result is cset 31 on 4.10 branch.

Result: The 4.10 branch is now NOT containing the changes from 21 to 29.

#3

Operation: Interval cherrypick from 10 to 29 -> Result is cset 32 on main branch.

Result: The main branch is now containing the changes from 21 to 29. Request #1 resolved

#4

Operation: Interval cherrypick from 10 to 20 -> Result is cset 33 on 4.10 branch.

Result: The 4.10 branch is now containing the changes from 11 to 20. Request #2 resolved

 
Tell me if it works for you and don't hesitate to ask if you have any question.
Link to comment
Share on other sites

  • 2 weeks later...

I tried a variation of your suggestion and was able to get close to what I wanted.

 

My actual goal was to make the main branch look like the 4.10 branch (not to make the 4.10 branch look like the main branch), so I only followed steps #1 and #3.

 

And for step #3, I used a standard merge of the change set from the top of the 4.10 branch to the main branch. Also, I created a sub-branch off the tip of the main branch to do this work. So the subtractive merged was checked in first on the sub-branch (step #1). Then the merge from 4.10 was checked in on the sub-branch (step #3). 

 

However, after steps #1 and #3, the contents of the tip of the main branch were NOT the same as the original tip of the 4.10 branch. There were 148 files that were not the same (out of about 2500 files) and another 34 that were missing entirely from the workspace. Of the 34 missing files, most of these files (perhaps all) were added on the 4.10 branch and were never touched on the main branch. In fact, most of them have only three entries in their history:

  • The add on the 4.10 branch
  • And two removes on the main* branch

* The first remove was the check-in I did of the subtractive merge on the sub-branch. The second remove occurred when I merged that sub-branch back to the main branch, after all of the changes were complete.

 

I was able to recover the missing files, and the restore the 148 files with missing changes by comparing a copy I had made of the tip of the 4.10 branch before I started this operation, to the workspace after step #3. I then applied the differences (the missing 34 files and the missing changes to the other 148 files) to the workspace, and checked those changes in on the sub-branch, before merging the sub-branch in to the main branch. But now, the history for those 34 files indicates that they were added today, and not on the 4.10 branch.

 

Why were these 34 files not included in the merge from the 4.10 branch?

Link to comment
Share on other sites

OK, I tried again, this time following your instructions more closely.


 


I still only followed steps #1 and #3, but for step #3 I used cherry pick merge, not a regular merge. 


 


And this time, I was not prompted to resolve any merge conflicts, and the resulting work space matched exactly the original tip of the 4.10 branch. 


 


So, the moral of this story is that your instructions, IF FOLLOWED, did what I needed.


 


Thanks for your help.


Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...