| Share |
Updated: July 26th, 2010
This is a quick recipe that I found pretty interesting and relatively unknown.
Everyone who uses SVN knows that most repositories are set up to allow viewing of their contents via a web browser. For example, here's the trunk of WP Plugins SVN: http://plugins.svn.wordpress.org/ and here is the current trunk version of a specific file, let's say http://plugins.svn.wordpress.org/stats/trunk/readme.txt.
The Problem
However, what if you wanted to view a specific revision of a file or directory in your browser?
Let's say I wanted revision 100,000 of http://plugins.svn.wordpress.org/stats/trunk/readme.txt
Normally, on a command line, you'd do something like
svn co http://plugins.svn.wordpress.org/stats/trunk/readme.txt stats cd stats; svn up -r100000 readme.txt
or simply
svn export -r100000 http://plugins.svn.wordpress.org/stats/trunk/readme.txt
However, how would you do this in your browser? Trying something like ?r=100000 or ?revision=100000 parameters doesn't work.
The Solution
Here is the syntax to get a specific revision of a file or directory:
- Take the root of the repository (in our case, http://plugins.svn.wordpress.org)
- Append this string !svn/bc/REVISION_NUMBER right after the repository root and before the directory or file path.
Going back to our example:
- http://plugins.svn.wordpress.org/!svn/bc/100000/stats/
shows the stats directory exactly as it was at revision 100,000 and
- http://plugins.svn.wordpress.org/!svn/bc/100000/stats/trunk/readme.txt
shows our readme.txt at 100,000.
And that's how you do it, folks. Happy revisioning!
Update: this post is now sponsored by Wirefly Learn where you can find cell phone news and reviews, as well as comparisons and videos.
Artem Russakovskii is a San Francisco programmer, blogger, and future millionaire (that last part is in the works). Follow Artem on Twitter (@ArtemR) or subscribe to the RSS feed.
In the meantime, if you found this article useful, feel free to buy me a cup of coffee below.
beer planet is a blog about technology, programming, computers, and geek life. It is run by Artem Russakovskii - a local San Francisco geek who is currently pursuing his own projects and regularly enjoys hacking Android, PHP, CSS, Javascript, AJAX, Perl, and regular expressions, working on Wordpress plugins and tools, tweaking MySQL queries and server settings, administering Linux machines, blogging, learning new things, and other geeky stuff.
Tnks! It's really helpful!
Interesting, but a think that creating a wiki like trac is probably more efficient if you want to do that.
Spyros,
yup, I agree, Trac is always nice but sometimes not available. This is the fastest way to direct link to files in this case.
The default mod_dav_svn doesn't support viewing older revisions. A third-party software like ViewVC or SVN::WEB should be installed in server prior to modifying URL on client machine.
Are there any other hidden features of web client?
Where may I learn them?