Okay, confession. Since the mid-90s I’ve helped produce hundreds of websites. Yet, I’ve been using source code management software for less than 1 year.
Hindsight, right? In retrospect, I was just plain ignorant. Had I been using something like Subversion, I can think of a few big issues on past projects that just simply wouldn’t have mattered.
- Before using Subversion: “Argh. I just royally whacked 189 files in one fell swoop. Curses! When was my last backup?!”
- After using Subversion: “Hrm. I just royally whacked 189 files in one fell swoop. Eh, I’ll just update from the prior revision and try again.”
Source code management irritant
I have a side project, rangelistings.com, built with the Nephtali PHP framework.
Updating the framework source code into my site’s code was trivial, but irritating. With each new release of Nephtali, I would upgrade. I’d do this by doing an export of the Nephtali source from a Google code repository and then copy and paste in the framework files to my working copy.
I couldn’t just drag in a directory because that would drop Subversion’s meta files from that directory and really mess up my working copy. Then I’d spend an extra half hour or so fiddling around to undo my screwed up Subversion copy. Very irritating.
svn:externals to the rescue
I knew about a feature in subversion called “externals,” but had no first-hand experience. I investigated and realized that externals could be the answer to this particular problem.
Here’s how I made use of externals. When upgrading Nephtali, I updated the files in a working copy directory /nephtali/src/NCore/.
- Since you can’t create an external for a directory that already exists, I removed the NCore directory from my working copy and committed that change.
- Using Versions, an SVN client for the Mac, added a property to the src directory (NCore http://nephtali.googlecode.com/svn/trunk/src/NCore/).
- Ran an SVN update on the src directory and, as though by magic, I suddenly had the up-to-date source of Nephtali’s core in my working copy.
On my first attempt, I followed an example I had seen online and created a text document that had the svn:externals property in it, and then added the property ‘-F name_of_file.txt’.
That didn’t work so well. It created the folder, but failed to load the files from the remote Nephtali repository.
Once I put the local directory and SVN URL in the property itself, it worked like a charm.
Here are a couple other pages I used while looking into svn:externals.
- The obligatory manual link: Externals Definitions
- Short tutorial on svn propset for svn:externals property (this one includes the separate text file example)