Subversion Install Swankiness Part 2

Nothing Like A Fresh Subversion Import
Nothing Like A Fresh Subversion Import

Welcome back to part 2 of my Subversion install series.  What we are going to go over is developing the right structure for the repository, importing a website, updating a website, then testing and deploying the website using some of Subversion’s command sets.  There were some road blocks along the way and I will talk about that as well as some other thoughts about the process.  After that I’ll talk about what’s next but first let’s setup and deploy some code.

The first step in molding the fresh install of Subversion into something workable, was to decide on what kind of structure I wanted to keep.  Articles online discussed whether or not to keep multiple repositories for projects or maintain a single repository to house multiple projects.  In thinking of how I wanted it implemented, the simplicity of maintaining a single repository won over the cleanliness of revision management in multiple repositories.  Perhaps at a later date I can split it out or even incorporate Git, but for the purpose of getting started I’m going with one repository.

I decided to follow the svnbook’s advice of a creating a temporary directory structure to setup the initial framework of the repository.  In my case, there are three major areas I will develop in:  websites, scripts, and home related projects.  I created the structure and imported them in to Subversion using the svn import command.  After which, I deleted the temp directories and verified the structure below.  Here’s the output:

hokey@tardis:~/tempdir$ sudo svn import . file:///var/svn/ --message 'Initial Repository Layout'
[sudo] password for hokey:
Adding         scripts
Adding         headquarters
Adding         web
Adding         web/gonzoguys.com
Adding         web/gonzoguys.com/trunk
Adding         web/gonzoguys.com/branches
Adding         web/gonzoguys.com/tags
Adding         web/h0key.net
Adding         web/h0key.net/trunk
Adding         web/h0key.net/branches
Adding         web/h0key.net/tags
Adding         web/hoketronics.net
Adding         web/hoketronics.net/trunk
Adding         web/hoketronics.net/branches
Adding         web/hoketronics.net/tags
Adding         web/kccollegegameday.com
Adding         web/kccollegegameday.com/trunk
Adding         web/kccollegegameday.com/branches
Adding         web/kccollegegameday.com/tags

Committed revision 1.
hokey@tardis:~/tempdir$ svn list --verbose file:///var/svn
1 root                  Nov 18 08:44 headquarters/
1 root                  Nov 18 08:44 scripts/
1 root                  Nov 18 08:44 web/
hokey@tardis:~/tempdir$

It was time to work with local install of my website.  I copied the production code to my home folder on my local webserver.  After setting up the database and changing root path directives, I set about verifying the local page.   It looked good so I then downloaded the latest WordPress package.  Following the directions, I copied the updated code and again verified the website.  The recent point releases didn’t affect the database schema, so I was good on that end.

Now that I updated my code to the latest WordPress point release, I imported the website into the Subversion repository.  Using svn add, I recursively added all of the new files from my website.  When it successfully added the file set, I committed the change using svn commit, complete with the initial import message.  Subversion pulls from CVS alot and these two commands reflect that.  It almost felt like I was greasing the code revision bicycle gears and getting back to the smooth ride of code management.

So now that I added the website files to the repository, I did it twice because of another point release in WordPress, it was time to test and deploy the code.  Using the svn export command, I copied the code to the web docs directory on my local webserver.  I decided on doing that instead of checking out the repository on the live site because I’m on a shared hosting platform for production and I didn’t want trailing ‘.svn’ folders eating up space.  Plus it adds the benefit of greater security.

hokey@tardis:/var/www/hoketronics.net$ sudo svn export http://localhost/svn/web/hoketronics.net/trunk ./hoketronics.net

The code exported to the local server.  This is where I ran into some issues.  The code portion of the website works well in different directories, but I need to come up with a way to manage dev/test/prod databases for link resolution.  The logon screen for the local test install pointed to the local dev install.  Regardless of that little issue, the code tested out well.  Now it was time to deploy the website to my shared host, minus the config file.

The other issue I ran into was the process of updating my shared host with the new code.  I run Linux on the webserver locally but my workstation runs Windows XP.  The best way, I thought at the time, to copy the update was to compress the test folder, copy it to my workstation, and then use Filezilla to copy it up to my shared host.  This proved laborious and it ended up taking more time than I expected due to two reasons: remembering the correct compression one liner and not taking advantage of a command line ftp client on the local webserver.

That said, the production site on the shared host updated with no breaks.  I logged on, verified the version, and inspected both the UI and and the backend files for any issues.  The Subversion process was almost complete.  After I updated the code, I made note to change the initial work flow for updating my site to handle updates from the local webserver to the shared host.  Also, I’ll take some time to flesh out different configs for my environments to avoid any path issues the next time around.  Lastly, I’m going to make sure I centralize my one liners for easier access, maybe even using the repository to keep track of additions.

Subversion seems like a great centralized source code management tool.  With my CVS experience under the belt, much of the commands feel familiar and comforting when I invoke them.  Now that I have the repository live, kccollegegameday.com is getting some work.  I’m looking forward to checking the ‘diffs’ when modifying pages and themes.  Chances are you’ll see me talk about that on top of a couple of article ideas due to the roadblocks experienced with this project.