Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVN 1.8 merge (branch reuse) seems broken when having local mergeinfo

We have a problem with the new 1.8 subversion clients (we use TortoiseSVN 1.8.5 & SlikSVN 1.8.5). It seems that the new SVN 1.8 feature of being able to keep using your feature branch after reintegration is not working in some cases.

It is not working when the trunk contains local mergeinfo (Mergeinfo on files or sub-trees). This may cause a problem for branch reuse after the reintegrate. This wasn't a problem with 1.7 clients if branch reuse was done using the 'keep alive dance' (using the record only option).

I have made a script that illustrates this problem from scratch. It can be run against an empty repository using a 1.8 client.

The script below has 10 steps. Step 1-5 are used to create the starting situation of having local mergeinfo in the trunk. Steps 6-9 simulate changes being made to the trunk during the life of a feature branch2. Step 10 is the failing step which simulates the first step of reuse of the feature branch after reintegrate.

This is the error in step 10:

svn: E195016: Reintegrate can only be used if revisions 8 through 11 were pre
viously merged from svn://svn2010/practice/branches/featurebranch2 to the reinte
grate source, but this is not the case:
  trunk/file1.txt
    Missing ranges: /trunk/file1.txt:9

This is the (Windows) script.

@ECHO OFF
ECHO ------------------------------------------------------------------
ECHO STEP 0: Create a repository
ECHO ------------------------------------------------------------------
if exist repo rmdir repo /S/Q
if exist trunk rmdir trunk /S/Q
if exist featurebranch1 rmdir featurebranch1 /S/Q
if exist featurebranch2 rmdir featurebranch2 /S/Q
svnadmin create repo --compatible-version 1.8
REM Make url based on current directory and replace backslashes by forward slashes
set url="file:///%cd:\=/%/repo"
ECHO url=%url%

ECHO ------------------------------------------------------------------
ECHO STEP 1: Create a trunk with 2 files
ECHO ------------------------------------------------------------------
svn mkdir -m "Create trunk" %url%/trunk
svn checkout %url%/trunk
echo Original file contents created in the trunk. > trunk\file1.txt
echo Original file contents created in the trunk. > trunk\file2.txt
svn add trunk\file1.txt
svn add trunk\file2.txt
svn -m "Added 2 files" commit trunk

ECHO ------------------------------------------------------------------
ECHO STEP 2: Create a copy (feature branch) from the trunk
ECHO ------------------------------------------------------------------
svn mkdir -m "Create branches dir" %url%/branches
svn copy -m "Create featurebranch1" %url%/trunk %url%/branches/featurebranch1

ECHO ------------------------------------------------------------------
ECHO STEP 3: Modify both files in the feature branch
ECHO ------------------------------------------------------------------
svn checkout %url%/branches/featurebranch1
echo Additional file contents created in featurebranch1. >> featurebranch1\file1.txt
echo Additional file contents created in featurebranch1. >> featurebranch1\file2.txt
svn -m "Modified 2 files in featurebranch1" commit featurebranch1

ECHO ------------------------------------------------------------------
ECHO STEP 4: Merge both files from featurebranch1 to the trunk to 
ECHO         create local mergeinfo on both files
ECHO ------------------------------------------------------------------
svn update trunk
svn merge %url%/branches/featurebranch1/file1.txt trunk/file1.txt
svn merge %url%/branches/featurebranch1/file2.txt trunk/file2.txt
svn -m "Merged 2 files from featurebranch1 to trunk" commit trunk

ECHO ------------------------------------------------------------------
ECHO STEP 5: Delete featurebranch2, we only needed it for the
ECHO         initial setup
ECHO ------------------------------------------------------------------
svn delete -m "Delete featurebranch1" %url%/branches/featurebranch1

ECHO ------------------------------------------------------------------
ECHO STEP 6: This is the start of the problematic scenario
ECHO         Create a new featurebranch2 from the trunk and a wc for it
ECHO ------------------------------------------------------------------
svn copy -m "Create featurebranch2" %url%/trunk %url%/branches/featurebranch2
svn checkout %url%/branches/featurebranch2

ECHO ------------------------------------------------------------------
ECHO STEP 7: Modify the contents of file1.txt in the trunk and leave
ECHO         the contents of file2.txt unchanged (this is important)
ECHO ------------------------------------------------------------------
echo Additional file contents created in the trunk. >> trunk\file1.txt
svn -m "Modified file1.txt in the trunk" commit trunk

