You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Philippe Legay <pl...@acial.fr> on 2007/04/01 21:16:23 UTC

Tag and substitution

Hello,

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 ? 

Thanks for any pointer.

PHL.

Re: Tag and substitution

Posted by Ryan Schmidt <su...@ryandesign.com>.
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