views:

395

answers:

6

I got an email a few days ago from someone who was having trouble building a Delphi project I have on Google Code. The project file and one of the DFM files were munged after he updated with some changes I had checked in. We talked back and forth a bit, and traced it down to what he said was SVN throwing in extra stuff. He deleted the files and ran Update again and it worked fine.

I've never seen this problem before, and I wasn't able to reproduce or verify any of it at my end. There weren't any update conflicts with other users, since I'm the only one with write access to the repository. So I'm wondering what could have caused this. Is this a known issue for SVN? Is there a way to keep it from happening?

+3  A: 

Suppose he or his local system managed to mangle the two files.

Then suppose he updates and finds things not working. After some finger-pointing he deletes the files with, ahem, local mods, runs update, and gee ... the right files!

Entia non sunt multiplicanda praeter necessitatem.

While it is always possible that a strange syntax error is a compiler bug and a corrupted file is an svn bug, there are usually more prosaic reasons, and we have it on William of Ockham's authority that the simpler explanation is usually the correct one.

DigitalRoss
Good point. Except that project files and DFM (form description) files are managed by the IDE. They're stored in text format, but you don't usually edit them by hand like normal source code. I've never heard of the IDE corrupting a DFM file, and corrupted project files do happen occasionally, but not very often. So I find this explanation just a little unlikely.
Mason Wheeler
I agree with you completely but now we must take into account *publication bias*, aka *reporting bias*. Sure, it's unlikely, but so are the competing explanations. We are comparing unlikely scenarios with other unlikely scenarios, and given that only corruption will be reported, the fact that corruption is rare might be a dangerous factor to reason with.
DigitalRoss
I agree that it's most likely that he munged it locally. The "extra stuff added by svn" could well be the conflict info that svn will add to the versioned file in the working copy when it identifies a local conflict. Resolving the conflict would have made the "extra stuff" go away. Or indeed, simply deleting them and trying again. ;-)
Conor Boyd
+4  A: 

If the DFM file was treated by Subversion as text, assuming the user had local changes, it will attempt a merge. Where there are conflicts and Subversion can't resolve them, it will add extra detail to help you manually resolve the conflicts, you will see text like <<<<<<< .mine which of course will bork in Delphi. It could also be that Subversion did a merge automatically, which didn't conflict, but lead to a corrupt DFM file.

The reason why you didn't see the problem was probably because you didn't have local changes, so no merge was necessary. Deleting or reverting the files resets the working copy back to BASE so any update won't need to do a merge.

One solution: If you have text files which should not be merged by Subversion, then set the svn:mime-type to an appropriate non-text value, and it will treat it as binary, and won't attempt a merge. You will be required to manually fix the problem. Incidentally, this is also a good tip if you need to store sensitive text files in Subversion and don't want diffs showing the content :)

Si
Interesting trick. But then I'd lose the ability to use TortoiseSVN to review my changes before checking in a new batch of code.
Mason Wheeler
It would be easy to corrupt a DFM file if merging, changing "unimportant" details can cause the component order to change. Naive merging could then completely muck it up.
Gerry
@Mason - Did you try? TortoiseSVN -> Diff will show the changes (well it did for me, but I have it configured to use Beyond Compare) SVN won't show the diff (say in a post-commit email) instead it will report "Binary files differ". It's been years since I coded in Delphi, but I'm guessing it analogous to .NET designer files. Personally I don't bother setting MIME type for this kind of file (I was just suggesting one possible solution) because if I see a "Merged" status after an update to an auto-generated and maintained file, it's a pretty big clue things may go wrong :)
Si
If it's not clear: I'm *not* suggesting setting svn:mime-type as a security feature, but given that most tools (which send details of changes to files) use svn or svnlook, it's a way to help prevent sensitive data inadvertently being sent which you are not expecting it. E.g. We version our svnserve authz and passwd files, and although I have authz setup on the config directory itself, I don't want our post-commit email hook to email out the diff of changes. Of course anyone with the proper authorization can see the changes.
Si
Security by obfuscation...
Jeroen Pluimers
Again, it's not a security measure, just an attempt to reduce data leakage.
Si
Si: DFMs are text files that contain form description information, serialized in a simple format that looks kinda similar to JSON.
Mason Wheeler
+1  A: 

Did the "munged" files contain "mine" or "theirs" text?

If so he probably mucked up his conflict resolution and ended up committing the theirs or mine rev inadvertently.

Or it's entirely possible that the merge thought it could auto-merge changes because they were in "unrelated" parts of the file, but for SVN (or any naive auto-merge process) "unrelated" simply means in lines of the files that don't/didn't overlap.

"Naive" auto-merge knows nothing about any structure internal to the file so may easily merge changes that it believes are unrelated when in fact the changes have adverse side effects on each other. Without knowing precisely the nature of the "munging" it's hard to say for sure, although in this case the reference to "extra stuff" suggests that inadvertent commital of "mine" or "theirs" revisions seems most likely.

Deltics
A: 

Which Delphi version? Older Delphi versions had bugs in which sometimes text DFM files became binary.

Files suddenly becoming binary kill any source control system.

--jeroen

Jeroen Pluimers
2010, so that's not an issue here.
Mason Wheeler
it still can be: if SVN does not support unicode properly (or one of the SVN clients does not) then you will get in trouble
Jeroen Pluimers
A: 

Are you working on multiple platforms? Are you using editors that assume Unix lineendings (like some cygwin tools?)

If so, check if you configured the eol-style property properly.

Marco van de Voort
A: 

I was perform a SVN update and SVN was mucking up the DFM files with <<<<<<<<.mine, which I'd never seen before. I had to manually delete those modifications before Delphi would allow me to open the project.