Friday, August 8, 2008

SVN configuration file

Lot of people like me don't know about a configuration file in subversion on the client side which can help in setting up a lot of default options for them. It took me a time to figure it out, so I guess its worth talking about.

The file resides at: %APPDATA%\Subversion\config on Windows systems.

Some of the uses of this file are:
  • Identifying different file extensions which should be ignored by default
  • Identifying different file extensions for which svn:eol-style=native can be set by default.

Working with the SubVersion Config file

In the following I will show you some examples of how you can use this config file to make your life easier.

Global Ignores

Typically when I work on my python projects, a number of *.pyc files are generated when Python compiles my source files. It is annoying to see them listed whenever I run svn update or svn status commands. Fortunately one can specify a set of file name patterns (typically wild-card based) which will be ignored by default.

In your configuration file:

  • Search for a line with keyword global-ignores
  • If the line is commented, un-comment it
  • add a list of file patterns which you wish to ignore

On my side it looks like:

global-ignores = *.o *.lo *.la *.pyc *.obj .DS_Store

VC++ programmers may like to add *.obj, *.exe, *.lib, *.dll etc.

Auto Props

SVN allows you to set some properties on the files. Some of the commonly used ones are svn:externals, svn:eol-style, svn:keywords etc.

I work on multiple platforms (Windows/Mac/Linux). Hence I usually need to check-in my source code with svn:eol-style=native so that when it is checked out on different platforms, the end of line characters are adjusted accordingly. (Read more about it in SubVersion manual).

My problem was that I had to do this manually for each file. Later on I found that its possible to specify in the configuration file a few automatic properties which get attached to a new file the moment its added to SVN repository.

  • Find out a line which has enable-auto-props
  • Make sure its un-commented
  • Make sure that it looks like: enable-auto-props=yes
  • Find out a section [auto-props]
  • For each file pattern of your interest (*.c, *.cpp, *.py), define the automatic properties which you would like to be setup. e.g.: *.py = svn:eol-style=native;svn:keywords=Id
  • You are done!!!

SubClipse and SVN

SubClipse supports two different SVN interfaces. JavaHL and SVNKit. JavaHL uses the same configuration files as the command-line client viz. %APPDATA%\Subversion\. SVNKit caches information in Eclipse keyring. I don't know much about it and won't talk about it. I am happy with JavaHL SVN interface for SubClipse.

I hope this post is useful to SubVersion users around the world.

No comments: