Hi,
You can get the current revision number of a checkout using, on the command line, "svn info
".
For instance :
$ svn info
Chemin : .
URL : http://.../trunk
Racine du dépôt : http://...
UUID du dépôt : 128b9c1a-...-612a326c9977
Révision : 185
Type de nœud : répertoire
Tâche programmée : normale
Auteur de la dernière modification : ...
Révision de la dernière modification : 185
Date de la dernière modification: 2009-09-28 20:12:29 +0200 (lun. 28 sept. 2009)
Note it's localized ; if you're on Linux, you could try using :
$ LANG=en svn info
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LANG is en
svn: warning: please check that your locale name is correct
Path: .
URL: http://.../trunk
Repository Root: http://...
Repository UUID: 128b9c1a-...-612a326c9977
Revision: 185
Node Kind: directory
Schedule: normal
Last Changed Author: mzeis
Last Changed Rev: 185
Last Changed Date: 2009-09-28 20:12:29 +0200 (Mon, 28 Sep 2009)
If using this from PHP, though, getting it as XML might be more helpful (easier to parse, and not locale-aware) :
$ svn info --xml
<?xml version="1.0"?>
<info>
<entry
kind="dir"
path="."
revision="185">
<url>http://.../trunk</url>
<repository>
<root>http://...</root>
<uuid>128b9c1a-...-612a326c9977</uuid>
</repository>
<wc-info>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="185">
<author>...</author>
<date>2009-09-28T18:12:29.130307Z</date>
</commit>
</entry>
</info>
Just use simplexml_load_string
on that, and fetch the revision
attribute of the entry
tag.
Note that I would not do that on each page view : not quite as fast as one would hope for your application.
Instead, I would get that revision number when creating the archive I will, later, send to the production server -- and store it in some kind of configuration file.
This way, you don't need to use the svn
command on your production server, and you don't need to do your checkout on that server either.