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.


  • Share/Bookmark

15 Responses to “How To Properly Set SVN svn:externals Property In SVN Command Line”

    13 Comments:
  1. grundic says:

    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.

  2. Eric Marden says:

    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.

  3. pbgswd says:

    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/

  4. JustAnotherDude says:

    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.

  5. Gareth says:

    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

  6. Diego says:

    How can I commit different externals on their own repo?
    Thanks

  7. GRAQ says:

    Thanks Artem!

    Am creating an install routine for WordPress builds, loading public and private plugins and themes. Perfect.

  8. Kalle says:

    *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 :)

  9. john random hacker says:

    thank you very much. svn sucks. git ftw!

  10. cheapshot says:

    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.

  11. Timothy Nott says:

    Thanks for the post. Saved me eons, I'm sure.

  12. 2 Pings:
  13. [...] Originally posted here: How To Properly Set SVN svn:externals Property In SVN Command Line … [...]

  14. [...] or even specific revisionsif you want the bias more to stability over new features. You can also specify multiple remote repositories by creating a text file with directory and remote resource pai…s and point svn propset at that file. Be prepared to handle things that you flub up using svn [...]

Leave a Reply