Home > Technology > SVN Beef To Pick

SVN Beef To Pick

I don’t normally write about technical things on my blog, but I’ve got to here.

If you venture over to Laura’s blog, at least at the time I’m posting this, you’ll find all of her uploaded photos missing. Why?

I’m using Subversion for source control on my server. It allows me to keep all of the files for all of the websites on the server archived, so that if I ever need to go back to a previous version or get those files easily on another computer, there you go.

Well, Subversion’s got a set of commands for adding new files, deleting files and committing what you want to do:

  • svn add <file|folder>
  • svn del <file|folder>
  • svn commit

Basically, you use add to schedule adding a file or folder to source control. You use del to schedule deleting a file or folder to source control. You use commit to actually execute the scheduled commands to the server.

So it’s obvious I did a del, right? Well… Sort-of. I did svn add on Laura’s uploads/ directory to add the directory to source control. I was then going to have it ignore any uploaded files because I don’t want those in source control.

Well, add is a recursive command, meaning, any files and folders within uploads/ would be scheduled to be added too. This wasn’t the behavior I wanted, and forgot to add a flag to the add command to only work on that one directory and not those underneath it.

So I performed an svn del because I wanted to remove the scheduled addition of all of those files to source control. Only problem is, it actually removed those files from the local filesystem too. So thus, all of Laura’s uploads were lost. Again, I forgot a flag. The flag I forgot this time was to leave all of the local files in place and only schedule the removal on the server.

So… What’s the problem? The problem is, Subversion is built around not losing things. If I had committed the add before running the del, then I could have at least gotten the files back out of an older revision and then done some work afterwords to fix things.

The problem here was the default behavior. My problem was, I was trying to add files that were not in Subversion control, but performed a del before committing those files. The default behavior was to remove them from the local filesystem, but the problem with that is, they weren’t in Subversion control! They were only scheduled to be added!

That’s an awful, awful default behavior. Sure, I really fucked it up, but the default behavior for an add->del combo without a commit should be to just remove the scheduled add and leave the local files alone.

Poor Laura’s going to have to re-upload all of her files now. D’oh! I owe her now.

Sphere: Related Content

  1. No comments yet.
  1. No trackbacks yet.