svnsedsvnadminsvn-repository

Reordering subversion repository fails


I want to reorder a subversion repository; for this I use svnadmin dump, svnadmin load, svndumpfilter and sed.

For example, I want to "move" the following directory (in fact, it's much more but I do it step by step now):

project1/common/bib -> trunk/pub/common/bib

For this, I execute the following command on the exported dump file:

sed -i "s|Node-path: project1/common/bib|Node-path: trunk/pub/common/bib|g" repo.dump
sed -i "s|Node-copyfrom-path: project1/common/bib|Node-copyfrom-path: trunk/pub/common/bib|g" repo.dump

However, when I load this into a new/empty repository I get:

<<< Neue Transaktion basierend auf Originalrevision 64 gestartet
svnadmin: Datei nicht gefunden: Transaktion »63-1r«, Pfad »trunk/pub/common/bib«
 * Füge Pfad hinzu: trunk/pub/common/bib ...

I don't why this does not work since I replace stupidly every entry!


Solution

  • svnadmin dump will indeed produce a complete history of your "project1" repository.

    However, although possible, altering file paths within that history can be tricky. Your sed commands are good, but they might get the job done only 98%. To correctly change the history, you need to do some more searching and validation of the changed history file.

    Here is an example of how things can get corrupted if you only perform those 2 sed commands:

    Supposing the common directory was added and committed in revision 5, svndump would give:

    Node-path: project1/common
    Node-kind: dir
    Node-action: add
    Prop-content-length: 10
    Content-length: 10
    
    PROPS-END
    

    You run your incomplete sed magic, and the new repository fails to create the trunk/pub/common directory:

    Node-path: project1/common # bad! should be: trunk/pub/common !!!
    Node-kind: dir
    Node-action: add
    Prop-content-length: 10
    Content-length: 10
    
    PROPS-END
    

    From this point in time, svn will try to re-create your invalid paths, thus giving:

    <<< Started new transaction, based on original revision 2
    svnadmin: File not found: transaction '1-1', path '/trunk/pub/common'
         * adding path : trunk/pub/common ...
    

    Sometimes this can work. But most of the times it fails.

    Solution:

    Personally, I would use a text editor with nice search and replace features (e.g. vim), and replace all "project1", "project1/common" and "project1/common/bib" appearances.