SVN modifies svn:mergeinfo property on files with no change
Asked Answered
C

2

4

I've a "problem" with svn I can't understand why sometimes when I merge two branches it reports modify on mergeinfo property on files with no changes on the text.
Is it a normal behavior?
If not, what can be the problem?

Childs answered 11/9, 2012 at 13:6 Comment(0)
L
4

Well, you did merge those two branches. Right? Works as expected.

What you did was do a merge. Even though the merge didn't result in any code changes, and that's not uncommon with merges, Subversion still marks that a merge was done. If nothing else, marking that you did a merge -- even though it resulted in no changes, is still a good idea. Imagine a release going out, and someone saying "Wait, no one merged that branch back into the trunk! We'll have to delay the release until we get that done" because they didn't see the merge in the svn:merge-info record.

So, yes what you saw can be normal behavior.

Now, if your question is "Why didn't my changes get merged", that's a different issue. Subversion usually does a good job with merges, but you have to make sure you do a few things:

  • Merge from the root of your project only, and not individual branches and files. There are exceptions, but most of the time you should be merging the branches of a project. Otherwise, you'll end up with svn:merge-info all over the place.
  • Know when to use the --reintegrate flag. You have a branch "A" (which could include trunk in this example). You make a branch "B" from branch "A".
    • When you merge from "A" to "B", you don't use --reintegrate
    • When you merge from "B" to "A", remember to use --reintegrate. It changes the way Subversion handled the merge.
  • Subversion doesn't handle highly complex merge situations very well. If you make a branch a whole slew of branches, and do merges back and forth between them, Subversion will mess up. This is one of the reasons I tell people not to do the branch per feature business. It makes tracking the various merges hard to do, and can cause Subversion to have merge problems. Maybe this is a feature: Since Subversion doesn't handle these highly complex merge situations very well, you have to avoid them. I've been able to talk many managers out of highly complex anti-pattern branching schemes by simply stating Subversion can't handle it.
  • If you manually merge your files (and many developers prefer to do this: Apply changes in the branch back to the trunk manually), use the svn merge --record-only, so that Subversion knows you've done the merge. Hilarity ensues when developers do some merges manually while others allow Subversion to do the merge.

So, if Subversion didn't merge in changes it should have, make sure that you're using the --reintegrate correctly, and that you're not having the other issues mentioned above.

Longtin answered 11/9, 2012 at 14:58 Comment(5)
Yes, but for example if in my N revision I change the file Controller.java in the branch B1 , and then I reintegrate this on the trunk why before I commit I have the mergeinfo property changed in the root of the trunk and in configuration.xml (for example) ?? This sounds strange to me...Childs
You're just merging that one file, or are you merging everything from the root and that's the only file that is merged? If you're merging from the root of the project, and that's the only file merged. The root of the project gets the svn:mergeinfo. The configuration.xml gets changed because someone did an svn merge on just that one file, and now it has to track merges too. Thus, it's svn:mergeinfo gets updated too. That's why I said to always merge from the root from the project. Otherwise, you'll end up with thousands of files -- each with its own svn:mergeinfo.Longtin
Ok, but nobody touched configuration.xml, that's the problem, also if there isn't any modify on it, SVN set the mergeinfo property...Childs
If that file has the svn:mergeinfo attribute on it, it means someone did a merge on that file, and only that file in the distant past. svn:mergeinfo is set on the root of the merge (which is why I stated my first point). Once svn:mergeinfo is set on a file or directory, it will be updated on every merge even though it's not on the root of the tree. See Mergeinfo Inheritance. You can delete the svn:mergeinfo property on configuration.xml to get merge tracking to stop. Then, it wont' update it.Longtin
Found the missing paper. This will explain Everything about merge tracking in Subversion, and why that configuration.xml file has an svn:mergeinfo property on it.Longtin
D
0

svn:mergeinfo property is used to track information about merges which have been performed in your repository.

See the SVNBook for details: "Mergeinfo and Previews".

Datura answered 11/9, 2012 at 13:18 Comment(1)
Yes, I've read it, but why it tracks informations on files that aren't affected by the merge?Childs

© 2022 - 2024 — McMap. All rights reserved.