[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Tag and substitution

From: Ryan Schmidt <subversion-2007a_at_ryandesign.com>
Date: 2007-04-01 23:48:54 CEST

On Apr 1, 2007, at 16:16, Philippe Legay wrote:

> What is the easiest way to the "tag name" into my source file ? using
> substituion variable ?
>
> Description :
> For instance I put my code in tag space as Version-1 and as Version-2.
>
> Is it possible to have at the check-out time a substituion ?
> So in my code, I will have for instance String v = "Version-1" ; or
> String v =
> = "Version-2" ;
>
> Is it possible ? What is the easiest way tot do that ?

Here's an example of how to do it in PHP; I'm sure you can adapt it
to whatever programming language you're using:

<?php

$headurl = '$HeadURL: file:///tmp/repo/tags/1.2.3/index.php $';
if (preg_match('%/tags/([^/]+)%', $headurl, $matches)) {
        $version = $matches[1];
} else if (preg_match('%/trunk/%', $headurl)) {
        $version = 'trunk';
} else {
        $version = 'unknown';
}
unset($headurl);
echo 'Version: ' . $version . "\n";

?>

Be sure to set the svn:keywords of the file to include the value
HeadURL.

-- 
To reply to the mailing list, please use your mailer's Reply To All  
function
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Sun Apr 1 23:49:23 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.