Git / Subversion backporting function

What would be the preferred way to achieve the next workflow using Git or Subversion (I have more interest in the Git version, but comparison will certainly be useful):

  • Say, we recently had a large release of a product, and there is a special branch of polysychine called release-2.0.x .

    Then development continued and several feature branches were merged into master/trunk (they will later become part of the upcoming release-2.1.x ).

  • Now, at some point, another function was developed (namely, critical-feature ) and combined with master/trunk . We understand that this function is so important that we must pass it to release-2.0.x .


Here is a small pseudographic illustration for the case described. Please note that everything on top leads to tree differences between release-2.0.x and current master/trunk and leads to problems with merging (otherwise I could just merge the critical-feature and not write this question :)

  (features added since 2.0.x, which should not be backported) ^ ^ ^ | | | (code refactorings done | | | in master/trunk) \ | / (*) (*) (*) -------------------------------------------------------> master/trunk | | | | | | \ release-2.0.x \ critical-feature (should be backported) 

Questions:

  • What would be the best way to perform backporting from a VCS perspective?

  • If this is done as a simple merge corresponding critical-feature branch with conflict resolution conflicts?

  • Or should it be done as a cherry-pick commit that integrates the critical-feature into master/trunk when it is done? Or maybe even as a set of cherry-picks for each commit in critical-feature branches?

  • Could you advise something for the conflict resolution procedure? What if the current difference between release-2.0.x and master/trunk so great that naive backporting leads to a huge amount of conflicts due to code refactoring and missing functions or API that were added after release-2.0.x ?

  • Does Git or Subversion have anything specific to offer this procedure other than the standard merge or cherry approach? I assume that reloading will not be useful if the number of conflicts is huge, but obviously I could be wrong.

+8
git merge merge-conflict-resolution svn
source share
3 answers

The whole idea of ​​backporting functions seems broken for me. Only critical and non-destructive changes should be considered. For features and enhancements, you need to create a new branching period and begin stabilization.

Check out the release process used by the Apache Subversion project itself: https://subversion.apache.org/docs/community-guide/releasing.html#release-stabilization

+2
source share

It depends. If the critical feature is relatively simple and small, you can just make some cherry blanks. However, of course, this can cause a lot of merge conflicts, since the implementation of this function may use reorganized code. However, as I understand it, this will be the easiest solution. And only a solution for SVN.

However, this decision does not reflect the action on the history chart; it is confusing.

With git, there is another option to rebase a critical function on the merge-base core and release-2.0.x branches. This literally means that you must override the function using the old code, which is common to both branches. In this case, you could combine the rebased function. If you already combined this function with the wizard, when you combine the reinstall function into the wizard, it will most likely conflict (because the wizard already has such an implementation). This way you will resolve conflicts, but in most cases it will be easy, because the changes should be almost the same.

The good thing about the “fabricated” approach is that if you find an error in it, you can fix it in function branches and easily merge corrections into a release and main branches.

Of course, rebooting can cause a lot of conflicts, but this means that there is no easy way to enable this feature in release-2.0.x . Maybe it would be easier to just reimplement it then.

+2
source share

I developed some tools specifically to facilitate this process with git, and last week I wrote an extensive blog article about them. In particular, the git cherry-menu command referenced by this post can accept an arbitrary list of commits for backup, so using git log and your favorite text editor, you can create a fairly carefully selected list of commits that make up the critical backported function. and then run something like:

 git checkout -b release-2.0.y release-2.0.x git cherry-menu cat commits-to-backport.txt 

This is similar to the suggestion of reinstalling kan, except that the backporting process is more structured, and using the git notes under the hood, you get several convenient additional functions, including the fact that all metadata describing the process is saved for several git cherry-menu runs.

Of course, if you only have a few backup commits, kan is right that you can just simply select the cherry directly.

Unfortunately, I think the accepted answer is a bit contradictory:

The whole idea of ​​backporting features looks broken for me. Only critical and non-destructive changes should be considered. For features and enhancements, you need to create a new branching period and begin stabilization.

because the creation of a new branch and the beginning of the stabilization period is still the opposite. The only difference is which branch you decide to put backup transactions in! You can either put them in the source branch release-2.0.x , or a branched branch, like the branch release-2.0.y above. It’s generally safer / cleaner to do the latter (and I think that Ivan points out), but actually it depends on how you organize your repositories and branches. He still does not avoid the need to make cherry picks and potential conflict resolution.

+2
source share

All Articles