SVN如何解决“本地添加,传入添加更新”*文件夹*?

这是我的情况:

假设我们有一个包含以下内容的SVN回购:myfolder myfolder \ file.txt

现在我创build两个这个回购,co1和co2的结帐。

在co1中我们修改file.txt。 在二氧化碳我们:

  • svn删除我的文件夹
  • svn提交
  • 创build一个名为myfolder的新文件夹
  • svn添加我的文件夹
  • svn提交

现在如果我在co1中尝试更新,我得到一个树冲突:

A + C myfolder > local edit, incoming delete upon update M + myfolder\file.txt 

我想保留我的文件夹和修改后的文件,所以我解决了树冲突:

 svn resolve --accept working folder 

现在,如果我尝试提交,我得到“svn:目录”/ myfolder“已过时”。 如果我试图解决这个使用svn上我的文件夹,我再次得到一个树冲突:

 A + C folder > local add, incoming add upon update M + myfolder\file.txt 

好的,所以我们尝试svn解决 – 再次接受工作文件夹。 但是我们仍然不能提交,我们得到的信息是“svn:Directory'/ myfolder'已经过时了”,如果我们把文件夹放到上面,我们就回到最后一个树的冲突。

解决这种冲突的正确程序是什么(当我们想保留我的文件夹及其变化时)?

编辑:Windows cmd线脚本来说明:

 rmdir /S /QC:\svntest mkdir C:\svntest cd C:\svntest svnadmin create repo svn co file:///c:/svntest/repo co1 svn co file:///c:/svntest/repo co2 cd co1 mkdir folder echo content > folder\file.txt svn add folder svn commit folder -m "" cd C:\svntest\co2 svn up cd C:\svntest\co1 svn del folder svn commit -m "" mkdir folder svn add folder svn commit -m "" cd C:\svntest\co2 echo changed_content > folder\file.txt svn up svn resolve --accept working folder svn commit -m "" svn up folder svn resolve --accept working folder svn commit -m "" 

这里是运行该脚本的输出(注意最后的提交失败):

 C:\>rmdir /S /QC:\svntest C:\>mkdir C:\svntest C:\>cd C:\svntest C:\svntest>svnadmin create repo C:\svntest>svn co file:///c:/svntest/repo co1 Checked out revision 0. C:\svntest>svn co file:///c:/svntest/repo co2 Checked out revision 0. C:\svntest>cd co1 C:\svntest\co1>mkdir folder C:\svntest\co1>echo content 1>folder\file.txt C:\svntest\co1>svn add folder A folder A folder\file.txt C:\svntest\co1>svn commit folder -m "" Adding folder Adding folder\file.txt Transmitting file data . Committed revision 1. C:\svntest\co1>cd C:\svntest\co2 C:\svntest\co2>svn up A folder A folder\file.txt Updated to revision 1. C:\svntest\co2>cd C:\svntest\co1 C:\svntest\co1>svn del folder D folder\file.txt D folder C:\svntest\co1>svn commit -m "" Deleting folder Committed revision 2. C:\svntest\co1>mkdir folder C:\svntest\co1>svn add folder A folder C:\svntest\co1>svn commit -m "" Adding folder Committed revision 3. C:\svntest\co1>cd C:\svntest\co2 C:\svntest\co2>echo changed_content 1>folder\file.txt C:\svntest\co2>svn up C folder At revision 3. Summary of conflicts: Tree conflicts: 1 C:\svntest\co2>svn resolve --accept working folder Resolved conflicted state of 'folder' C:\svntest\co2>svn commit -m "" Adding folder svn: Commit failed (details follow): svn: Directory '/folder' is out of date C:\svntest\co2>svn up folder C folder At revision 3. Summary of conflicts: Tree conflicts: 1 C:\svntest\co2>svn resolve --accept working folder Resolved conflicted state of 'folder' C:\svntest\co2>svn commit -m "" Adding folder svn: Commit failed (details follow): svn: Directory '/folder' is out of date 

我想通了

 svn resolve --accept working PATH_TO_FILE 

最终应该是:

已解决“PATH_TO_FILE”的冲突状态

树冲突给出了一个很好的树冲突概述和解决scheme。 在某些情况下, svn revert也可能有帮助,同时丢失所有本地修改。 作为最后的手段,一个新的工作副本,手动合并从“破”的变化将带你回到正轨。 绝对是颠覆的黑暗面。

尝试

 C:\svntest\co2>move folder folder.SAVE C:\svntest\co2>svn revert folder C:\svntest\co2>svn update 

然后Svn应该带一个新的folder目录版本与co1相同。 然后,您可以用folder.SAVE的内容覆盖。

