How to correctly update a function branch from a trunk?

The SVN book says :

...Another way of thinking about this pattern is that your weekly sync of trunk to branch is analogous to running svn update in a working copy, while the final merge step is analogous to running svn commit from a working copy

I find this approach very impractical in major events for several reasons, mainly related to the reintegration phase.

  • From SVN v1.5, merging is done rev-by-rev. Cherry-selection of areas that need to be combined will force us to resolve conflicts between branches twice (one when merging versions of chests with FB and again when merging).
  • Repository size: changes in the chests can be significant for a large code base, and copying the difference files (as opposed to the SVN copy) from the trunk elsewhere can be significant overhead.

Instead, we do what we call "re-branching." In this case, when a significant part of the trunk changes is required, a new function branch opens from the current trunk, and the merge is always down (function branches → trunk → stable branches). This is not in line with the recommendations for SVN books, and developers consider this an additional pain.

How do you deal with this situation?

+7
svn
source share
5 answers

After the study:

After many brainstorming sessions in VisionMap, discussions about F2F, including Artyom, opening the SVN book portfolio, etc. - It looks like it's impossible. A functional branch is completely different from a working copy. The only working way to update it is to recreate a new branch, as described above.

+1
source share

From SVN v1.5, merging is done rev-by-rev. Cherry-selection of areas that need to be combined will force us to resolve conflicts between branches and branches twice (one when combining versions of chests with FB and again when merging)

Then you are doing something wrong!

We'll see:

 trunk fb ---------\ r1-10 | r11-20 | r20-30 | 

As a rule, if you want to make changes made in 11-20, it is best to merge 1-20 in fb and that's it.

Then, when fb is executed, merge 20-30, and then copy fb to the trunk (without merging!).

If you decide to merge only r11: 20, ok, in the end you will need to combine r1: 10 and r20: 30 and then copy fb to the trunk.

Unable to merge changes twice!

I assume that you are likely to follow these steps:

 copy trunk->fb merge 11:20 -> fb. merge fb-1:30 -> trunk !!!!! WRONG 

You cannot do this because you merge 11:20 twice. You should always combine code in one direction only.

The right way:

 copy trunk->fb merge 1:20 -> fb. merge 21:30 -> fb (now fb=trunk+feature) copy fb -> trunk 

Edit

So the correct steps are:

  • Create a function (FB) branch from the trunk (copy the trunk to the svn-copy branch)

     FB_0=trunk_0 
  • Work on FB.

     FB_1=FB_0 + change_a 
  • Merge all upcoming changes externally on FB.

     trunk_1=trunk_0 + tr_change_a; FB_2 = FB_1 + (trunk_1 - trunk_0) == trunk_0 + change_a + tr_change_a 
  • Work on FB

     FB_3 = FB_2 + change_b 
  • Merge all upcoming unrelated changes from the trunk to the FB.

     trunk_2=trunk_1 + tr_change_n; FB_4 = FB_3 + (trunk_2 - trunk_1) == trunk_0 + change_a + change_b + tr_change_a + tr_change_b 
  • At this moment, we have a feature branch consisting of all the new functions and all the changes in the connecting line. Therefore, we simply copy the difference between the two branches.

     trunk_3 = trunk_2 + (FB_4 - trunk_2) = FB_4 = trunk_0 + change_a + change_b + tr_change_a + tr_change_b 

    Now the FB is deleted, as trunk has all the changes we need.

    The last step is done:

     svn merge /path/to/trunk@LatestRev /path/to/branches/fb@LatestRev . svn ci 

    Or in ordinary language, they take the difference between the chest and the branch and put them in the trunk making them equivalent.

This template is described at http://svnbook.red-bean.com/en/1.4/svn.branchmerge.commonuses.html#svn.branchmerge.commonuses.patterns.feature

Now, if this does not work for you, I do not understand the question.

Edit2: For svn-1.5

When working with svn-1.5 you can combine much easier:

When you work with a function branch, you simply change the changes from time to time:

 $ svn merge /path/to/trunk Solve conflicts $ svn ci 

He will line up your FB with all the changes in the trunk. At the end of the FB, you follow this procedure again to make sure everything is up to date. You go into the trunk and run

 $ svn merge --reintegrate /path/to/fb $ svn ci 

In the latter case, there should be no conflict if you work as shown.

+3
source share

We are a small company, so I do not know if our decision will apply to your situation. What we do is switch between a chest and a stable branch. We can do this in two different ways: - Actually we need to fix it, we merge only after - Dangerous correction / change. We will wait a few days until the change is checked in the trunk, and then we can combine

With this continuous merger, we avoid a ton of conflict.

My 2 cents.

0
source share

Unfortunately, all of the above can be considered as hacks. Updating from a trunk on a branch can lead to very serious problems when returning to the trunk and opens up the possibility for the worst of all conflicts, tree conflicts. This is because directories are not considered first-class citizens. The best approach is to use Mercurial with the SVN Extension as a standard SVN client. This allows you to continue to use SVN while gaining the processing power of Mercurial files.

Then, on the wworkstation side, you can use a number of approaches that provide many features to satisfy many situations compared to SVN. You can use regular patches, update queues, updates from a local copy of the trunk without affecting the common trunk, and various other approaches.

This approach works around all sides of SVN. I had to switch to this approach due to similar circumstances. Even if you do not use this approach right away, you should at least give it a try as soon as possible.

0
source share

I think I need to get clubs for @Artyom here. I also think that if you need

resolve trunk conflicts twice

something is wrong. And I think the @Artyoms argument / solution is strong enough.

I believe one of the minor things that @Artyom could write more clearly is that at the end, where you “copy” fb to trunk , you are not using svn copy , but svn merge (or svn merge --reintegrate ), This may be the reason that the template was not found in the General branching patterns .

Since I'm struggling with understanding what you are doing so far, I'm not sure what else to say.

Here is what I hear:

Instead, we do what we call "Re-Branching." In this case, when a significant part of the changes in the chests is necessary to open a new branch of functions from the current body, ...

Now you have a new branch (let's call it b2) that is equivalent to the trunk, right? And where is “a significant portion of chest changes needed”? I guess in fb?

... and the merge is always down (function branches → trunk → stable branches).

But since you just created b2 from the trunk, there is nothing to merge with the trunk, no? And you do not merge the changes from b2 to fb (since it will be the same as merge trunk into fb ...). So how do “significant chunks of change” get into fb? And once they are there, why do you want to combine them back into the trunk (since this is where they came from in the first place)?

Actually, the following links are the “Manual Merge Tracking” section and / or the “Merging an entire branch into another” section , presented in the SVN 1.4 documentation (I know you do not use SVN 1.4, but I believe that it’s the same) in the General section branch patterns can help clarify some things. These links are "missing" in the 1.5 documentation (probably due to the new --reintegrate option in merge ).

It seems that you seem to be merging the same changes twice, and I really think you don't need (need to) do this.

0
source share

All Articles