Export in Subversion with variable replacement

I am trying to setup deployment using subversion.

When I used CVS I used to have the revision number and date for the individual file included. This was useful when debugging code or fixing bugs in case a person had an old version of the file, it would be known.

With Subversion the repository number is universal across all files.

I would however like to be able to list the version number on a file for the revision when that file last changed, and also the date of that.

Is that somehow possible?

Thank you.
thepaddersAsked:
Who is Participating?
 
fernandonajeraCommented:
Welcome to Subversion!

I'll answer to your question in 2 parts.

-- FIRST PART:

You should read THE Subversion book: <http://svnbook.red-bean.com>.

Subversion lets have that number quite easy. You have these keywords (from <http://svnbook.red-bean.com/en/1.1/ch07s02.html#svn-ch-7-sect-2.3.4>):

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.

I personally prefer Id, as you have all the info there. But, if you want it in your way, you'll have to rewrite your header like this:

#############################
// Product Name : Name
// $LastChangedRevision$
// $LastChangedDate$
#############################

which replaces to:

#############################
// Product Name : Name
// $LastChangedRevision: 657 $
// $LastChangedDate: 2005-03-25 $
#############################


Y prefer this way:
#############################
// Product Name : Name
// $Id$
#############################

Which is replaced by:

' $Id: file.php 657 2005-03-25 14:23:04Z fernando $

AND please note, you should set the svn:keywords property of the file(s) to let subversion know that it should replace that keywords. You can do it via command line client svn.exe:

svn propset svn:keywords "LastChangedRevision LastChangedDate" file.txt

or you can use TortoiseSVN <http://tortoisesvn.tigris.org> to easyly change properties on files using right-click - Properties - Subversion tab.

For new files, if you configure subversion config file according to this, you'll get that property in every added file:

[miscellany]
enable-auto-props = yes

[auto-props]
*.php = svn:keywords="LastChangedRevision LastChangedDate"

More on this at <http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.2>

--- SECOND PART:

What you don't have so easy is the Product revision. Remember that keyword expansion is done when you update a file, and if you update a file now and it does not change in the future, and tomorrow you'll release a version, the keywords are expanded today with the repository number as of today, not tomorrow.

For what you want, you can use SubWCRev.exe from TortoiseSVN, a Windows GUI for subversion. That question is covered here: <http://subversion.tigris.org/faq.html#version-value-in-source>

If you plan to use SubWCRev, your header should be:

#############################
// Product Name : Name
// Product Revision : $WCREV$
// $LastChangedRevision$
// $LastChangedDate$
#############################

But you should explicitly call subwcrev.exe to replace that item -- you should do it the night before a release, and subwcrev does not replace the word in the source file, but creates a copy of the file with the word replaced. There are also more keywords that subwcrev changes. You can learn more on that (if you need to) in TortoiseSVN help (available when you download TortoiseSVN from <http://tortoisesvn.tigris.org>. After reading the documentation, you can write to the users list about this or other matters about TortoiseSVN / SubWCRev.

Good luck!
0
 
Shane Russell2nd Line Desktop SupportCommented:
You are basically trying to get the Date Last Modified of each file in a directory ? Or can you please explain what you mean, with regards to doing it, it is probably possible through using the FSO :

www.juicystudio.com

That has plent of info on the FSO :)

Once I know exactly what you are trying to do I can make a working example of what you are attempting to do provided it is something I am able to do , obviously LOL.

I will give it my best shot :)
0
 
thepaddersAuthor Commented:
I use  subversion to manage PHP Files, at the top of each file I want something like this:

#############################
// Product Name : Name
// Product Revision : 1545 (ie the subversion revision)
// Last Change Revision : 1245 (the revision when this file last changed)
// Last Change Revision Date : 12/04/2005 (date this file last changed, ie date of 1245)
############################
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
thepaddersAuthor Commented:
Thank you very much!!!!

I got keyword expansion working perfectly now, thank you. I use linux for building so I think I will do that manually, do it in the same way as SubWCRev but just directly on linux.

Thanks again, all that info helped so much!
0
 
thepaddersAuthor Commented:
Is there anyway of getting the filename from the id but not the full path to that id? Ie so I can just get text.txt ?
0
 
fernandonajeraCommented:
You're welcome!

At least in Windows, if you use $Id$ it won't give you full path but not path. A quick test, my repo is at G:\testrepo so path is a/b/text.txt:

$Id: text.txt 1 2005-04-27 13:49:05Z fer $
$LastChangedRevision: 1 $
$LastChangedDate: 2005-04-27 15:49:05 +0200 (Wed, 27 Apr 2005) $
$LastChangedBy: fer $
$HeadURL: file:///g:/testrepo/a/b/text.txt $

If it doesn't help, you can write to users_at_subversion.tigris.org or join to the IRC channel. More info at <http://subversion.tigris.org/>.

Good luck!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.