Next article: Goodbye, Nibs
Previous article: Performance Comparisons of Common Operations, Leopard Edition
Tags: python subversion utility versioncontrol
If you're like me, you sometimes have to edit
rtfd files which are under version control, and it's painful. TextEdit and Xcode will blow away the version control directory (if you use the sort of version control which keeps directories in everything) and it's annoying to work around it. I finally got fed up enough to write a script which works around it for me.
Download the script here. Rename it to bundleedit.py and put it somewhere in your
The script assumes you use subversion, but can be changed to something else by editing the
versionControlDir variable. If you're a CVS user, change it to
'CVS'. If you use something else, hopefully you'll know what to change it to.
Usage is easy. Feed it the path of one or more bundle-style documents which are under version control. It will open them one by one in the default editor for that file type. Make your changes and then quit the editor, and you're done. If you specified more than one file it will re-open the editor for the next one, repeating until you've edited them all.
The concept of the script is very simple. It simply moves the
.svn directory to a temporary location, then opens the bundle. When you're done editing, it moves the
.svn directory back to its original location. End result: you get a modified document that's still under version control.
It takes advantage of two useful flags to the
/usr/bin/open command. The
-W flag makes it wait until the editor quits before continuing so that it knows when to replace the version control directory. The
-n flag makes it always open a new instance of the editor even if it's already running. This ensures that you can quit it without disturbing any documents you already had open.
This script is intended to work with
rtfd files because that's the only bundle type I use which isn't version control friendly, but it should work with any other unfriendly bundle type you might have as long as
open works with it.
Comments RSS feed for this page
Add your thoughts, post a comment:
Spam and off-topic posts will be deleted without notice. Culprits may be publicly humiliated at my sole discretion.