How To Properly Set SVN svn:externals Property In SVN Command Line
| Share |
Updated: October 6th, 2009
Introduction
Every time I have to deal with svn:externals in SVN, I forget the command line syntax. Every single damn time. Normally, I use SVN GUI clients, such as SmartSVN, which make it very simple to add an svn:externals property. But for command line, it always takes looking at 25 different sites on google, which are all incredibly unhelpful for this question for some reason. Trying "svn help propset" on the command line was bloated and equally useless.
So this time I needed to write it down and make sure everyone who needed help with svn:externals would find exactly what they need here. I hope this page will soon come up on top of all the unhelpful results on google for "propset svn:externals" and other related queries.
The Problem
I want to set a simple svn:externals property in one of my project's directories, lets say 'plugins' (talking about WordPress here). The outcome would be a directory called 'akismet' within 'plugins' that points to a remote svn url.
Various combinations of trying to do it produced pathetic results, like
svn propset svn:externals akismet http://plugins.svn.wordpress.org/akismet/trunk svn: Setting property on non-local target 'http://plugins.svn.wordpress.org/akismet/trunk' needs a base revision
svn propset svn:externals . akismet http://plugins.svn.wordpress.org/akismet/trunk svn: Error parsing svn:externals property on 'akismet': '.'
svn propset svn:externals akismet http://plugins.svn.wordpress.org/akismet/trunk akismet svn: Setting property on non-local target 'http://plugins.svn.wordpress.org/akismet/trunk' needs a base revision
The Solution
Finally, thanks to this post, I found the right command:
svn propset svn:externals 'akismet http://plugins.svn.wordpress.org/akismet/trunk' . property 'svn:externals' set on '.'
Note that dot at the end of the command and the quotes around the directory name and url.
Now commit via
svn commit
and then
svn up Fetching external item into 'akismet' A akismet/akismet.gif A akismet/akismet.php A akismet/readme.txt Updated external to revision 127962. Updated to revision 16.
There, was it that hard, forum gurus and blog fiends?
Edit: in order to set multiple directory/url pairs in a single svn:externals property, you should put the individual dir/url pairs into a file (let's call it 'svn.externals'), like so
akismet http://svn.wp-plugins.org/akismet/trunk all-in-one-seo-pack http://svn.wp-plugins.org/all-in-one-seo-pack/trunk
and then apply the property using
svn propset svn:externals -F svn.externals .
You should also just check in 'svn.externals' to easily keep track of it.
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.
Also you can't set property if you don't have a local working copy. If folder is tooo big to checkout completely you can run this command:
svn co svn://branck/blah -N
So easy, but I also spend lot of time figuring this out. Hope, this helps.
If you have your SVN_EDITOR set in your .bash_profile (i.e. export SVN_EDITOR=/usr/bin/vi), you can do this a lot easier with this command (run from inside the dir you want to create the external link in):
svn pe svn:externals .
This will open up your editor, and allow you to easily manage the "foldername http://repos/path" entries from a much nicer interface.
I use svn:externals so much I set up a bash alias that shortens the command even further to just: svnext
In fact, I've got a whole library of little svn shortcuts set up as aliases in .bash_profile that make working with svn on the command line easier and more powerful than any GUI.
I dont know all Eric's tricks but I really like the what you can do with these techniques. Its a huge huge huuuuuge labor saver.
I worked out the process for pulling WordPress core and plugins and themes in one script.
http://www.superwebdeveloper.com/2009/11/07/installation-script-using-wordpress-subversion-repositories/
Also, every page says "you can even specify a specific revision", but few actually give an example of the syntax for referencing a specific revision.
Augmenting the example above you do it like this:
svn propset svn:externals 'akismet -r 22 http://plugins.svn.wordpress.org/akismet/trunk' .
Notice the "-r 22" where 22 is the desired revision number.
Hey, thanks this helped out quite a bit I ended up doing it slightly differently but got it working which is the main point.
Regards
How can I commit different externals on their own repo?
Thanks
Diego, I believe this is impossible. See this post on StackOverflow for details. In short, you can try to use Eclipse's commit which handles this automatically.
Thanks Artem!
Am creating an install routine for WordPress builds, loading public and private plugins and themes. Perfect.
*love* <– this is all I wanted to say, really, for you saving my ass on an increasingly frustrated "gaah" moment of trying to propset the svn:externals deal, but I got a "comment too short" whine at me. Bah
Glad I could help :-]
thank you very much. svn sucks. git ftw!
Thanks Russakovskii.
I had the same problem.
I was used to command line and then forced to use SmartSVN because this trouble, that is not covered on svn redbook. It's a pity that properties on svn is so documentation missed.
Thanks for the post. Saved me eons, I'm sure.
I use a slightly different version. It let's you edit multiple externals via your editor of choice (ie. Vi)
Assume you have an externals folder called 'ext'
cd into that directory and then you can run 'svn propedit svn:externals .'
That will allow you to edit all externals defined in that directory through your editor.
That's a helpful tip, Eric. But just in case someone wants to directly use 1 command, my recent blog post would help http://www.buggedtech.com/2011/01/25/multiple-values-on-svnexternals/
Thanks for the post, worked great !
We use it for having a main docs directory (http://mobicents.googlecode.com/svn/trunk/docs/) on Mobicents (http://www.mobicents.org/) which gather the docs from multiple subprojects that the main content authoring person can checkout without checking out the full SVN
Hi,
I am a SUBVERSION NEWBIE and I had a requirement in which we need to force each and every user to enter comment in a specified format like
BUG ID:
REV NO:
…like. And Clearly I am dumb about how to start. Looking for your valuable help on this.
Thank you,
Srikanth
Hi there Srikanth. You need to know scripting like bash or perl. You can do what you want via the hook scripts. In your repository hooks directory (say /var/repo/svnrepo01/hooks), you can look at pre-commit.tpl to start with.
I'm sorry I cannot spoon-feed you with everything but if you know scripting, that's all that you need to start from.
Good Luck!
Ismael Casimpan
It's worth pointing out here when using the svn client commands under the Windows environment the single quotes need to be replaced for double quotes or you will get the following svn error:
svn: Cannot specify revision for setting versioned property 'svn:externals'
Thank you! The documentation on this is pretty lame. Took a few minutes of Google searching to figure out my mistake.
Thanks! I've done this so many times before, but when I needed to do it again, I forgot!
The format changed sometime during or before SVN version 1.6. The TortoiseSVN client had a tooltip showing that the format is now:
URL directory-name
not:
directory-name URL
Thanks!!! You save my day!
Thanks for the info! This was very helpful. However, I noticed a small issue: I tried this with SVN 1.6.6 and after I issue the propset command, I tried to do the commit but it complained that the directory was out of date. I had to do svn up *before* doing svn commit in order for it to work.
Awesome stuff bro.
Externals seems like a good option when I'm in a non-Java environment (which is pretty often) and lack a tool like Maven – very handy.
My svn, version 1.6.6 has the externals parameters in the reverse order.
For my system, your command would be
svn propset svn:externals 'http://plugins.svn.wordpress.org/akismet/trunk akismet'
Thanks, very useful!