我不能重现你所提到的。 这是我所尝试过的。

 test@test:/tmp$ cd /tmp/ test@test:/tmp$ svn co http://localhost:8080/svn/stackoverflow so --username=admin A so/trunk A so/branches A so/tags Checked out revision 1. test@test:/tmp$ cd so/trunk/ test@test:/tmp/so/trunk$ mkdir x test@test:/tmp/so/trunk$ ls /tmp > x/test.txt test@test:/tmp/so/trunk$ svn add x/ A x A x/test.txt test@test:/tmp/so/trunk$ svn ci -m "test" Adding trunk/x Adding trunk/x/test.txt Transmitting file data . Committed revision 2. test@test:/tmp/so/trunk$ cd /tmp/ test@test:/tmp$ svn co http://localhost:8080/svn/stackoverflow so1 --username=admin A so1/trunk A so1/trunk/x A so1/trunk/x/test.txt A so1/branches A so1/tags Checked out revision 2. test@test:/tmp$ cd /tmp/so1/trunk/ test@test:/tmp/so1/trunk$ svn remove x D x/test.txt D x test@test:/tmp/so1/trunk$ svn ci -m "" Deleting trunk/x Committed revision 3. test@test:/tmp/so1/trunk$ mkdir x test@test:/tmp/so1/trunk$ cp ../../so/trunk/x/test.txt x test@test:/tmp/so1/trunk$ ll /tmp > x/test.txt test@test:/tmp/so1/trunk$ svn add x/ A x A x/test.txt test@test:/tmp/so1/trunk$ svn ci -m "" Adding trunk/x Adding trunk/x/test.txt Transmitting file data . Committed revision 4. test@test:/tmp$ cd so/trunk/ test@test:/tmp/so/trunk$ svn up D x A x A x/test.txt Updated to revision 4. test@test:/tmp/so/trunk$ 

显然我尝试了同样的方法,而且没有再遇到任何问题。 你使用的是什么版本的svn?

 export REPOPATH=/tmp/svntest test@test:/tmp/co2/trunk$ rm -rf $REPOPATH test@test:/tmp/co2/trunk$ mkdir $REPOPATH test@test:/tmp/co2/trunk$ svnadmin create $REPOPATH/repo test@test:/tmp/co2/trunk$ svn co file:///$REPOPATH/repo co1 svn: Repository UUID '2d803eb8-2030-4dd3-bb6f-34ab07c74813' doesn't match expected UUID '82764ae8-6410-4565-933f-9a420cb60013' test@test:/tmp/co2/trunk$ svn co file:///$REPOPATH/repo co2 svn: Repository UUID '2d803eb8-2030-4dd3-bb6f-34ab07c74813' doesn't match expected UUID '82764ae8-6410-4565-933f-9a420cb60013' test@test:/tmp/co2/trunk$ test@test:/tmp/co2/trunk$ cd $REPOPATH/co1 bash: cd: /tmp/svntest/co1: No such file or directory test@test:/tmp/co2/trunk$ mkdir folder mkdir: cannot create directory `folder': File exists test@test:/tmp/co2/trunk$ echo content > folder/file.txt test@test:/tmp/co2/trunk$ svn add folder svn: warning: 'folder' is already under version control test@test:/tmp/co2/trunk$ svn commit folder -m "" test@test:/tmp/co2/trunk$ test@test:/tmp/co2/trunk$ cd $REPOPATH/co2 bash: cd: /tmp/svntest/co2: No such file or directory test@test:/tmp/co2/trunk$ svn up At revision 10. test@test:/tmp/co2/trunk$ test@test:/tmp/co2/trunk$ cd $REPOPATH/co1 bash: cd: /tmp/svntest/co1: No such file or directory test@test:/tmp/co2/trunk$ svn del folder svn: Use --force to override this restriction svn: 'folder/file.txt' is not under version control test@test:/tmp/co2/trunk$ svn commit -m "" test@test:/tmp/co2/trunk$ mkdir folder mkdir: cannot create directory `folder': File exists test@test:/tmp/co2/trunk$ svn add folder svn: warning: 'folder' is already under version control test@test:/tmp/co2/trunk$ svn commit -m "" test@test:/tmp/co2/trunk$ test@test:/tmp/co2/trunk$ cd $REPOPATH/co2 bash: cd: /tmp/svntest/co2: No such file or directory test@test:/tmp/co2/trunk$ echo changed_content > folder\file.txt test@test:/tmp/co2/trunk$ svn up At revision 10. test@test:/tmp/co2/trunk$ svn --version svn, version 1.6.6 (r40053) compiled Dec 12 2009, 05:04:54 Copyright (C) 2000-2009 CollabNet. Subversion is open source software, see http://subversion.tigris.org/ This product includes software developed by CollabNet (http://www.Collab.Net/). The following repository access (RA) modules are available: * ra_neon : Module for accessing a repository via WebDAV protocol using Neon. - handles 'http' scheme - handles 'https' scheme * ra_svn : Module for accessing a repository using the svn network protocol. - with Cyrus SASL authentication - handles 'svn' scheme * ra_local : Module for accessing a repository on local disk. - handles 'file' scheme 

在这种特殊情况下,我认为你必须手动重新应用本地更改。 也就是说,创build一个补丁文件(svn diff> mine.patch,或将文件复制到其他地方),恢复您的更改或使用他们的解决scheme,然后应用补丁(或复制文件)。 也许你需要svn在应用你的改变之前将你的文件的基础复制回重新创build的文件夹中。

就像zellus说的那样,这是颠覆的黑暗面,这是当前实现无法处理的事情。 再次,删除一个文件夹,并添加一个相同名称的回来听起来不太正确。 你会期望颠覆吗? 如果该文件没有在文件夹中重新创build呢? 如果它的内容不同呢?

尝试避免这种情况,不删除一个文件夹,你想保持:)