Wednesday, June 29, 2005

Using Subversion (SVN) Properties to improve version control

This is a tutorial by example...

Lets say you check out the MyApplication tree by using:
$> svn co svn+ssh://repos@server.domain.com/home/repos/repository/trunk/MyApplication/java Java

Now you have the MyApplication source in Java/ and this is what the tree looks like:

[karan@karan Java]$ ll
total 68K
-rw-rw-r--     1 karan karan 3.3K Jun 29 16:54 build.xml
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 config
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 lib
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:40 nbproject
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 other
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:23 resources
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:23 src
lrwxrwxrwx  1 karan karan   36 Jun 29 16:23 swingSkins -> /usr/local/skinlf-1.2.11/swingSkins/
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 impFiles

When you run ant to build the src, the Java/ tree is going to look like this:
[karan@karan Java]$ ll
total 84K
drwxrwxr-x  3 karan karan 4.0K Jun 29 17:08 build
-rw-rw-r--     1 karan karan 3.3K Jun 29 16:54 build.xml
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 config
drwxrwxr-x  3 karan karan 4.0K Jun 29 17:08 dist
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 lib
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:40 nbproject
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 other
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:23 resources
drwxrwxr-x  4 karan karan 4.0K Jun 29 16:23 src
lrwxrwxrwx  1 karan karan   36 Jun 29 16:23 swingSkins -> /usr/local/skinlf-1.2.11/swingSkins/
drwxrwxr-x  3 karan karan 4.0K Jun 29 16:23 impFiles

Notice the build/, dist/ directories.
If you would have compiled the sources from NetBeansant would also have created a manifest.mf and a test/ directory.

Users of SVN would notice that if I run svn status right now, I am going to be bugged by a whole lot of "?s" which is SVN's way of asking
"what do i do with build/, dist/, test/.....??"
I can either choose to leave them as it is, checking in/out only the dirs that I know I need. However, as the application grows, so does your margin for error to miss a directory or file.

So to make SVN conveniently ignore the build/, dist/, etc. trees and files do the following in Java/:
$> export SVN_EDITOR=nano
$> svn propedit svn:ignore .
In the nano editor window that opens up write the following:
build
dist
test
manifest*
+ any other files that you want to be ignored

Hit ^o to save and ^x to exit.
Now if you run svn status you will see that svn conveniently ignores the build/, dist/, etc. directory structures.
So you can safely filter the directory structure processed by SVN, to keep in the repository.
Mission accomplished!

Powered by Blogger