Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the last revision number in SVN?

Tags:

svn

Using PHP, Perl, or Python (preferably PHP), I need a way to query an SVN database and find out the last revision number sent to SVN. I don't need anything other than that. It needs to be non-intensive (so I do it every 5 minutes as a cron job; SVN's performance should not be affected).

SVN is located on my Intranet, but not my specific computer.

I have SVN installed, but no bindings installed for PHP/Perl/Python. I'm running Windows XP, but I would prefer a platform-independent solution that can also work in Linux. If you have a Linux-only (or XP-only) solution, that would also be helpful.

like image 453
Coltin Avatar asked Feb 23 '09 20:02

Coltin


People also ask

How can I get previous revision from svn?

On the file, simply right-click => Team => Switch to another branch/tag/revision. Besides the revision field, you click select, and you'll see all the versions of that file.

How Do I Get latest in svn?

Simply type svn update [name-of-directory] , or cd to that directory and type svn update there.

What is svn revision?

Subversion, with the command line tool svn, is a revision control system, also known as a source code management system (scm) or a source code control system (sccs). The subversion server maintains a repository, where files are stored in a hierarchy of folders, same as a traditional file system.

What is the head revision in svn?

The HEAD revision refers to the most current revision in a repository. If you are browsing the HEAD revision of your repository and one of your teammates commits a change, those new changes will be included when you decide to check out a working copy of that revision or fetch specific information about it.


2 Answers

If you want to analyse a local working copy, the best tool is svnversion, which comes with Subversion and produces output like 968:1000M. The documentation says:

The version number will be a single number if the working copy is single revision, unmodified, not switched and with an URL that matches the TRAIL_URL argument. If the working copy is unusual the version number will be more complex:

4123:4168     mixed revision working copy 4168M         modified working copy 4123S         switched working copy 4123:4168MS   mixed revision, modified, switched working copy 
like image 143
sth Avatar answered Oct 10 '22 17:10

sth


<?php     $url = 'your repository here';     $output = `svn info $url`;     echo "<pre>$output</pre>"; ?> 

You can get the output in XML like so:

$output = `svn info $url --xml`; 

If there is an error then the output will be directed to stderr. To capture stderr in your output use thusly:

$output = `svn info $url 2>&1`; 
like image 36
Daniel X Moore Avatar answered Oct 10 '22 15:10

Daniel X Moore