January 27, 2006

HowTo: Get Out The Icon Files In A Subversion Repo

Filed under: ResearchAndDevelopment — Ryan Wilcox @ 11:08 pm

I got bit by it: I loaded a Icon\r file into my subversion repository accidentally and blew it up (just like Andrew Pontious).

However, Andrew doesn’t actually tell you how to fix the problem, beyond some vague mutterings about svndumpfilter. I’m going to show you how.

So you committed some Icon files to your repository. Oops.

Where did you commit this Icon file?

This is important. Usually you’ll need to try to do an svn checkout on a machine to find out where your icon files are. (Just make sure it’s not a machine with changes or anything!!!!) I haven’t figured out how to find multiple Icon files, so let’s just hope you checked only one in.

Dump your repo

There’s no repository-wide svnadmin delete command. In a way, I can see this as a good thing (“Don’t remember your files, boys and girls, just mark them as deleted so you can come back to them”), and a bad thing (like in this situation where we really want to delete that file.) We can, however, get around the issue by dumping out the repository then filtering out the Icon files.

SSH into your Subversion Server

Yes, you’ll need to execute commands on the server itself.

Dump your repo using these commands


(your now in your repository folder at this point)

$ sudo svnadmin dump . > ~/Temp/wholeRepo

What we have done is dumped your repository out in an almost-human readable format. Human-readable, assuming you like scrolling through multi-megabyte text files with your favorite unix text editor. No thanks. svnadmin will dump this text through standard out, so pipe it to a file. Here I pipe it into a file in my Temp folder. (I suppose you could also use /tmp/, but, better to pipe it somewhere not that scary.)

Filter your dump file

This one took me careful reading of the svnbook to find (but since I was in quasi panic mode, I couldn’t do careful reading in the svndumpfilter section. The docs in that section need to be clearer, ’cause having your repository go boom is scary!)

Filter your dump file using these commands

cat ~/Temp/wholeRepo | svndumpfilter exclude PATH/TO/IconFILE/Icon > ~/Temp/outDamnIconOut


A mildly scary command, so let’s take what I did:

cat ~/Temp/wholeRepo | svndumpfilter exclude Work/HxNewbies/Icon > ~/Temp/outDamnIconOut

Here I take my dumped repository (from ~/Temp/wholeRepo, remember?), and pipe it into svndumpfilter. Now, this command works on a stream of data from STDIN, and not from a specified repository (like I expected it did). Feed it your dumped file, tell it to exclude the the icon file you found (mine was in Work/HxNewbies/Icon). This, like svnadmin dump, will dump the stream to STDOUT, so we capture it.

Results from svndumpfilter

svndumpfilter will tell you what files it excluded, so you can judge if it worked or not. If you don’t get the results you expect, maybe you misspelt the path or something (and you do have to specify the repository relative path to the file, just like I did for my Icon file above.)

Dropped 1 node(s):
'  '/Work/HxNewbies/Icon

Move your old repo, and use your new one


$ svnadmin create /YOUR/REPO/PATH/HERE

$ svnadmin load yourdeadrepo

In English: move your current (dead) repository aside and make a new, empty repository container. Now take the data from your old repository (without the Icon file!) and import it into the container.

How To Not Do It Again

That was annoying, and I want to make sure I never have to do that again. Luckily subversion has several ways to mark files as ignored, thus excluded from (normal) svn status listings.

Locally to repository

Now it seems like you should be able to use the svn:ignore property to filter out Icon files. In theory, yes, in practice, no. In a footnote in the properties section we have:

The patterns are strictly for that directory—they do not carry recursively into subdirectories.

The fact that these properties only apply to the directory doesn't work for us, as the system could put Icon files in theory anywhere. (In practice, only where you have a custom icon... maybe. I didn't have a custom icon in my HxNewbies folder). So we can't use this method (unless we wanted to apply this property to every folder of our project "by hand" (ie: writing a shell/perl/python script to do it). Still doesn't sound good.

"Global" to user on machine

When subversion runs for the first time it creates a .subversion folder in your home folder. This holds configuration information for your user on that machine. Any settings made here will apply to every subversion operation you, as that user, make. In particular, we want the global-ignore option.

$ cd ~/.subversion

$ pico config

(Pico is easy. If you have a favorite editor go use that, I don't care.)

In this config file, find the global-ignores line and uncomment it. (A comment any line that begins with a pound sign.). There can be no leading whitespace on that line (I had to trim a bit off mine.)

With that line uncommented, add Icon* to the end. The items in this line are white-space delimited, so just go to the end of the line, type a space, and append Icon*. (Icon* because, remember, the Icon file actually has a return at the end!)

More Trouble (On The Client Side)

Even after all that I still had issues, except now they were on the client side: Icon was still giving me fits. I knew it wasn't in the repository, so but svn on the client side thought I wanted to delete the file. Maybe this was due to my previous attempts at removing the file (via the svn client app), or maybe this was due to the state of the repo on that machine. I did a svn revert and my icon file went away.


May you never fall into this mess, but if you do, may these tips help (and make it never happen again!)

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment