合并时如何正确处理Subversion的祖先问题和“忽略祖先”只会让事情变得更糟?

时间:2016-04-26 14:08:27

标签: svn version-control merge tortoisesvn branch

我遇到以下情况:

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

Branch A是在主干上创建的。在该分支中删除了Folder F,然后重新添加了几个提交,但是使用了新的新文件(即没有反向合并 - 撤消删除)。之后Branch B从树干上分离出来,其他一些工作继续进行。与此同时,A重新融入后备箱。

现在正在完成B我想将它重新集成到主干中,但是在发生这种情况之前我遇到了与主干同步的问题。无论我做什么,我的subversion客户端(TortoiseSVN)声称B的{​​{1}}版本已经过时了。我想这是因为F的{​​{1}}和躯干的B没有共同的祖先。但是,当我尝试使用“忽略祖先”选项将主干的F合并到F的{​​{1}}时,它会继续保持F没有错误看起来像是行李箱里的那个。如果我尝试将整个行李箱合并到B上并选择“Ignore Ancestry”,那么其他一切悲伤就会发生(到处都是树木冲突等)。

就我而言,FF没有进行任何更改。

在这样的情况下,如何正确处理祖先问题?

1 个答案:

答案 0 :(得分:0)

我无法重现这个问题,所以一定有些东西丢失了。如果您能够花时间,请查看我在MVCE下方的尝试,并将其与您的情况进行比较:

@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"

这个输出是(在我的机器上,运行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.