tags:

views:

235

answers:

2

My problem is: I wan't to display in file "A" the latest revision number of file "B".

Subversion has a featured called "Keyword Substitution". It is used the replace keywords in the file content by the actual value when you commit it.

But is it possible to add a keyword in a file that it will be substituted by a value related to other file? If not, what is the solution to my original problem state above?

I guess Jeff Atwood does it, right here in StackOverflow site. If I remember well, he even commented about it in a previous podcast.

<script type="text/javascript" src="/content/js/master.js?v=3067"></script>

"v=3067" seems to be the lastest revision number of "master.js". Jeff, can you give me a hand? :)

+1  A: 

I recently asked some similar questions -

The short answer is that with SVN, you can't do this.

You're only real option is to implement a build time solution to make the substitution(s), e.g. with make or Ant (whatever you're using).

Richard Nichols
+1  A: 

Well, that number can be one of two things:

  1. The revision number of HEAD of the repository of the site
  2. The revision number of the last change to that particular file

In either case, it serves a specific purpose, to make sure that when a user gets a web page with a reference to a CSS or javascript file, with such a version number, if the version number has changed since the last time the user visited the same page, the web browser will disregard its local cache for that file, and redownload it.

Unless you want to pin that reference to an older, working, version, I'd say that you could just update it with the HEAD revision number. That would be "safe" in the sense that it would give you what you want, but might waste bandwidth since it will force a redownload of a file that may or may not have changed.

If you really need the revision number of that other file, for that link, then I would say that you should roll your own solution with a small program, a custom keyword system, and parsing the log file.

For instance, you could do this:

rc="/content/js/master.js?v=#Rev(master.js)#"

and have a regex that looks for this:

#Rev\((?<filename>[^)])\)#

and then you would have to read the log file from Subversion, you can output this with XML .

Lasse V. Karlsen