#!/bin/sh set -e cwd=`pwd` basename=`basename $0` scratch_area="`echo $basename | sed -e s/\.sh$//`" repos=$scratch_area/repos trunk=$scratch_area/trunk branch=$scratch_area/branch feature1=$scratch_area/feature1 feature2=$scratch_area/feature2 rebase=$scratch_area/rebase trunk_url=file:///$cwd/$repos/trunk branch_url=file:///$cwd/$repos/branches/firstbranch feature1_url=file:///$cwd/$repos/branches/feature1 feature2_url=file:///$cwd/$repos/branches/feature2 rebase_url=file:///$cwd/$repos/branches/rebase set -x rm -rf $scratch_area mkdir -p $scratch_area mkdir -p $trunk echo alpha > $trunk/alpha echo beta > $trunk/beta mkdir $trunk/gamma echo delta > $trunk/gamma/delta mkdir $trunk/epsilon echo zeta > $trunk/epsilon/zeta svnadmin create $cwd/$repos svn import $trunk $trunk_url -m "importing project tree" svn copy --parents $trunk_url $branch_url -m "creating branch" rm -rf $trunk svn checkout $trunk_url $trunk svn checkout $trunk_url ${trunk}2 svn checkout $branch_url $branch # Create some mergeinfo using the branch we just created. # Make some changes in the branch, reintegrate and delete it. # This is done only to have some prior merge history in mergeinfo. # It may or may not be relevant to the problem. echo aaa >> $branch/alpha svn ci $branch -m "change branch" svn up $trunk svn merge --reintegrate $branch_url $trunk svn ci $trunk -m "reintegrated branch" svn rm $branch_url -m "remove branch" rm -rf $branch # Create a feature1 branch svn cp $trunk_url $feature1_url -m "create feature1 branch" svn co $feature1_url $feature1 echo bbb >> $feature1/beta svn ci $feature1 -m "work on feature1" # Do something on trunk echo zzz >> $trunk/epsilon/zeta svn ci $trunk -m "some work on trunk" # Sync feature1 branch to trunk svn up $feature1 svn merge $trunk_url $feature1 svn ci $feature1 -m "sync with trunk" # Create a feature2 branch, do some work on it svn cp $trunk_url $feature2_url -m "create feature2 branch" svn co $feature2_url $feature2 echo aaaa >> $feature2/alpha svn ci $feature2 -m "work on feature2" # Reintegrate the feature2 branch svn up $trunk svn merge --reintegrate $feature2_url $trunk svn ci $trunk -m "reintegrate bugfix from feature2 branch" # Keep the feature2 branch alive, we need to do more work still. # This creates mergeinfo on the feature2 branch for trunk. svn up $feature2 svn merge -c `svnlook youngest $repos` --record-only $trunk_url $feature2 svn ci $feature2 -m "block reintegration revision" # Sync the feature2 branch with trunk. # This creates more mergeinfo on the feature2 branch for trunk (though # nothing is actually merged). svn up $feature2 svn merge $trunk_url $feature2 svn ci $feature2 -m "sync with trunk" # Sync the feature1 branch with trunk. svn up $feature1 svn merge $trunk_url $feature1 svn ci $feature1 -m "sync with trunk" rebase_rev=`svnlook youngest $repos` # Management decided that feature1 should be merged with feature2. # feature1 is based on the code base of trunk, so we'll have some # integration work to do to merge with feature2. # So do a 'rebase' of the feature1 -- this means merging the diff # trunk->feature1 into the feature2 branch. svn up $feature2 svn merge $trunk_url@$rebase_rev $feature1_url $feature2 # Ooops... Why does the mergeinfo for trunk get reverted? # Without it, we cannot sync the feature2 branch to trunk anymore :( svn diff $feature2 svn pg -v -R svn:mergeinfo $feature2 # Alternative case, with a temporary integration branch, same problem: #svn cp $feature2_url $rebase_url -m "create rebase branch" #svn co $rebase_url $rebase #svn merge $trunk_url@$rebase_rev $feature1_url $rebase #svn diff $rebase #svn pg -v -R svn:mergeinfo $rebase