Just when going through the sparse checkout concepts, I was given an opportunity to explore the viewspec.py script
It was really an effective and an easy-to-use tool for “sparse checkouts” and interesting too… 🙂
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.
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
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”. . .