Fix svn:externals cached in working copy

The goal was to change an external reference and make it a part of the repository.  So from this:

\-foo -> external: https://....

To this:

\-foo (included in repo directly)

The procedure for this would be:

  1. Removing the externals reference
    repo$ svn pd svn:externals .
  2. Adding the content
    svn add foo
  3. And committing it
    svn ci -m 'Include foo in repo instead of external reference'

However there’s actually an additional step needed after step 1: committing the removal of the externals definition. Otherwise the working copy can get corrupted. I managed to get the working copy in a reasonable state except the foo directory was still recognised as an external.

As it turns out the list of externals in a working copy is stored in .svn/wc.db. Since the update around the removal of the externals reference failed halfway the entries from this database were not removed. Luckily it’s a standard, sqlite database so using the sqlite3 tool it’s possible to remove entries from the EXTERNALS table.

repo$ sqlite3 .svn/wc.db
SQLite version 3.8.2 2013-12-06 14:53:30
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .tables
sqlite> select * from EXTERNALS;
sqlite> delete from externals where local_relpath = 'foo';
sqlite> .quit

So far it seems that it didn’t do any damage.
Of course if the working copy is small and clean then checking it out might be a simpler and faster solution. In my case it was a 20G working copy so I was trying to find a way around it.

Change main domain of wordpress site

Ideally you should be able to do this in the WP admin however you might have trouble logging in even as the site is trying to force the set domain. So in this case it might be easier to fix the db:

UPDATE wp_posts SET
 guid = REPLACE(guid, '', ''),
 post_content = REPLACE(post_content, '', '')
UPDATE wp_options SET
 option_value = REPLACE(option_value, '', '')

Note thought that some plugins – the ones with integrations to external services – might need to be repaired but normally that should be no problem.