ECHO ------------------------------------------------------------------
ECHO STEP 8: Sync merge the trunk to featurebranch2
ECHO ------------------------------------------------------------------
svn update featurebranch2
svn merge %url%/trunk featurebranch2
svn -m "Sync merged the trunk into featurebranch2" commit featurebranch2

ECHO ------------------------------------------------------------------
ECHO STEP 9: Reintegrate featurebranch2 back into the trunk
ECHO ------------------------------------------------------------------
svn update trunk
svn merge %url%/branches/featurebranch2 trunk
svn -m "Reintegrated featurebranch2 back into the trunk" commit trunk

ECHO ------------------------------------------------------------------
ECHO STEP 10: Try to reuse featurebranch2 after it was reintegrated
ECHO          Sync merge it from the trunk. THIS FAILS with SVN 1.8 
ECHO ------------------------------------------------------------------
svn update featurebranch2
REM on SVN 1.7 we would use --record-only
svn merge %url%/trunk featurebranch2

:EOF

I do not understand why this happens. Also the error reports missing ranges of file1.txt while it seems to be file2.txt that is missing mergeinfo. While not a solution, deleting the local mergeinfo on file2.txt in the trunk also seems to fix the problem. This also hints that the error message is reporting something on the wrong file.

Edit: response to @gbjbaanb This problem is more subtle than the one you are pointing to even though the error message is the same. In my case it is not the reintegrate to the trunk that is failing but the reuse of the branch afterwards.

Also if I look at the mergeinfo of both file1.txt and file2.txt it seems file2.txt is missing the mergeinfo record of featurebranch2 so the problem is with file2.txt not file1.txt as the error suggests. Because file1.txt was changed in the trunk during the life of featurebranch2 and file2.txt wasn't the mergeinfo about the trunk wasn't set on file2.txt during the merge in step 8. I believe this is the spot where it starts to derail. This will not impact the reintegrate to the trunk but it does prevent feature branch reuse afterwards.

Edit: response to @David W I've tried the --record-only -c 11 and this also works on the Windows side. I had already tried it without -c (normaly you shouldn't, I know, but in this case there are no other changes) and then it reports:

svn: E200004: The required merge is reintegrate-like, and the record-only option
 cannot be used with this kind of merge

For good measure I also tried --record-only -c 1-11 which what I expected would be the same as not using -c (as 11 is HEAD). My initial expectation was that it would fail the same way as not using -c, but it didn't. It succeeded the same way as -c 11.

But the whole point of my post is that with SVN 1.8 we don't need to do keep alive trickery. The (DRAFT) documentation says:

If you choose not to delete your branch after reintegrating it to the trunk you may continue to perform sync merges from the trunk and then reintegrate the branch again[37]. If you do this, only the changes made on your branch after the first reintegrate are merged to the trunk. (http://svnbook.red-bean.com).

And from the Subversion 1.8 release notes:

Merging to-and-fro between two branches in any order is possible using the automatic reintegration merge (the "keep-alive dance" is no longer necessary). For best results, it is recommended to always merge all eligible revisions, i.e. not using the -r or -c options of svn merge. Merging just a subset of eligible revisions increases the likelihood of problems during future merges.(https://subversion.apache.org/docs/release-notes/1.8.html)

So my point is that this branch reuse without the keep alive trickery clearly doesn't work in the face of local mergeinfo and my script seems to show that.

If you still feel that the warning about the missing ranges could be correct, except for maybe the reported range numbers, please show me where in my script I cause a missing range. My script is a simple back and forth between trunk and branch without parallel work on both of them.

Also could you explain why also modifying file2.txt by adding: "echo Additional file contents created in the trunk. >> trunk\file2.txt" to step 7, will result in not having an error in step 10. Modifying an aditional file on the trunk can't solve a missing ranges problem.

like image 795
Halt Avatar asked Oct 21 '22 13:10

Halt


1 Answers

On the Subversion mailing list: [email protected] it was decided that this problem was worthy of creating an issue report for. For more info see: Issue report and Subversion user mailing list.

Edit:

As of version 1.8.9 it has been fixed (issue #4481). Thanks!

like image 162
Halt Avatar answered Dec 15 '22 00:12

Halt