In Subversion 1.6, there was an .svn
directory in every working copy directory. I could use the following code to quickly retrive the current revision number without the need for shell access/execution.
public function getSubversionRevision() {
if(file_exists("../.svn/entries")) {
$svn = File("../.svn/entries");
return (int)$svn[3];
}
return false;
}
Subversion 1.7 breaks this code. There is now only one .svn
directory per local repository. There is an entries
file in this directory but it no longer has anything useful for me. It looks like everything I need is now in a SQLite database. Specifically wc.db
. I suppose I could use PHP's SQLite functions to get the info I need, but this sounds a little too expensive to run on every (or close to every) page load.
Any ideas? Breaking out the exec
function and hoping that Subversion binaries are installed (and in the $PATH!) is a last resort. To summarize, I need to find a way to locate the .svn
directory at the root of the repository (which could be different depending on your checkout location) and then somehow parse a file in there (probably wc.db
) in a cost-effective way.