Setting up local Subversion for use with Coda and MAMP
I spent most of last year using Subversion via command line at the request of the client I was working with at the time. Because I'm geeky in a different way to those who are comfortable in commandlineville, it was all set up for me, and all I had to cope with were the commands to check out, check in, and occasionally, resolve a conflict.
In time, I got reasonably comfortable with those commands but I had no real idea how to go about setting up Subversion (or any other version control system) for myself, and haven't had or felt the need to do so until now.
I had hoped that I'd be able to find an easy to follow tutorial online, but either my googlefu has failed me, or it doesn't exist. What I did find were several tutorials that assume that you're comfortable with the command line or that you know how subversion works and what to do, and that isn't me, so I figured I'd set out what I did, in the hope that it might be helpful to a) someone else and b) me, when I come to do this again and realise I've completely forgotten what I did.
Disclaimer: This may not be the absolute best way to go about this, but it's what I did and it works. If there are better ways to do any of these steps, I'd love to know, so please leave a comment.
Step 1: Setting up Subversion
Follow the first part of the instructions handily provided at Ruby Robot's Subversion With Mac OS X Tutorial but stop when you get to "Creating a Sample Subversion Project".
Step 2: Create a Repository
In a fresh Terminal window, I changed directory to my MAMP directory htdocs folder by typing cd [path/to/htdocs] where in my case it was cd ../../../Applications/MAMP/htdocs (because MAMP installs to the Applications folder and I don't know how to/if you can move it without breaking it.
I then created the repository by using the command from the tutorial:
svnadmin create SVNrep
This created a SVNrep directory in my htdocs folder.
You could put the SVNrep directory wherever you like - I just wanted it close to my other working files.
Step 3: Set up a username and password
Use finder to go to the SVNrep directory, and find the conf directory. It will contain three files:
authz passwd svnserve.conf
Open svnserve.conf in whatever text editor you're comfortable with and uncomment line 20 (delete the # and space) to use the default password file. Save it and close it.
Open the passwd file and add a username and password by typing:
username = password
on a new line at the bottom of the file. Save it and close it.
Step 4: Add files to the repository
To add the site I wanted to be version controlled to the repository, I typed the following into Terminal:
svn import [sitedirectory] file:///[path to SVNrep directory]/[sitename for respository] -m "Initial import"
Then held my breath and hit return.
Step 5: Check out the files so you can work with them
Because I'm a version control moron, I thought I could check out the files to the directory I'd imported them from and they'd be version controlled, but you can't, so I used the following command to check them out to a different directory.
svn checkout file://[path to SVNrep dir/sitename from previous step] [newfolder]
Then held my breath and pressed return again.
Step 6: Set up new site in Coda
If you're setting up a new site once you've done all the previous steps and you choose the [newfolder] you set up in the previous step, it should detect that it's version controlled and the details should appear in the Source Control panel at the bottom of the new site dialog.
If this doesn't happen automatically, put the full path to your repository (the bit immediately after checkout in the previous step) in the Repository URL field.
It also works if you put the localhost url in (e.g., http://localhost:8888/[checkout folder]).
Then enter the username and password you created in Step 3.
Step 7: Test that it all works
Open your new site in Coda, find a file, open it and edit it.
When you save it, an M icon should appear next to the file name. Click this and a dialog should open up asking you to type a comment.
Type a comment, and hit commit.
Step 8: Work with your newly version controlled site
With help from O'Reilly's Version Control with Subversion free ebook if you need it.
Afterword
Obviously, having spent ages writing all this up, I did a quick google for coda subversion guide to see if there were any good tutorials for subversion commands within Coda and found what I wish I'd found to begin with:
A designer’s guide to installing a local copy of Subversion for use with Coda
Typical, eh?
Still, I've done all this now so I'll publish and be damned (or roundly mocked as a moron).