Switching an SVN directory to and from an ‘externals’ definition

There seems to be quite a few posts out there about how to replace Subversion externals definitions with local directories, but not so much for going the other way. I’m not sure why; it seems to me more likely that one would start off with some small module as part of a bigger repository, and then at a later date want to move it out to live on its own. I don’t really know what I’m on about, though.

The point being, that I’m working with a branch of a project that is having a few of its directories — its current, local, ‘normal’ directories — replaced by externals definitions. That’s all fine and good, but I keep having to switch to trunk and back again, and there’s the crux: the directories that are getting turned into externals do not like being switched.

Running the usual svn sw http://svn.example.com/repo/branches/v2 from the top level of a trunk checkout gives the following error:

Fetching external item into 'lib/foo':
svn: warning: W155037: Previous operation has not finished; run 'cleanup' if it was interrupted

Running svn cleanup complains with:

svn: E155010: The node '/path-to-repo/lib/foo/file.txt' is not installable

And not even status has anything useful to say (throwing instead the same error as above).

A solution (and yes, this post is probably a bit long-winded for such a short snippet of advice; I can only say that I felt like writing this down this morning because four weeks ago I figured it out but forgot and I suspect that four weeks hence I’ll have forgotten again, and this morning is one of those moments of verbosity; blame Travels with Charley, which I was reading over breakfast this morning), and it’s probably not the ‘proper’ solution because I’m no Subversion hacker and do rather treat it as magic, but the solution that I use is (and I’d better put it on it’s own line, because no one’s likely to have read to the end of this paragraph)…

Delete the offending directory (as in, rm -r lib/foo or what have you), and update again.

That’s all.