One useful feature that subversion and many other Versioning Systems offer for developers is the ability to include keywords in text files stored in the repository.
These keywords get replaced when some action is done on them by the server. This book excerpt (reproduced below) documents some keyword supported by subversion.
The keyword to be replaced is identified by an anchor in the text with the keyword name surrounded by two '$keywordName$.
Subversion defines the list of keywords available for substitution. That list contains the following five keywords, some of which have shorter aliases that you can also use:
LastChangedDate
This keyword describes the last time the file was known to have been changed in the repository, and looks something like $LastChangedDate: 2002-07-22 21:42:37 -0700 (Mon, 22 Jul 2002) $. It may be abbreviated as Date.
LastChangedRevision
This keyword describes the last known revision in which this file changed in the repository, and looks something like $LastChangedRevision: 144 $. It may be abbreviated as Revision or Rev.
LastChangedBy
This keyword describes the last known user to change this file in the repository, and looks something like $LastChangedBy: harry $. It may be abbreviated as Author.
HeadURL
This keyword describes the full URL to the latest version of the file in the repository, and looks something like $HeadURL: http://svn.collab.net/repos/trunk/README $. It may be abbreviated as URL.
Id
This keyword is a compressed combination of the other keywords. Its substitution looks something like $Id: calc.c 148 2002-07-28 21:30:43Z sally $, and is interpreted to mean that the file calc.c was last changed in revision 148 on the evening of July 28, 2002 by the user sally.
as in $keywordName$.
Have fun!
UPDATE on march/2009
Normally it would be necessary to set the properties on every single file of your system so the replacement of these props would happen. However, there is an easier way to do this, which is set the auto-props property in your environment.
In folder "C:\Documents and Settings\[your_username]\Application Data\Subversion" you will find a file named config (with no extension). In this file there should be a property "enable-auto-props" commented out. Remove the comment from this line so it looks like this:
### for 'svn add' and 'svn import', it defaults to 'no'.
### Automatic properties are defined in the section 'auto-props'.
enable-auto-props = yes
Then, on the same file, find the section [auto-props] and add a line at the end. If you want the replacement to happen only in your java files, add this:
Sunday, March 11, 2007
SVN Keywords
Posted by
Daniel
@
5:19 PM
0
comments
Labels: Subversion, Tools, Versioning
Thursday, January 18, 2007
SVN as a service under Windows
Found this great article on how to run subversion as a service (check my other post on installing subversion (SVN)).
Basically it explains how to use the "sc" (Service Control) which is provided by Windows OS to crete a service to run the svnserve command. This should work on Windows NT, XP, 2000 and 2003 Server.
It should look like something like this:
sc create [name]
binpath= "c:\svn\bin\svnserve.exe --service [svn-args]"
displayname= "Subversion Repository"
depend= Tcpip
If you are not comfortable in doing this, you can always try running svnservice, which is a project from tigris intended to "offer a comfortable way to run svn server (svnserve.exe) as MS Windows service".
Posted by
Daniel
@
7:50 PM
0
comments
Labels: Subversion, Tools, Versioning
Sunday, January 7, 2007
Installing Subversion, a Version Control System
Having a Version Control System is almost mandatory for every developer because keeping track of the evolution of his code is highly desirable. Such a system allows the developer to have individually registered version of every file in his system, including source code, documentation, diagrams etc.
Subversion (AKA as SVN) is such a system. It is open source and is considered an evolution of CVS with new features and a new internal architecture which allows SVN to have significant changes and improvements when compared to CVS, such as directories versions, truly atomic commits etc.
After this brief introduction, let’s get to work. As I am using Windows as platform for development (flames expected here ;) this article will give you the steps on installing SVN on this platform. If you are using Windows there are 3 ways to get subversion on your system:
1. Get an installer from Collabnet site.
2. Get a zipped file with binaries from tigris.
3. Get the sources from the repository and compile them on your system.
I’ll stick to the first two situations, because you would normally need the third one only if you need the latest features on the system. The stable releases should be enough for most needs.
Using Collabnet’s installer
Collabnet is the company that designed and created subversion. Using this prepared installation file should be the easiest way to get subversion up and running on your windows box. It comes with the SVN server, a SVN command-line client and an apache server almost ready for running svn.
CollabNet provides a readme file with basic instructions on creating a repository, clearing the firewall to let SVN do his work etc. It is a good basic reference. So, simply download the file (version 1.4 as of the time of the writing) and follow instructions.
Using ZipFile Binaries
This installation option is a little bit more difficult than the one above but everyone should do fine. I will not cover apache installation on this article.
Step 1
First of all you should download the latest version of the server available from subversion project downloads page. As of the time of this writing it is version 1.4.2. You may choose to download the sources and compile them yourself or download the binaries created by contributors to the project, which though not maintained by the project team are normally reliable packages. Now scroll the downloads page down to find the binaries for SVN Server for Windows. When you are redirected to the page find the latest release (should be the last one in the list) and get the file which name looks more or less like this svn-win32-X.X.X.zip (the one I got was svn-win32-1.4.2.zip).
Step 2
Unzip the file somewhere on your hard disk where it would make sense to have the subversion binaries. We will call this folder the subversion home directory (%SVN_HOME%). For example, if you unziped the files for SVN version 1.4.2 under C:\Program Files folder, your %SVN_HOME% dir would be: C:\Program Files\svn-win32-1.4.2. On the %SVN_HOME%\bin folder you will find the executable files which you will use to maintain your server and repositories.
svn.exe - Subversion client
svnadmin.exe - Subversion repository administration
svndumpfilter.exe - Subversion dump fle filter
svnlook.exe - Subversion repository browser
svnserve.exe - Subversion Server
svnsync.exe - Subversion repository replicator
svnversion.exe - Subversion revision extractor
Step 3
Let’s create the repository. Add the %SVN_HOME%\bin folder to your path variable in Windows to make the binaries accessible from anywhere in your computer. Now, create a test repository folder somewhere on your system (let’s say c:\temp\svn-test-rep) and we will call it the %SVN_REP%.
Run the svnadmin command to create a repository called repos1. You will do that running the following command:
svnadmin create c:\temp\svn-test-rep\repos1
As a result you should have a folder called "repos1" under %SVN_REP% with the following content:
DIR --- conf
DIR --- dav
DIR --- db
------- format
DIR --- hooks
DIR --- locks
------- README.txt
Step 4
Now we should test the server. This is as simple as running the command below:
svnserve -d -r c:\temp\svn-test-rep
This will get the server up and running. The "-d" tells the server to run as a daemon and "-r" tells the repository name.
Remember to enable svnserve to run on your firewall if you have one (if you don’t, you should get one ;)).
Now open another command prompt (while the server is still running), go to your "temp" folder and checkout the repository you created on step 3. Checking out a repository means getting a local version (copy with a revision number) from every file present on your repository. You can do that by typing:
svn co svn://localhost/repos1
This command will ask the svn server running on localhost to get the latest revision of every file on repository called "repos1". The "co" in the command line stands for "checkout" and "svn://" specifies the protocol used to access the repository. If had apache installed and setup to run svn mods we could use http or https to access the repository.
Well, this pretty much tells you how to install a SVN server and create repositories for your code. Of course now you will get worried about issues like: who can access my files or how do I specify security constraints? This should be subject for another article, as well as svn GUI clients and apache server.
Posted by
Daniel
@
11:15 PM
0
comments
Labels: Subversion, Tools, Versioning