I've been trying to merge our code into our feature branches and have experienced mysterious conflicts Thought I'd record what I'm doing, maybe it will be useful to someone else out there. I think the svn book doesn't treat this functionality thoroughly enough with examples (that being said, our use of svn hasn't been the ideal, so its most likely you won't experience these conflicts in your environment).
A - local missing, incoming edit upon merge
Why does this happen?
The 'local missing vs. incoming edit' conflicts can
happen if:
"
- You delete a file which existed in the common ancestor of both
branches, and the file is later modified on trunk and you merge
this modification. in this case you probably want to keep the file
deleted (or you might decide to resurrect it, in which case the
best approach would be to first revert the entire working copy,
undo the file's deletion on the local branch and commit (see
http://svnbook.red-bean.com/en/1.7/svn.branchmerge.basicmerging.html#svn.branchmerge.basicmerging.undo)
, and then repeat the first merge (which
should now not conflict anymore).
- After your branch is created, a new file is created on trunk in
revision A and later modified in revision B. You only merge revision
B which means the file is not created on your branch before the
merge tries to apply the modification. In this case you should
probably also merge revision A. A normal sync merge of the
'svn merge ^/trunk' variety will always do this."
*Excerpt from email conversation with Stefan Sperling from the subversion user's mailing list.
So lets see how we resolve this:
1.
svn status pointed to a tree conflict:
! C core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
> local missing, incoming edit upon merge
I'm guessing the "!" means it doesn't exist in the local copy.
2. First step, I perform an svn info, which tells me what revisions are conflicting. What is strange is that the revision that's conflicting is a very old one from a different branch, I'm not sure why its ending up here. (will update once I have an answer from the forum).
svn info core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
Path: core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
Name: SubscriberPIDMatrixDTO.java
Node Kind: none
Tree conflict: local missing, incoming edit upon merge
Source left: (file) svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@6896
Source right: (file) svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841
2. So I tried my luck and hoped svn would bring the file in automatically.
svn resolve --accept=working svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841
svn: warning: 'svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub' is not a working copy
This is the correct response, because the file doesn't exist in my local copy:)
3. I do an svn copy to copy the file from the trunk into my local repo.
svn cp svn://bcx-svn/acme.za/pams/server/trunk/core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java@9841 core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub
A core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
Yay, its been added.
4. svn status
svn status core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
A + C core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
> local missing, incoming edit upon merge
I've added the file I want, but its still in the conflicted state.
5. Mark the conflict as resolved
svn resolve --accept=working core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
6. svn status now shows the file as being resolved.
svn status core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
A + core/ppfe_dao/src/main/java/za/co/acme/ppfe/data/sub/SubscriberPIDMatrixDTO.java
Tree conflict resolved!
B - local add, incoming add upon merge
Okay, now for another tree conflict:"local add, incoming add upon merge".
I'm not sure what this means, I think that the files been added locally, but the message to me means I added a file locally and the incoming merge
1. svn status
svn status business_services/main_servlet/src/main/resources/testconfigs/pams.properties
C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
> local add, incoming add upon merge
2.
svn info business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Path: business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Name: pams.properties
URL: svn://bcx-svn/acme.za/pams/server/branches/v1-4-3-AM-CR3159-BatchActivations/business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Repository Root: svn://bcx-svn/acme.za
Repository UUID: 5545304e-a938-48f1-8c5a-7cf7c6df13d1
Revision: 9841
Node Kind: file
Schedule: normal
Last Changed Author: kiren
Last Changed Rev: 9673
Last Changed Date: 2012-06-26 10:47:45 +0200 (Tue, 26 Jun 2012)
Text Last Updated: 2012-07-25 17:42:47 +0200 (Wed, 25 Jul 2012)
Checksum: 0c70c81698528185a3a80d704f423c3f
Tree conflict: local add, incoming add upon merge
Source left: (file) svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896
Source right: (file) svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@9841
3. Does the file exist in the local revision?
svn info svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896
svn://bcx-svn/acme.za/pams/server/branches/V1-1-1-preprod/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@6896: (Not a valid URL)
svn: A problem occurred; see other errors for details
Nope, as expected.
4. The trunk version?
svn status svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties@9841
svn: warning: 'svn://bcx-svn/acme.za/pams/server/trunk/business_services/main_servlet/src/main/resources/testconfigs/pams.properties' is not a working copy
Apparently not.
5. Let me check my working copy.
ls -la business_services/main_servlet/src/main/resources/testconfigs/pams.properties
-rw-rw-r-- 1 kiren kiren 137 Jul 25 17:42 business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Damn, it's there? How is this possible? (will check later, its probably that conflict with an older revision).
6. I don't want this file here anyway, so I'm going to delete it.
svn delete business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D business_services/main_servlet/src/main/resources/testconfigs/pams.properties
7. Check status, should still be in conflicted state
svn status business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D C business_services/main_servlet/src/main/resources/testconfigs/pams.properties
> local add, incoming add upon merge
8. Resolve the conflict
svn resolve --accept=working business_services/main_servlet/src/main/resources/testconfigs/pams.properties
Resolved conflicted state of 'business_services/main_servlet/src/main/resources/testconfigs/pams.properties'
9. File should be in a deleted state.
svn status business_services/main_servlet/src/main/resources/testconfigs/pams.properties
D business_services/main_servlet/src/main/resources/testconfigs/pams.properties
10. Wonder if the file still exists on the file-system?
ls -la business_services/main_servlet/src/main/resources/testconfigs/pams.properties
ls: cannot access business_services/main_servlet/src/main/resources/testconfigs/pams.properties: No such file or directory
Aah, nice. Next commit should be rid of it. Tree conflict resolved!
C- local delete, incoming delete upon merge
Okay, here's another one:
1.
svn status core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used
! C core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used
> local delete, incoming delete upon merge
2. Again, the ! means it doesn't exist in the working copy, let's confirm:
ls -la core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.usedls: cannot access core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used: No such file or directory
Cool, the file needs to be deleted, its one of those annoying files that hangs around and people are afraid to ask :) (I'm not going to svn info as I'm not really interested in this file.)
3. Everything is good as it is, just need to resolve it now.
svn resolve --accept=working core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used
Resolved conflicted state of 'core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used'
4. Check the status
svn status core/pams-pams-dao/src/main/resources/META-INF/spring/pams-dao-beans_pamsdbonly.xml.not.used'
No output. Perfect!
Conclusion
While there seems to be some problem with our source tree in terms of the version V1-1-1-preprod, I think showing the steps I used to resolve the problem may help people working with tree conflict issues.
- It looks like our decision not to use --reintegrate merges may have cause problems.
- Also, mixed revisions when merging can cause a problem later on with merging, so avoid merging mixed revisions.
- A tip from Stefan on the user forum is that svn copies should be done with URL to URL to avoid mixed revisions issue.
Update
Subversion 1.6 onwards does not allow merging into mixed revision working copies.