I'm a big fan of Terry Pratchet. How can you not be a fan of someone who dedicates a book to "the Palace Guard, the City Guard, or the Patrol... Whatever the name, their purpose...is identical: to rush into the room, attack the hero one at a time, and be slaughtered..."
1. I checked out a copy of Hippo onto my laptop, and created a directory in which to do the training exercise we've assigned to the incoming students.
2. I fired up Eclipse to create a Java project in that directory. I put my Java source files in a sub-directory called
src, the JAR files my project needed in a sub-directory called
lib, and created an empty directory called
bin for Eclipse to put compiled class files in. I used
svn add to add all three directories to the repository.
3. Reading the Hibernate documentation, I thought I had to put the mapping file that described how to store my Java objects in a database in the same directory as the compiled class files. All right, no problem---I created
bin/LoanRecord.hbm.xml, and used
svn add to add it to the repository.
At this point, my workspace looked like this:
.project # Eclipse project file .classpath # Eclipse classpath file .svn/ # Subversion metadata bin/ .svn/ LoanRecord.hbm.xml # Hibernate metadata lib/ .svn/ hibernate2.jar hsqldb.jar src/ .svn/ LoanRecord.java # my one and only source file
$ svn status ? bin/LoanRecord.class S bin ! bin/LoanRecord.java
Uh, what? I understand that SVN doesn't know about the class files in the
bin directory, but what's with the "S"? And why does it think that there ought to be a file called
An hour and a half later, after chatting with Ben Collins-Sussman and others on the Subversion IRC channel, we  have an answer. When Eclipse builds your code, it copies the
.svn sub-directory from the
src directory into the output
bin directory. Yup, you heard that right: Eclipse overwrites the
.svn sub-directory in
bin when it compiles .
Now, if I could track down Eclipse's developers, they would probably either say, "It's not our fault---Subversion didn't even exist when we started work," or, "Yeah, yeah, we know, our bad, sorry," but I wouldn't accept either. I might forgive them if Eclipse popped up a dialog saying, "Hey, you have some files here that I don't know anything about, do you mind if I crush them?", but it doesn't even do that. Trampling on files and directories that aren't yours is just plain rude; anyone who has been programming for more than a few months ought to know better.
The fix is simple: don't add the
bin directory to the repository . But let's do some math. Assume there are 10,000 Subversion users out there. Assume that a quarter of them are using Eclipse, and that one in ten of those make the same mistake I did (adding the compile output directory to the repository). If each one of them wastes two hours figuring this out (half the time it took us), that's 500 hours, or twelve and a half working weeks. You can write a lot of software in twelve and a half weeks...
Which is what we have to do, now that Eclipse isn't getting in the way. Onward!
 David James, Michelle Levesque, and Greg Wilson.comments powered by Disqus