14

I've recently updated Subversion repositories from an old 1.2.3 version to 1.6.0 via svnadmin dump/load. The old repositories all used the same UUID (repositories were created using by copying a template repository). I've changed the UUID on a couple of the new repositories via svnadmin setuuid to be unique. I can't just relocate my existing working copies of those repositories because the UUIDs are different. I know about exporting the working copy and checking out from the new repository, but I was wondering whether there was a way to just change the UUID of the working copy in-place, like what svnadmin setuuid does for repositories.

5 Answers 5

3

You need to edit all the 'entries' files in your pulled repo. If the repo has a lot of directories, find + a sed script will make short work of the task.

19

New answer since Subversion 1.7 working copy format. You need sqlite3 command line utility.

In the root directory of your working copy, there is now a single .svn/ folder with a SQLite database. You can query current repository UUID known for your working copy with:

$ sqlite3 .svn/wc.db 'select uuid from REPOSITORY where id=1'
b6dc3e6c-5320-4549-b231-c153d86d7525

As a result, changing UUID can be done with:

$ sqlite3 .svn/wc.db 'update REPOSITORY set uuid="1c0d1ec1-2326-0410-bef5-eb29cddfc032" where id=1'

Of course, keep a backup of the .svn/wc.db file before invoking update query. There is almost no chance that your repository entity has different id or there are multiple lines in that table but you may check if you get unexpected results.

1
  • +1 worked perfectly with a relocated repo that also changed UUID
    – Amro
    Aug 31, 2013 at 11:06
8

Here is a command that does the trick for SVN 1.6 and below:

find . -type f -name entries -exec sed -i 's/old-uuid/new-uuid/g' {} \;

Replace old-uuid and new-uuid with the actual ids.

2
  • 1
    +1Thanks for the solution. This is not working for directories having spaces. "find . -type f -name entries -exec sed -i 's/old-uuid/new-uuid/g' {} \;" without double quotes seems working.
    – Tommy
    Oct 26, 2011 at 10:32
  • sry for necroing this thread this method just saved me a bunch of time.. for others trying this out, just want to add a note. Sed on MACOX seems to need a slightly different usage, u need to say sed -i "" 's/old-uuid/new-uuid/' and it works (just the extra empty double quotes) (ref)
    – Karthik T
    Oct 4, 2012 at 3:36
3

Yves Martin's answer worked great for us on a number of working copies with SVN 1.8, but we did end up running into cases where it didn't work.

Running Yves' command without "where id=1" worked in all cases for us:

$ sqlite3 .svn/wc.db 'update REPOSITORY set uuid="1c0d1ec1-2326-0410-bef5-eb29cddfc032"'

Investigating why this happened, I found out that multiple UUIDs are stored when relocating the repository, contrary to Yves' intuition that this should never happen.

A new entry into the REPOSITORY table is added after a relocate rather than updating the existing one, storing an incremented id with the new repository root and its UUID. So the cases that failed to work properly were the working copies that had already been relocated in the past: The command would appear to work, but only the initial UUID was changed, not the one currently being used.

One can check the list of stored roots and UUIDs in a working copy with this command:

$ sqlite3 .svn/wc.db 'select id,uuid,root from REPOSITORY'

I'll finally note that I had to use a different set of quotes for Windows command line / batch files, as follows:

> sqlite3.exe .svn\wc.db "update REPOSITORY set uuid='1c0d1ec1-2326-0410-bef5-eb29cddfc032'"
1
  • Thanks for details when a working copy has been relocated, I was not aware of this behaviour Sep 19, 2016 at 9:53
1

The section "Managing Repository UUIDs" in svn red-bean book may have the answer you are looking for.

4
  • That section talks about repository UUIDs, not working copy UUIDs.
    – Ioan
    Jan 6, 2011 at 21:30
  • @Ioan: Quoting from that section: For folks using versions of Subversion earlier than 1.5, these tasks are a little more complicated. You can explicitly set a repository's UUID by piping a repository dump file stub that carries the new UUID specification through svnadmin load --force-uuid REPOS-PATH - Isn't this what you needed?
    – yasouser
    Jan 6, 2011 at 21:31
  • 1
    Again, no, I'm not talking about repository UUIDs, but rather working copy UUIDs; working copies are the same as a checkout.
    – Ioan
    Jan 7, 2011 at 13:00
  • You cannot change the working copy UUID to that of the server repo without updating or svn switch-ing the working copy to the [new/existing] location of the repo.
    – yasouser
    Jan 7, 2011 at 13:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .