I haven’t posted in a while, been very busy with projects. But here’s a very useful little shell function for getting the URL of a path within a subversion working directory:
function -url { info $1 > /dev/null ERROR=$? if [ $ERROR -ne 0 ]; then return $ERROR fi info $1 | grep ‘URL: ’ | sed ‘s/URL: //’ }
Put the code into your shell rc file. You could use this function with back ticks like so:
co `-url /path/to/some/working/directory`
- Update: Removed smart quotes.
- Update: Add Daniel Jalkut’s change to the sed statement.
- Update: With the Subversion 1.3 update you can use the –xml switch to output XML that you can then process with xsltproc from the command line:
Save this XSLT file into a well known location (I saved mine into ~/Library/Application Support/Subversion/-url.xslt):
<?xml version=’1.0′ encoding=’utf-8′?><stylesheet version=‘1.0’ xmlns=‘http://www.w3.org/1999/XSL/Transform’> <output method=‘text’/> <template match="/"> <apply-templates select="/info/entry/url"/> </template> <template match="/info/entry/url"><value-of select="."/><text> </text></template></stylesheet>Then use it like this:
function -url { info –xml $* | xsltproc "$HOME/Library/Application Support/Subversion/-url.xslt" - }
One big advantage over the previous script is that this new version allows you to use specify wildcards and multiple paths. Of course you’ll need 1.3 though.
