1

I encountered the following situation:

    F deleted      F added
  +-----X------------X--------+--
  ^                           ^ |
  |       Branch A            | |
  |                           | |
  |                           | v
+-+----------------------+----+-+-------+->
                         |              |
                         |  Branch B    | PROBLEM
                         |              v
                         +---------------->

Branch A was created off trunk. In that branch a Folder F was deleted and then re-added several commits later, but using new, fresh files (i.e. without reverse-merge-undo of the delete). After that Branch B was spun off the trunk where some other work went on. In the meantime A got reintegrated into the trunk.

Now being finished with B I want to also reintegrate it into the trunk, but I'm having a problem with syncing it with trunk before that happens. No matter what I do my subversion client (TortoiseSVN) claims B's version of F is out of date. I imagine this is because B's F and trunk's F don't have common ancestry. However, when I try to merge trunk's F onto B's F using the "Ignore Ancestry" option it proceeds without error while still leaving me with F which doesn't look like the one in the trunk. If I try to merge entire trunk onto B with "Ignore Ancestry" selected for everything a whole bunch of other sadness happens (tree conflicts everywhere etc.)

In my case, no changes have been made to F in B.

How does one properly deal with ancestry problems in a situation like this?

Sanuuu
  • 243
  • 1
  • 10

1 Answers1

0

I can't reproduce the problem, so there must be something missing. If you're able to spend the time, review my attempt at a MVCE below and compare it to your situation:

@ECHO OFF

SET CWD=%~dp0
SET REPO_NAME=repo
SET REPO_PATH="%CWD%%REPO_NAME%"
SET WC_NAME=wc
SET WC_PATH="%CWD%%WC_NAME%"

:: Create REPO URI (C:\path\to\repo -> file:///C:/path/to/repo, see https://stackoverflow.com/a/27817626/1698557)
FOR /f "delims=" %%R IN (%REPO_PATH%) DO SET REPO_URL=%%~fR%
SET REPO_URL=file:///%REPO_URL%
SET REPO_URL=%REPO_URL:///\\=//%
SET REPO_URL=%REPO_URL:\=/%
SET REPO_URL="%REPO_URL%"

:: Cleanup previous run
RMDIR /S /Q %REPO_PATH%
RMDIR /S /Q %WC_PATH%

:: Create the repository
svnadmin create %REPO_PATH%

:: TEST STARTS HERE ----------------------------
svn mkdir %REPO_URL%/trunk -m "Creating trunk directory"
svn mkdir %REPO_URL%/branches -m "Creating branches directory"

:: Create folder "F" in trunk (revision 3)
svn mkdir %REPO_URL%/trunk/F -m "Creating F directory in trunk"

:: Checkout trunk
svn checkout %REPO_URL%/trunk %WC_PATH%

:: Add a file to "F" (revision 4)
echo "First file version" > %WC_PATH%\F\thefile.txt
svn add %WC_PATH%\F\thefile.txt
svn commit %WC_PATH% -m "Creating thefile.txt in trunk/F"

:: Create branch A (revision 5)
svn copy %REPO_URL%/trunk %REPO_URL%/branches/A -m "Creating branch A"

:: Delete F from Branch A (revision 6)
svn delete %REPO_URL%/branches/A/F -m "Deleting F directory from branch A"

:: Add F back to the branch (revision 7)
svn mkdir %REPO_URL%/branches/A/F -m "Recreating F directory in branch A"

:: Switch to branch A
svn switch %REPO_URL%/branches/A %WC_PATH%

:: Add a file with different content to "F" (revision 8)
echo "Second file version" > %WC_PATH%\F\thefile.txt
svn add %WC_PATH%\F\thefile.txt
svn commit %WC_PATH% -m "Creating thefile.txt in trunk/F"

:: Create branch B (revision 9)
svn copy %REPO_URL%/trunk %REPO_URL%/branches/B -m "Creating branch B"

:: Merge trunk to branch A (revision 10)
svn update %WC_PATH%
svn merge %REPO_URL%/trunk %WC_PATH%
svn commit %WC_PATH% -m "Synchronizing branch A with trunk"

:: Switch back to trunk
svn switch %REPO_URL%/trunk %WC_PATH%

:: Merge branch A to trunk (revision 11)
svn merge %REPO_URL%/branches/A %WC_PATH%
svn commit %WC_PATH% -m "Merging branch A into trunk"

:: Switch to branch B
svn switch %REPO_URL%/branches/B %WC_PATH%

:: Merge trunk into branch B (revision 12)
svn merge %REPO_URL%/trunk %WC_PATH%
svn commit %WC_PATH% -m "Synchronizing branch B with trunk"

The output of this is (on my machine, running SVN 1.9.3):

Committing transaction...
Committed revision 1.
Committing transaction...
Committed revision 2.
Committing transaction...
Committed revision 3.
A    wc\F
Checked out revision 3.
A         wc\F\thefile.txt
Adding         wc\F\thefile.txt
Transmitting file data .done
Committing transaction...
Committed revision 4.
Committing transaction...
Committed revision 5.
Committing transaction...
Committed revision 6.
Committing transaction...
Committed revision 7.
D    wc\F
A    wc\F
Updated to revision 7.
A         wc\F\thefile.txt
Adding         wc\F\thefile.txt
Transmitting file data .done
Committing transaction...
Committed revision 8.
Committing transaction...
Committed revision 9.
Updating 'wc':
At revision 9.
--- Recording mergeinfo for merge of r5 through r9 into 'wc':
 U   wc
Sending        wc
Committing transaction...
Committed revision 10.
D    wc\F
A    wc\F
A    wc\F\thefile.txt
 U   wc
Updated to revision 10.
--- Merging r5 through r10 into 'wc':
R    wc\F
A    wc\F\thefile.txt
--- Recording mergeinfo for merge of r5 through r10 into 'wc':
 U   wc
Sending        wc
Replacing      wc\F
Committing transaction...
Committed revision 11.
D    wc\F
A    wc\F
A    wc\F\thefile.txt
 U   wc
Updated to revision 11.
--- Merging r9 through r11 into 'wc':
R    wc\F
A    wc\F\thefile.txt
 U   wc
--- Recording mergeinfo for merge of r9 through r11 into 'wc':
 G   wc
Sending        wc
Replacing      wc\F
Committing transaction...
Committed revision 12.
Community
  • 1
  • 1
Patrick Quirk
  • 23,334
  • 2
  • 57
  • 88
  • Is `F` having files in it relevant at all? The directory/file structure of `F` are identical pre/post deletion but the file contents differ. – Sanuuu Apr 26 '16 at 15:19
  • See my edit. It doesn't appear to matter as my example still runs without conflicts. – Patrick Quirk Apr 26 '16 at 15:49
  • Ok, thanks for the MVCE attempt! This is puzzling. I have a suspicion the case might be of me simply not seeing the whole picture as the repository is much more complex that that, having existed for 5 years now and currently in its high 4,000 revision number. I'll try to look for some other cause of the problems. – Sanuuu Apr 26 '16 at 15:54
  • For now I have managed to reintegrate the branch by merging `B` back into trunk without the `-reintegrate` option, instead manually selecting all the revisions save for the ones merged into it from the trunk. – Sanuuu Apr 26 '16 at 15:57