Effective and easy "sparse checkouts" . . . #svn-viewspec.py script

Just when going through the sparse checkout concepts, I was given an opportunity to explore the viewspec.py script

http://svn.apache.org/viewvc/subversion/trunk/tools/client-side/svn-viewspec.py?revision=966710&view=markup

It was really an effective and an easy-to-use tool for “sparse checkouts” and interesting too…🙂

Usage:
1. __SCRIPTNAME__ checkout VIEWSPEC-FILE TARGET-DIR
2. __SCRIPTNAME__ examine VIEWSPEC-FILE
3. __SCRIPTNAME__ help
4. __SCRIPTNAME__ help-format

Here is a sample viewpec file which I used.
——————————————-
Format: 1
Url: http://svn.apache.org/repos/asf/subversion
Revision: 955767

trunk/**
branches/1.5.x/**
branches/1.6.x/**
README
branches/1.4.x/STATUS
branches/1.4.x/subversion/tests/cmdline/~

——————————————-

Here I am trying to checkout the revision 955767 as follows:
Format – version of the viewspec format used throughout the file
Url – base URL applied to all rules; tree checkout location

1. Infinite depth of trunk/
2. Infinite depth of branches/1.5.x/ and branches/1.6.x/
3. the README file
4. ONLY the STATUS file under branches/1.4.x/
5. ONLY the file children under branches/1.4.x/subversion/tests/cmdline/

NOTE FOR WRITING VIEWSPEC FILE:
PATH/** – checkout PATH and all its children to infinite depth
PATH/* – checkout PATH and its immediate children
PATH/~ – checkout PATH and its file children
PATH – checkout PATH non-recursively

The /subversion/tools/client-side/svn-viewspec.py script reads the VIEWSPEC file and gives the sparse checkout.

The command I used is as follows:

$/home/prabhugs/svntrunk/subversion/tools/client-side/svn-viewspec.py checkout /home/prabhugs/viewspec /home/prabhugs/sparse-wc

Here….
1. viespec is the file whose contents are shown a little above.
2. sparse-wc is my sparsely checked out working copy.

This makes the sparse checkouts much easier…

Suppose the viewspec file itself is versioned under some repo… In that case, we can use the following command…

$ svn cat http://svn.example.com/specs/viewspec |
__SCRIPTNAME__ checkout – /path/to/target/directory

My command is as follows:
$ svn cat file:///home/prabhugs/localrepo/viewspec | /home/prabhugs/svntrunk//subversion/tools/client-side/svn-viewspec.py checkout – sparse-wc2

NOTE that here, I have used “-” instead of specifying the “viewspec” filename.

This is because, the “svn cat” reads the contents of “viewspec” file from the repo and puts the content in the stdin… The “-” reads the input from the stdin (and not from a file).

Now the contents of the viewspec file from the repo are read and the respective sparse checked out working copy directory is “sparse-wc2”. . .

One thought on “Effective and easy "sparse checkouts" . . . #svn-viewspec.py script

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s