Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Export in Subversion with variable replacement

Posted on 2005-04-12
6
Medium Priority
?
271 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:thepadders
  • 3
  • 2
6 Comments
 
LVL 23

Expert Comment

by:gecko_au2003
ID: 13765091
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
 

Author Comment

by:thepadders
ID: 13765200
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
 
LVL 4

Accepted Solution

by:
fernandonajera earned 2000 total points
ID: 13867425
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:thepadders
ID: 13871106
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
 

Author Comment

by:thepadders
ID: 13871198
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
 
LVL 4

Expert Comment

by:fernandonajera
ID: 13876036
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Introduction to Processes

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question