sub

October 2, 2007 Alex Chaffee

Yellow Submarine

(Update — version 0.3 released 2-Oct-07. Release notes are here.)

We use subversion for our source control. We love it. But we’ve noticed a few flaws, and a few weeks ago I decided I’d had enough and wrote a wrapper for it that fixes a few of the most glaring ones:

  • Externals get messed up pretty frequently. If you remove or rename an external, the old one gets left around on disk, and if you convert an external to a “real” directory or vice versa then the next update simply fails.
  • Externals are updated in series, not in parallel, meaning that if you have a lot of externals your updates can take an excruciatingly long time.
  • Externals are updated even if they’re frozen to a specific revision number, which wastes even more time on update.
  • If you want a clean checkout — say, for an automated build — the only way to do it is to do a full checkout, even if 99% of the files are already there on disk.
  • The co command is not compatible with the convention of putting files under /trunk, requiring you to type out your whole repository URL followed by /foo/trunk foo
  • The name of the executable is hard to pronounce — either “ess vee enn” or “seven”, but nobody says “seven” except when they’re saying “seven up”, which is, I admit, a pretty good pun, but come on, how much cooler is it to say, “sub”?

The current version of sub fixes all of the above (except for converting directories to and from externals, and I’m going to make that work pretty soon).

Install with

sudo gem install sub

Help text is below the fold.

Usage:
  sub co project_name [dir_name]
    checks out [base_url]/project_name/trunk into ./project_name (or dir_name if specified)
  sub up [dir]*
    fast update (default command, so 'sub dir...' or just 'sub' work too)
  sub help
    prints this message

Options:
  --verbose, -v
      lots of output
  --quiet, -q
      no output at all except for errors
  --help, -h
      prints this message
  --clean, -c
      'up' command removes all unversioned files and directories
  --url [base_url]
      sets base repository url for 'co' command
      (default is ENV['SUB_BASE_URL'] or ENV['SVN'] or svn+ssh://rubyforge.org/var/svn)
  --version
      prints release version

Using sub up took the update time for my main project from 16.5 sec to 3.5 sec (we have about 20 externals).

If you have a common repository like we do, set it in your .bash_profile like this

export SUB_BASE_URL=https://svn.mygreatcompany.com/svn

and then

sub co foo

will run

svn co https://svn.mygreatcompany.com/svn/foo/trunk foo

Otherwise it’ll default to Rubyforge’s repository.

If you want to see what commands it’s executing, --verbose will show you (it indents the system commands so they’re easier to spot).

Enjoy! And please suggest improvements of any kind.

About the Author

Biography

Previous
Cacheable Flash 0.1.4 — Test Helpers
Cacheable Flash 0.1.4 — Test Helpers

I just released Cacheable Flash 0.1.4. This version includes test helpers so you can easily test your cache...

Next
dot.rake
dot.rake

Article moved to http://www.pivotalblabs.com/articles/2007/10/15/dot-rake