Friday, January 08, 2010

Gotcha Of The Day: Convincing Subversion To Pull All Directories From The Server

Subversion has an interesting operating philosophy:

One of the fundamental rules of Subversion is that a “push” action does not cause a “pull”, nor the other way around. Just because you're ready to submit new changes to the repository doesn't mean you're ready to receive changes from other people. And if you have new changes still in progress, then svn update should gracefully merge repository changes into your own, rather than forcing you to publish them.

One of the side effects of this is that you can have a repository with the structure:

 webapp
  +-- images
  +-- js
  +-- huge-dir

You can say:

  svn update -N webapp      #pull down webapp and no subdirs
  cd webapp
  svn update images js
  # ... stuff happens ...
  svn update

The result is that you can pull down the images and js subdirectory, but not huge-dir. When you do the svn update to pull in changes, subversion does not automatically pull down huge-dir.

This can be a good thing, as it allows you to run a svn update without pulling in stuff you don't want.

But, yesterday, I wanted to pull down all the directories - in other words, I wanted:

  svn update

To grab huge-dir. I read up on Subversion, but couldn't find the right incantation to do this.

My hack?

  svn update `svn ls`

svn ls gets a list of all the files in current directory from the server, and svn update explicitly updates them. I'm sure there's a cleaner way to do this, though in a hurry, this worked.

The svn ls is also a nice reminder that Subversion isn't just about commits and updates - it's actually a remote filesystem that you can play with as needed.

2 comments:

  1. I've always been a fan of the command-line access of SVN... I also like the Subversive plug in for eclipse, but with my new job I've been using TortoiseSVN from tigris and been hearing about RapidSVN.

    TortoiseSVN is a windows application that really helps demonstrate the fact that SVN is a file system and integrates it with your windows file browser. Plus it lets you simply move folder around without having to know much about the inners of SVN, its really almost like working with a mounted drive.

    I haven't tried RapidSVN yet, but it is suppose to be good to.

    ReplyDelete
  2. Nick -

    I've used TortoiseSVN before, and yeah, it's slickly done. Though what I don't do with svn on the command line, I find emacs' interface covers well.

    -Ben

    ReplyDelete