Making the Jump to Subversion
Subject:   Bash script for packages
Date:   2006-04-09 08:37:09
From:   wrashi
As Adam mentions at the end of this article, programs that save stuff as packages (keynotes, TextEdit, etc) sometimes erase the .svn folder, making it impossible to commit the new version into the repository. Adam gives a series of instructions that I have turned into a bash script.

The script is called svnpackup. I like to put these kinds of scripts into script/ in the home Library, and put that directory on my path (so that it gets backed up, but can still be called directly from the Terminal).

svnpackup takes one argument -- the name of the package that needs to be updated. Call this script from within the directory containing the file to be updated.

# @(#)svnpackup -- Update svn packages that have had their .svn folder removed and can't be committed -- Wrashi 06/04/07
# Based on code from Adam Swift's article Making the Jump to Subversion

# Check for package name to be updated
if [ $# -ne 1 ]; then
echo "Usage: svnpackup source"
echo "updates packages that have had their .svn folder removed so they can be committed"
exit 1

# Set up variables for convenience

# Move the package aside
mv "$SOURCE" "$TEMP"
# Get original from the repository
svn update "$SOURCE"
# Move .svn folder
mv "$SOURCE/.svn" "$TEMP/"
# Toss away the old package
rm -rf "$SOURCE" # Using -f so confirmation is not needed for every file
# Move the package back so it can now be committed
mv "$TEMP" "$SOURCE"