SVN merge trunk into branch deleting files

人盡茶涼 提交于 2019-12-10 23:07:41

问题


I am trying to do something seemingly simple, yet having problems.

Basically, I have an svn repo, it has a trunk and a branch which was created from revision 122.

I added a file (src/utils/foo.py) to the branch, committed it as revision 128, all good.

However, there have been several commits (namely (123,124,125,126,127) in to the trunk that I'd like in my branch. So I do something like:

$ svn merge -r122:127 ^/projects/my_project/trunk/src/utils .
--- Merging r123 through r127 into '.':
D    foo.py

Whoops! It deleted my file! What am I doing wrong so that this doesn't happen?


回答1:


It may have more to do with the folder that owns the file, than the file itself. I believe most SCM tools treat folders like files in that they get versioned as well. You might need to go up one level to make sure that the "utils" folder gets merged over also.

Edit:

Just to explain a bit more, it is the folder "utils" that records that the file "foo.py" is a child of it, so even if foo.py exists in trunk, without merging the updated utils folder it may not display.




回答2:


First are you in the correct directory where you executed the svn merge command? Second never merge only subfolders in SVN. Just use

svn merge ... ^/projects/my_project/trunk 

into the root of your working copy. That will be better in particular in relationship with the merge history (svn:mergeinfo).




回答3:


Ah! Someone had indeed merged the branch into the trunk, which added the file to trunk, but then rolled back that commit, deleting the file from trunk. Thanks for the help. Good lesson in how svn merge works.



来源:https://stackoverflow.com/questions/8432344/svn-merge-trunk-into-branch-deleting-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!