5 svnpath - output svn url with support for tags and branches
19 svnpath is intended to be run in a subversion working copy.
21 In its simplest usage, svnpath with no parameters outputs the svn url for
22 the repository associated with the working copy.
24 If a parameter is given, svnpath attempts to instead output the url that
25 would be used for the tags, branches, or trunk. This will only work if it's
26 run in the top-level directory that is subject to tagging or branching.
28 For example, if you want to tag what's checked into subversion as version
29 1.0, you could use a command like this:
31 svn cp $(svnpath) $(svnpath tags)/1.0
33 That's much easier than using svn info to look up the repository url and
34 manually modifying it to derive the url to use for the tag, and typing in
37 svn cp svn+ssh://my.server.example/svn/project/trunk svn+ssh://my.server.example/svn/project/tags/1.0
39 svnpath uses a simple heuristic to convert between the trunk, tags, and
40 branches paths. It replaces the first occurrence of "trunk", "tags", or
41 "branches" with the name of what you're looking for. This will work ok for
42 most typical subversion repository layouts.
44 If you have an atypical layout and it does not work, you can add a
45 ~/.svnpath file. This file is perl code, which can modify the path in $url.
46 For example, the author uses this file:
49 # svnpath personal override file
51 # For d-i I sometimes work from a full d-i tree branch. Remove that from
52 # the path to get regular tags or branches directories.
53 $url=~s!d-i/(rc|beta)[0-9]+/!!;
65 chdir $path || die "$path: unreadable\n";
70 # Get the svn url of the current directory.
71 $url = `svn info .| grep -i ^URL: | cut -d ' ' -f 2`;
75 $url = `svk info .| grep -i '^Depot Path:' | cut -d ' ' -f 3`;
83 # Now jut substitute into it.
84 $url=~s!/(?:trunk|branches|tags)($|/)!/$wanted$1!;
86 if (-e "$ENV{HOME}/.svnpath") {
87 require "$ENV{HOME}/.svnpath";
95 GPL version 2 or later
99 Joey Hess <joey@kitenet.net>