I started with a nice simple problem: do a global search and replace on the image directory path to save bandwidth (by pointing to a caching server.) I used this regular expression and then had two problems:
- This isn’t easy to read (which isn’t a huge deal since I only have to run it once.)
- The find and replace updated the hidden .svn directory too. Which meant when I went to sync with SVN, it thought it was up to date and didn’t commit anything.
find $path/templates/default -type f | xargs perl -pi -e ‘s/\$\{contextPath\}\/templates\/default\/images/\$\{imagesServedFrom\}\/templates\/default\/images/g’
- Find all files in the templates/default directory or any subdirectories
- Do a search for ${contextPath}/templates/default/images and replace with ${imagesServedFrom}/templates/default/images
The bigger problem is that I made a bunch of other changes in my commit and didn’t notice that none of the template/default/image changes got committed. Eclipse/SVN didn’t commit the changed files because the .svn directory’s base file was changed as well.
I solved this by disconnecting from SVN in Eclipse. (Team disconnect) and deleting the metadata when prompted. I then reconnected to SVN, Eclipse saw the difference and I committed normally.
If I was doing this again, I’d update the find statement to exclude the .svn directories.