svn:externals micro howto In WebTech, 1017 days ago 

Disclaimer: what follows reflects my actual setup. It could be “a quick and dirty hack” or something, and couldn’t be very polite and/or technically perfect. But it works.


If your projects share a common code base (a library, a framework, a bunch of javascript scripts residing somewhere on a svn repository), what you really need is the help of the svn:externals capabilities. Let’s call this “shared code base” the SCB. By using this feature, your project:

  • uses an actual physical copy of the SCB (not symlinks)
  • should not care about changes in the SCB: they will be in syncrony upon each update, transparently as usual

What follows is my actual setup. My PHP projects share a common set of PHP scripts (they are the framework, shudder!). They reside in a repository by their own.

I decided to put those scripts in a directory in the project source tree, calling it “lib”.

I then went in the directory where “lib” will be created, and I instructed svn to hook here a copy of some externals file (that is, the framework). The svn command to use is propedit, being svn:externals a svn property.

Ok, sitting in the parent directory of “lib”, I issued something like:

svn propedit svn:externals .

(please note the final “.”)

What I said, in substance, was: “Please edit the values of the svn:externals property for the current directory”. Indeed The System fired up my editor to enter the actual values (what? No editor? An error, instead? No worries: “export EDITOR=vim” and retry).

Those values are a list (line by line) of pairs. Each pair is composed by a directory name and a repository path. So, getting a “library” residing in the trunk of my “uberfw” repository this residing on www.mysecretretrepository.com is a matter of writing:

lib svn://www.mysecretrepository.com/uberfw/trunk/library 

Save the file and you’re done.

Now you have to “svn update”. This time the “externals” will be actually fetched and the “lib” created.

Finally (I swear), commit (nothing apparently will be transmitted).

A BIG note of WARNING: what have to be clear is that the externals are NOT an exported snapshot of a repository path: they are an actual working copy. BUT! If you make changes into a directory provided as an external, you have to explicity commit BEING INSIDE that directory, otherwise the changes will not be committed.

Instead, an update on the root directory of the project will fetch also the (eventual) externals changes.

Learn more on this topic from the subversion book.

Comments

commenting closed for this article

This site

Browse by category

Contacts

Feed from feedburner Subscribe to this feed with Bloglines

Creative Commons

XFN Friendly