Search code examples
svnsvnadmin

How to merge history about SVN


I want to merge history of two files in different branch.Two files’s content is different.

Example

Branch1 a.txt 
History(rev)
1 make file
7 Modify file
15 add functions 

Branch 2 b.txt
32 make file
45 Modify file
60 add functions

Expectation
a.txt
1 make file
7 Modify file
15 add functions
32 make file
45 Modify file
60 add functions

File name can be a.txt or b.txt


Solution

    1. You can do it (faked history) easy
    2. If Branch1 is ancestor of Branch2 (test it), you can try some tricks with dump of repo (dump-edit-import into new repo, test result, replace unmodified repo with extended):

    Hard way

    In order to have common history, you have to have new or edited existing changeset between r15 and r32, in which rename a.txt ->b.txt will be recorded... But, if you add revision in the middle of existing history, you must also change numbers of all subsequent revisions (AFAICR) also

    1. Before creating dump, you have to create such "rename-revision" in the HEAD of any affected branch (in order to copy-paste its presentation in dump in another location)
    2. Dump
    3. Edit
    4. Load full modified dump

    Less tricky way

    1. p.1 of hard way, write|remember rev-id of this commit N
    2. p.2 of hard way
    3. load part of dump from start to somewhere in between 15:32, note max-loaded revision M
    4. load "rename rev" N only, prepared on step 1
    5. load rest part of dump in range M+1:N-1 (from breakpoint to end without last "technical" revision, unwanted in polished history)