Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Split files while keeping history in SVN

During refactoring, I sometimes have to split one source file into two or more (for example, when a class has become so big that it should be split up into two classes).

For example, let A be the original file, and B1 and B2 the new files.

Is it possible to tell SVN that B1 and B2 should both "inherit" the complete history of file A, so when I look at both the history logs of B1 and B2, I can see that they have been emerged out of A, and the logs look like this:

A                B1                  B2
- change A3      - change B1.2       - change B2.2
- change A2      - change B1.1       - change B2.2
- change A1      - change A3         - change A3
                 - change A2         - change A2
                 - change A1         - change A1

I know how to keep the history when I rename a file (like discussed here on SO), but AFAIK that is only a way to keep the history of A associated with either B1 or B2, not both.

Currently I am using Tortoise SVN 1.6.12 on Windows.

like image 538
Doc Brown Avatar asked Feb 15 '11 09:02

Doc Brown


1 Answers

Just make 2 SVN copies of file A and then SVN delete File A.

I have just made a quick test with a new repo and it seems to work perfectly.

  1. I created file A.txt with two classes B1 and B2 inside and committed file a.txt
  2. I made a SVN copy of A.txt to B1.txt and remove the declaration of class B2 from B1.txt
  3. I made another SVN copy of A.txt to B2.txt and remove the declaration of class B1 from B2.txt
  4. I SVN deleted A.txt
  5. Commited everything and the history looks good.
like image 57
Otherside Avatar answered Oct 02 '22 12:10

Otherside