Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Gautam

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

svn cd.

Shell Alias that allows you to cd into a svn repo, without checking out the entire repository.
Since, each checkout or update is done non recursively, the entire repository is not checked out.

   1  
   2  function scd() {
   3      # Get SVN repo url and remove the parts we don't need.
   4      if svn ls `svn info |grep "URL: http://"|cut -c6-`/$1
   5      then
   6          # Break apart each entry in the path 
   7          for partial in $(echo $1 | tr '/' ' ')
   8          do
   9              # non recursively update that part and cd
  10              #  into the direcotry. 
  11              svn update -N $partial
  12              # Should check to see if the last entry is a 
  13              # file or directory before cd'ing into it.
  14              # Could do it like so:
  15              # if file $partial | grep -e ': directory$'
  16              # then
  17              #  cd $partial
  18              # fi
  19              # But I have not tried it out.
  20              cd $partial
  21          done
  22      fi
  23  }


The way one would use it is. First checkout you repo as normal except use a -N flag as well.
For example:
svn co -N http://www.example.com/repo/ /home/example/repo

Now say yoy wanted to go to your trunk, you would do:
cd /home/example/repo
scd some/long/path/to/a/set/of/modules/module1/trunk

You would now be in some/long/path/to/a/set/of/modules/module1/trunk everything but trunk checked out.
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS