SVN如何解决“本地添加,更新时传入添加”问题在*文件夹*上?
这是我的场景:
假设我们有一个包含以下内容的 SVN 存储库: 我的文件夹 myfolder\file.txt
现在我创建此存储库的两个签出:co1 和 co2。
在co1中我们修改file.txt。 在 co2 中,我们:
- svn delete myfolder
- svn commit
- 创建一个名为 myfolder 的新文件夹
- svn add myfolder
- svn commit
现在,如果我尝试在 co1 中进行更新,则会出现树冲突:
A + C myfolder > local edit, incoming delete upon update
M + myfolder\file.txt
我想保留 myfolder 和修改后的文件,因此我解决了树冲突:
svn resolve --accept working folder
现在,如果我尝试提交,我会收到“svn:目录'/myfolder'已过期”。如果我尝试使用 svn up myfolder 解决此问题,我会再次遇到树冲突:
A + C folder > local add, incoming add upon update
M + myfolder\file.txt
好的,所以我们再次尝试 svn resolve --accept 工作文件夹。但我们仍然无法提交,我们收到相同的消息“svn:目录'/ myfolder'已过期”,如果我们执行svn up myfolder,我们会立即回到最后一个树冲突。
解决此类冲突的正确步骤是什么(当我们希望保留 myfolder 及其更改时)?
编辑:Windows cmd 行脚本来说明:
rmdir /S /Q C:\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 /Q C:\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
Here is my scenario:
Assume we have an SVN repo with the following content:
myfolder
myfolder\file.txt
Now I create two checkouts of this repo, co1 and co2.
In co1 we modify file.txt.
In co2 we:
- svn delete myfolder
- svn commit
- Create a new folder named myfolder
- svn add myfolder
- svn commit
Now if I attempt an update in co1 I get a tree conflict:
A + C myfolder > local edit, incoming delete upon update
M + myfolder\file.txt
I want to keep myfolder and the modified file, so I resolve the tree conflict:
svn resolve --accept working folder
Now if I try to commit, I get "svn: Directory '/myfolder' is out of date". If I try to resolve this using svn up myfolder, I get a tree conflict again:
A + C folder > local add, incoming add upon update
M + myfolder\file.txt
Okay, so we try svn resolve --accept working folder again. But we still can't commit, we get the same message that "svn: Directory '/myfolder' is out of date", if we do svn up myfolder, we get right back to the last tree conflict.
What is the correct procedure to resolve this type of conflict (when we wish to keep myfolder and its changes)?
EDIT: Windows cmd line script to illustrate:
rmdir /S /Q C:\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 ""
And here is the output of running that script (note the commit failures at the end):
C:\>rmdir /S /Q C:\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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我弄清楚了
最终应该是:
解决了“PATH_TO_FILE”的冲突状态
I figured out with
which should end up with:
Resolved conflicted state of 'PATH_TO_FILE'
树冲突很好地概述了树冲突及其解决。在某些情况下,
svn revert
也可能有所帮助,但会丢失所有本地修改。作为最后的手段,一个新的工作副本,其中手动合并了“损坏的”工作副本中的更改,将使您回到正轨。绝对是颠覆的阴暗面。Tree Conflicts gives a nice overview of tree conflicts and their resolution. In some cases
svn revert
might help as well, while loosing all your local modifications. As last resort a new working copy with manually merged changes from the 'broken' one will bring you back on track. Definitely the dark side of subversion.尝试
Svn 后应该会引入一个与
co1
中的版本相同的新folder
目录版本。然后,您可以使用folder.SAVE
中的内容进行覆盖。Try
Svn should then bring in a fresh
folder
directory version identical with the one fromco1
. You can then overwrite with the content fromfolder.SAVE
.我无法重现您提到的内容。这是我尝试过的。
显然我尝试了与您相同的方法,并且没有再次遇到任何问题。你使用什么版本的 svn ?
I am not able reproduce what you have mentioned. Here is what I have tried.
Apparently I tried the same approach which you did and did not face any problem again. What version of svn are you using ?
在这种特殊情况下,我认为您必须手动重新应用本地更改。也就是说,创建一个补丁文件(svn diff > mine.patch,或将文件复制到其他地方),恢复您的更改或使用他们的更改进行解析,然后应用补丁(或将文件复制回来)。也许您需要在应用更改之前将文件的基础复制回重新创建的文件夹中。
就像泽勒斯所说,这是颠覆的黑暗面,这是当前实现无法处理的。话又说回来,删除一个文件夹并添加一个同名的文件夹听起来不太正确。您期望颠覆会做什么?如果该文件未在文件夹中重新创建怎么办?如果内容不同怎么办?
尝试通过不删除您想要保留的文件夹来完全避免这种情况:)
In this particular case, I think you'll have to re-apply the local changes manually. That is, create a patch file (svn diff > mine.patch, or copy files somewhere else), revert your changes or resolve using theirs, then apply the patch (or copy files back). Perhaps you will need to svn copy the base of your files back in the recreated folder before applying your changes.
Like zellus said, it's the dark side of subversion, and this is something the current implementation is unable to handle. Then again, deleting a folder and adding an identically named one back in doesn't sound quite right. What would you expect subversion to do? What if the file is not recreated in the folder? What if its content is different?
Try avoiding the situation altogether by not deleting a folder you want to keep :)