toxicsoftware.com

RANDOMIZE USR 0

toxicsoftware.com header image 2

Mac OS Custom Icons and subversion don’t mix

September 20th, 2006 · Comments · Default

I had some big trouble with subversion today. I had upgraded to subversion 1.4 on both client and server a few days ago and today something went tits up with the repository on the server. I wont go into more detail here until I’ve reproduced and isolated the problem but suffice to say I deemed it worthwhile to try and restore my subversion repository from a recent dump file. Try was the operative word:

[schwa@umbriel] Dumps$ admin create test
[schwa@umbriel] Dumps$admin load test < dumpfile 'vnadmin: Invalid control character '0x0d' in path 'trunk/Path/To/Some/Directory/Icon<

My attempt to recover from a dumpfile failed because my repository contained a folder with a custom icon. Crickey. I find it odd that subversion lets me check these bad files into subversion in the first place. But whatever, I had to recover this dump file. Fortunately there is a tool called ‘dumpfilter’ that can be used to filter arbitrary paths in dump files. But after removing the first bad Icon file I found this particular repository had more than one. Instead of removing them by hand I started to write a shell script to automate the filtering process. Of course my shellfu is too low so I switched to Python:

#!/usr/bin/python
import commands
import re
import sys
theInputFile = sys.argv[1]
theOutputFile = None
if len(sys.argv) > 2:
    theOutputFile = sys.argv[2]
    thePattern = re.compile(r'^Node-path: (.+/Icon\r)$')
    thePaths = [thePattern.match(theLine).group(1) for theLine in open(theInputFile) if thePattern.match(theLine)]
    if theOutputFile == None:
        print 'Found the following paths:'
        for thePath in thePaths:
            print '\t\'%s\'' % thePath.replace('\r', '\\r')
        else:
            theCommand = 'dumpfilter exclude %s < %s > %s' % (' '.join(['\'%s\" % thePath for thePath in thePaths]), theInputFile, theOutputFile)
            print commands.getstatusoutput(theCommand)[1]

This script, when passed a path to an existing subversion dump file, will list all paths within the dump that contain custom icons. When passed a path to an existing dump file and the name of a new dump file it will remove all paths containing custom icons. You can then use this new dump file to populate your subversion repository without those pesky files. Update: From the comments, a link to Ryan Wilcox’s blog page concerning the problem (and a more detailed description of the solution): http://www.wilcoxd.com/blog/howto-get-out-the-icon-files-in-a-subversion-repo.html

Tags: ·

  • cos
    weird. has never let me check "Icon\n" files into the repository in the first place due to the name.
  • Go figure. I have them though. Maybe a previous version of did allow this files into the repository.

    This probably means you wont need to add the file pattern to the -ignore configuration.
  • When I encountered this I just had the one Icon file, so I didn't have to write a script to do it :)

    (and to never do it again, set the global-ignore option in your ~/.subversion/config file to Icon*)

    Blog entry with my woes on the issue
  • Ryan, lucky!

    I didn't have that many either (about 3 files each in 2 repositories). But the dump/filter process took so long (large repositories) that I didn't want to dork about.

    Your blog page is great, going into more detail about the problem. The only problem with it is that you can't always find the Icon files by doing a checkout. My icon files were in a directory that had previously been deleted - but the dump file was _still_ corrupt (I had aactually deleted them from one repository and moved them to another). You really do have to scan the dump file for the files themselves.
  • Blake Chaffin
    Did you get a chance to ask Brian Fitzpatrick about this at C4? I asked him, but couldn't remember which blog it was, sorry. At any rate, he was unaware of any issues at the time.

    Sadly, there were several people I didn't get to meet, and I guess you're one of them. Maybe next year...
  • Rob
    Thanks for the info guys.

    I have a repo with many OmniGraffle docs that had their own icon file. They all bork the admin load.

    Best way to find all Icon files is:

    grep "^Node-path: .*/Icon" repo.dump

    I then used a multi-line argument call to dumpfilter to exclude all the Icon paths in one call:

    dumpfilter \
    exclude "Project/Diagrams/Garment Meeting 20050601.graffle/Icon" \
    exclude "Project/Diagrams/Inspector/Fabric Order Inspector.graffle/Icon" \
    exclude "Project/Diagrams/Inspector/Inspector Sheets.graffle/Icon" \
    exclude "Project/Diagrams/Reports/Testing.graffle/Icon" \
    exclude "Project/Diagrams/Wizard/Fabric/New Fabric Order.graffle/Icon" \
    exclude "Project/Diagrams/Wizard/Fabric/New Fabric Supplier.graffle/Icon" \
    exclude "Project/Diagrams/Wizard/Fabric/New Fabric.graffle/Icon" \
    exclude "Project/Diagrams/Wizard/Wizard Template.graffle/Icon" \
    exclude "Project/Diagrams/Reports/Fabric/Workspace Reports.graffle/Icon" \
    exclude "Project/Diagrams/Inspector/Fabric/Fabric Inspector.graffle/Icon" \
    exclude "Project/Diagrams/Inspector/Fabric/Supplier Inspector.graffle/Icon" \
    exclude "Project/Diagrams/Reports/Fabric/Detail Report.graffle/Icon" \
    < repo.dump \
    > repo.filtered.dump
blog comments powered by Disqus