Reserved Keywords
HEAD, BASE, PREV, and COMMITTED are, to paraphrase from the Collins-Sussman SVN book, "reserved revision entities" (i.e., reserved keywords that help quickly and easily identify certain versions).
- HEAD indicates the LATEST revision of the repository as in the following examples:
$/opt/svn-1.4.3/bin/svn log -r HEAD file:///opt/samagdocs r48 | ram | 2007-05-02 08:25:06 +0530 (Wed, 02 May 2007) | 1 line update number three $/opt/svn-1.4.3/bin/svn log -r HEAD /home/ram/svnarticle_rndtwo r48 | ram | 2007-05-02 08:25:06 +0530 (Wed, 02 May 2007) | 1 line update number three
- BASE indicates the revision of the working copy and works only on the working copy, not on the repository:
$/opt/svn-1.4.3/bin/svn log -r BASE file:///opt/samagdocs svn: 'file:///opt' is not a working copy svn: Can't open file 'file:///opt/.svn/entries': No such file or directory $/opt/svn-1.4.3/bin/svn log -r BASE /home/ram/svnarticle_rndtwo r48 | ram | 2007-05-02 08:25:06 +0530 (Wed, 02 May 2007) | 1 line update number three
- COMMITTED is the most recent revision of an item in the working copy:
$/opt/svn-1.4.3/bin/svn log -r COMMITTED /home/ram/svnarticle_rndtwo/svnarticle_serone r49 | ram | 2007-05-04 06:07:53 +0530 (Fri, 04 May 2007) | 1 line updated four on reserved keywords
- PREV is revision of an item in the working copy, which is equivalent to COMMITTED less one:
$/opt/svn-1.4.3/bin/svn log -r PREV /home/ram/svnarticle_rndtwo/svnarticle_serone r48 | ram | 2007-05-02 08:25:06 +0530 (Wed, 02 May 2007) | 1 line update number three
In addition to these reserved revision keywords, SVN also allows "dates" as revision keywords that can be passed as values to the "--revision" or "-r" switch. Dates with spaces between them should be separated by quotes.
Note: The SVN command that contains date keywords without reference to the actual time of the day outputs the most recent revision of the repository as of that date.
The use of "real dates" as keywords is shown below. The command shown extracts the log of the working copy, with its revision as of January 1, 2007:
$/opt/svn-1.4.3/bin/svn log -r {2007-01-01} /home/ram/svnarticle_rndtwo r9 | ram | 2006-12-26 00:23:34 +0530 (Tue, 26 Dec 2006) | 1 line svnserve updated screenshots
Managing Parallel Development
Provision of branches, in any version control infrastructure, raises the temptations of the developers to branch everything. This style of working indirectly brings along with it divergence from the stable base; if not handled properly, it may result in conditions where returning (or "re-basing") to the stable base can be a complex effort.
This task of re-basing the code is made possible by SVN's merge utility. The SVN merge compares two repository trees and applies the differences to the local directory that belongs to the working copy.
Arguments to the SVN merge command are:
- Initial repo tree
- Destination repo tree
- Working copy, where the differences between the trees shall be applied
Without performing the actual merge, it is possible to know what may happen if the actual merge were run, with the preview option, "--dry-run". With the help of actual examples, involving two branches (actually, one is a tag), I will explain what is happening under the hood.