Introduction:Now that
Subversion 1.6.1 is out, improving and
fixing a few things in Subversion 1.6, it is time for us to review some of the most important features provided by this new release. Because a few of the new features of Subversion 1.6 remain undocumented and because the latest version of the
Subversion book does not yet cover Subversion 1.6, I do hope you might find helpful information in these reviews.
We will start today with the relative urls feature.
Relative urls and the svn:external property:Subversion 1.5 introduces some relative URLs shortcuts available in the
svn:external property.
Because a server URL tends to change more often than the structure of a Subversion repository, in the svn:externals property, you no longer need to write the full URL to each source directory.
The syntax for each these shortcuts is:
- '../'
URL of the parent directory on which the svn:externals
property is set.
EG:
url: http://my.svn.domain.com/a/long/path/to/repo/and/to/my/property,
shortcut '../' points to http://my.svn.domain.com/a/long/path/to/repo/and/to/my
shortcut '../../' points to http://my.svn.domain.com/a/long/path/to/repo/and/to/
- '^/'
URL of the root of the repository in which the svn:externals property is set.
EG:
given the same url,
shortcut '^/' points to http://my.svn.domain.com/a/long/path/to/repo - '/'
URL of the Server which hosts the repository in which the svn:externals property is set.
EG:
given the same URL,
shortcut '/' points to http://my.svn.domain.com - '//'
Relative to protocol of server URL
EG:
given the same URL,
shortcut '//' points to http://
Because it has already been covered, please refer to the Subversion book for more information about the relative url shortcuts in the svn:ex
Repository root relative urls from the command line:
Although the support for relative urls in the svn:externals property is already a nice addition, the subversion development team went one step further by providing the
repository root relative urls feature with the command line client of Subversion 1.6
.
The syntax for each these shortcuts is:
- '^/'
URL of the root of the repository. - '/'
URL of the Server which hosts the repository - '//'
Relative to protocol of server URL
For example, creating a simple tag prior to 1.6 you write:
svn copy http://svn.domain.com/repo/trunk \
http://svn.domain.com/repo/tags/release-1.0 \
-m "Tagging for release 1.0"
Using the relative root URL in Subversion 1.6, it is much simpler:
svn copy ^/trunk ^/tags/release-1.0 -m "Tagging for release 1.0"
The repository root relative syntax is '
^/', not '
^'. So use '
^/' to refer to the root of the repository. URLs that begin with a '
^' are reserved for future extension. Also '
../' is a shortcut only available in the svn:externals property definition. It is possible to use it with the command line client.
The benefits of the relative root URL feature are:
- Type less
- Less typo error in the URL
- Ease automation
- Easier to move your repository from host to anotherr.
How does the magic works, you ask?
The client start to look for any non relative URLs in the paramters list. If these non relative URLs are all identical, the client replace all relative URLs in the parameters list with the root URL of the non relative one. If they are no non relative URLs in the parameters list, the client uses repository root URL for the current working copy. If the current folder is not a current working copy, the client reports an error. The same goes in every other situations.
An example you ask?
The working copy is located in $WC. It currently is a checkout from the trunk of your project located in http://some.domain.com/svn/repo
- svn copy http://some.domain.com/svn/repo/trunk ^/tags/release-1.0 -m "..."
http://some/domain.com/svn/repo/ is used to replace ^/ - svn copy ^/trunk ^/tags/release-1.1 -m "..."
The above command fails provided it is started outside of a working copy
- cd $WC ; svn copy ^/trunk ^/tags/release-1.1 -m "..."
http://some/domain.com/svn/repo/ is used to replace ^/ - svn switch ^/tags/release-1.0
successfully switch your working copy to http://some.domain.com/svn/repo/tags/release-1.0
source:
cli-repo-root-relative-support.txt