Why does committing a branch to the still untouched trunk cause conflicts?
Having a rough time with my first big directory merge and was hoping for clues as to why I am getting these errors.
I branched off the code in trunk/ a week ago and made a lot of changes to the code in branches/myBranch, and decided that it was time to merge them into trunk/. No code has since been touched in the trunk, it is exactly the same as when the new code branched of, so I thought that this meant no conflicts could arise.
False assumption, it seems, as I know get a heap of conflicts when trying to merge the new code into trunk and reports of missing files. Could someone clarify why this is happening?
This is the basic facts:
- The code was branched in revision 19466.
- The trunk has since been untouched. No changes (Last Changed Rev: 19453).
- The branch was (unfortunately?) done locally, incorporating some changes.
- I tried merging the changes from the branch intro trunk using the following command:
svn merge -开发者_开发知识库r19466:HEAD branches/myBranch trunk/
. (It didn't matter if I was standing in trunk and skipping the last argument, or just doing the above) Subversion complains about a missing file, fooDao.
! C trunk/fooDao.java
> local missing, incoming edit upon merge
This file was renamed in the same commit that the branch was created (19466), but I thought that subversion should pick this up since it was issued using
svn move
. The log shows its ancestry:... A /branches/myBranch/fooDao.java (from /branches/myBranch/fooDato.java:19452)
- If you are wondering why the revision numbers increase even without code changes, it is because it is a shared repository containing many other (active projects).
The main cause of the errors I experienced were due to creating the branch in a unsound way. If you do branching correctly the brainch point will have exactly the same files as in the trunk (in that revision). If a branch created in revision 100 were to be merged into trunk I could then just use svn merge -r100:HEAD ../branches/myBranch ./trunk
and get just the changes to the files in those revisions.
Unfortunately I had local modifications in trunk/ before creating the branch. These modifications were copied into the new branch and then committed. Thus the files in myBranch and trunk were different at the point of creation of the branch. To remedy the situation I had to find a revision before the branch creation to merge from (say: rev99) and do the merge from there. Any conflicts that appeared were simply solved by choosing "tf" (their full) to get the full file from the branch in a conflict. I could do this quick fix because the trunk was untouched and had no changes.
To sum it up: to avoid problems, do branching correctly by making sure
- all local modifications in trunk have been committed
- do the copy on the server. As in "svn cp https://source.foo.com/svn/repos/myProj/trunk https://source.foo.com/svn/repos/myProj/branches/myBranch"
精彩评论