📜 ⬆️ ⬇️

Split Subversion repository into parts

When I first learned about the version control system, I decided that I should definitely try this development tool. At that time, I had little idea what it was. Therefore, after reviewing the available offers, I chose Subversion.
After reading a few manuals I decided to create my first repository. And suddenly I thought for a minute, and how to organize the structure, if I have several projects ... and for myself I decided that I would create a tree that is divided into projects, and in each project there will be painfully familiar to everyone trunk, tags, branches. As time passed, the number of projects increased (though not very much, but still) and somehow sadly began to observe the through-numbering of revisions in the project. Those. You look at the project logs, and there first there is a 649 revision, and then 700. All the same, programmers are ambitious, they love it when everything is laid out, so it was decided to divide one large repository into several smaller ones.

So, a brief instruction so that everything was on "feng shui"

Some basic data:

Instruction:
  1. We need to dump our repository. To do this, run the command:
    svnadmin dump /home/user/svn/reps/projects > myrep.dump
  2. Now leave only one project.
    cat myrep.dump | svndumpfilter include Projects/Project1 --drop-empty-revs --renumber-revs > project1.dump

    --drop-empty-revs - remove empty revisions
    --renumber-revs - renumber revisions

    It is necessary to specify the full path to the project, i.e. not just the name of the project “Project1”, but namely “Projects / Project1”. Otherwise, you will receive an empty dump file.
    ')
    In general, the previous two teams can be combined
    svnadmin dump /home/user/svn/reps/projects | svndumpfilter include Projects/Project1 --drop-empty-revs --renumber-revs > project1.dump
  3. Let's create a new repository for the project in the «reps» folder
    svnadmin create project1
  4. Load the cleaned dump into the new repository.
    svnadmin load project1 < project1.dump
    An error occurs in this step.
    svnadmin: File not found transaction '0-0', path Projects/Project1 , i.e. this means that the Projects folder does not exist. Apparently during restoration, the structure is not recreated.
    To fix this, you must manually create a folder “Projects”:
      svn mkdir http://svn.mysite.ru/project1/Projects -m "Creating Projects folder" 

    And now we can safely perform:
    svnadmin load project1 < project1.dump
  5. Because the structure of the new repository turned out, repeating the old structure, it will be necessary to transfer everything from the folder “Project1” to the root of the repository, and then delete the folder “Projects”

I would like to write here “Everything” and put an end. But still, among these 4 items, there is a fly in the ointment.
If, during the work on the project, you renamed it, then at the 2nd step an error Invalid copy source path ' ' will occur.
The regular svndumpfilter program cannot solve this problem.
After some searching, I found a script written in python svndumpfilter2 that allows you to work around this limitation.
Download the script to your computer and enter the command
cat myrep.dump | svndumpfilter2 --drop-empty-revs --renumber-revs /home/user/svn/reps/projects Projects/Project1 > project1.dump
There are some differences from svndumpfilter.


Well, now ... EVERYTHING.

Note: When I started writing this article (and this was a week ago), then searching on Habré did not find anything similar. But since My publication was postponed a bit, then during this time a similar article appeared Restore the SVN repository , but since It seems to me that some problems are not covered there, I decided to publish my article.

Source: https://habr.com/ru/post/73788/


All Articles