Is it safe to merge between feature branches in SVN?

If two developers each create a feature branch from the backbone, is it safe for them to "synchronize the merge" between their feature branches as well as from the outside, and then still be able to reintegrate each item branch into the backbone without issue?

By "sync merge" I mean a command of the form "svn merge ^ / Project1 / trunk" and "svn merge ^ / Project1 / branch / other-feature-branch", where the svn: mergeinfo property will keep track of what has been merged from each location.

The reason I am asking is because I read the documentation in several places that suggest that switching to the same revisions on a branch will cause conflict issues (although I don't see anywhere that explains why this should be the case) ... If so, the above scenario should be problematic because each feature branch will sync to the trunk as well as the other feature branch, so any changes made on the trunk are obtained both directly and syncing to the trunk, and also when syncing with another feature branch (which may have already picked up the same trunk changes).

However, in the testing I have done, it works great, but I would like to get some expert confirmation before recommending this as a workflow for our team.

@nosid: answer to nosid in this edit because the funny character limit on SO prevents a 4 sentence comment. What is this Twitter?

I have read the documentation. The problem is that it describes a very simple scenario where only one destabilizing function is processed at a time, and where the destabilizing work is done in the function branch and all other work is done on the trunk. In this scenario, it is trivial to keep the function branch in sync with the trunk.

However, in a more realistic scenario, a product can easily have several serious destabilizing jobs at once. What is the process of synchronizing these parts of the work so that they can synchronize on demand with the trunk and with each other, but without breaking the changes imposed on them?

+3


source to share


3 answers


This is not the case, feature branches should be used in Subversion. A simple example test shows that this approach will cause problems later. Follow these steps:

  • Create a new repository.
  • Creation and fixation of the initial structure (connector, branches, tags).
  • Create and commit two new (empty) trunk branches with svn cp -m 'new branch' ^/trunk ^/branches/a

    and the corresponding command for ^/branches/b

    .
  • Add and commit a new file to the branch b

    .
  • Merge changes from branch b

    to branch a

    with svn merge ^/branches/b

    . I haven't made any changes to the trunk, so there is nothing to combine.
  • Rebuild and fix the branch a

    on the outside line with svn merge --reintegrate ^/branches/a

    .
  • Merging changes from trunk to branch b

    with svn merge ^/trunk

    .
  • You will now see a tree conflict in the file you added earlier.


The Subversion documentation details the recommended use of feature branches. See the following link: Branches of functions . A functional branch is usually created from a trunk. You commit your changes to feature branches and continually merge changes from the trunk into your feature branch (with svn merge ^/trunk

). And once you are done with your work, you reintegrate the branch into the trunk (with help svn merge --reintegrate ^/branches/name

). After reintegration, the feature branch is deprecated and should no longer be used.

+4


source


If you synchronize both branches of traits with each other, which point has two?



They will be essentially the same.

0


source


Here I take the OP's question. You may notice some parallels with the testing steps suggested by other sources to determine the answer to the question, but I came to a different conclusion.

Here's my reprogramming script:

#----------------------------------------------------------------------
# Test whether merging between feature branches in SVN results in
# tree conflicts, as claimed elsewhere:
#   http://stackoverflow.com/questions/10015249
#----------------------------------------------------------------------
export REPO=file:///tmp/merge-test/repo

#----------------------------------------------------------------------
# Create a new repository.
#----------------------------------------------------------------------
echo Creating a new repository ...
cd /tmp
rm -rf merge-test
mkdir merge-test
cd merge-test
svnadmin create repo

#----------------------------------------------------------------------
# Create and commit the initial structure (trunk, branches, tags).
#----------------------------------------------------------------------
echo Creating initial structure ...
svn mkdir $REPO/trunk -m "Initializing trunk"
svn mkdir $REPO/branches -m "Initializing branches"
svn mkdir $REPO/tags -m "Initializing tags"

#----------------------------------------------------------------------
# Create and commit two new branches of the (empty) trunk.
#----------------------------------------------------------------------
echo Creating two new branches of the empty trunk ...
svn cp $REPO/trunk $REPO/branches/a -m "branch a"
svn cp $REPO/trunk $REPO/branches/b -m "branch b"
svn co $REPO/trunk
svn co $REPO/branches/a
svn co $REPO/branches/b

#----------------------------------------------------------------------
# Add and commit a new file on branch b.
#----------------------------------------------------------------------
echo Adding and committing a new file on branch b ...
cd b
echo testing > foo
svn add foo
svn ci -m "committing new file"

#----------------------------------------------------------------------
# Merge the changes from branch b to branch a.
#----------------------------------------------------------------------
echo Merging the changes from branch b to branch a ...
cd ../a
svn merge ^/branches/b
svn commit -m "merged b into a"

#----------------------------------------------------------------------
# Reintegrate and commit branch a on the trunk.
#----------------------------------------------------------------------
echo Reintegrating and committing branch a back to the trunk ...
cd ../trunk
svn merge --reintegrate ^/branches/a
svn ci -m "merged a back into trunk"

#----------------------------------------------------------------------
# Merge the changes from the trunk to branch b.
#----------------------------------------------------------------------
echo Merging the changes from the trunk to branch b ...
cd ../b
svn up
svn merge ^/trunk
svn ci -m "refreshing b from trunk"

#----------------------------------------------------------------------
# Look for a tree conflict on the file added earlier.
#----------------------------------------------------------------------
echo Looking for tree conflicts for the file added earlier ...
svn status

      

There is no result from the last (svn status) command, which supposedly means no tree conflicts. As far as I can tell, there is no explicit statement in http://svnbook.red-bean.com/ to indicate that merging between branches will cause problems (outside of normal conflicts, merging can occur, including merging between branch and trunk). If anyone has any evidence that cross-industry link merging is more problematic than merging in general, I would be very interested to examine that evidence. Until then, I tend to advise the OP that in practice there is nothing dangerous.

0


source







All Articles