Splitting a Subversion repository into parts
When I first learned about the version control system, I decided that I definitely should try this development tool. At that time, I had little idea what it was. Therefore, looking at the available offers, I chose Subversion.
After reading a little manual, I decided to create my first repository. And suddenly I thought for a moment, but how to organize the structure if I have several projects ... and I decided for myself that I will create a tree that is divided into projects, and in each project everyone will be familiar with trunk, tags, branches. As time went on, the number of projects increased (although not very much, but still) and somehow it became sad to observe the end-to-end numbering of revisions in the project. Those. you look at the project logs, and there first 649 revisions, and then 700. All the same, programmers are ambitious people, loves when everything is sorted out, so it was decided to split one large repository into several smaller ones.
So, a brief instruction, so that everything is according to "feng shui"
A bit of initial data:
Instruction:
Here I would like to write "Everything" and put an end to it. But still, among these 4 points, there is a fly in the ointment.
If you renamed it during work on the project, then an error will occur at the 2nd step
A full-time program
After some searching, I found a script written in python svndumpfilter2 , which allows to get around this limitation.
Download the script to your computer and enter the command.
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 Since my publication was postponed a little, a similar article appeared Restoring the SVN repository , but because It seems to me that some problems are not covered there, I decided to publish my article.
After reading a little manual, I decided to create my first repository. And suddenly I thought for a moment, but how to organize the structure if I have several projects ... and I decided for myself that I will create a tree that is divided into projects, and in each project everyone will be familiar with trunk, tags, branches. As time went on, the number of projects increased (although not very much, but still) and somehow it became sad to observe the end-to-end numbering of revisions in the project. Those. you look at the project logs, and there first 649 revisions, and then 700. All the same, programmers are ambitious people, loves when everything is sorted out, so it was decided to split one large repository into several smaller ones.
So, a brief instruction, so that everything is according to "feng shui"
A bit of initial data:
- Physical repository location:
/home/user/svn/reps/projects
- Access to the repository is configured through apache and has an address
http://svn.mysite.ru
Previously, the SVNPath variable was used, pointing to/home/user/svn/reps/projects
, but since we are going to separate projects, then we will configure access using the
SVNParentPath variable "/ home / user / svn / reps" - The structure of the repository to be divided:
http://svn.mysite.ru | | -Modules | | -Projects | | -Project1 | | -Project2
Instruction:
- We need to dump our repository. To do this, run the command:
svnadmin dump /home/user/svn/reps/projects > myrep.dump
- Now we leave only one project
cat myrep.dump | svndumpfilter include Projects/Project1 --drop-empty-revs --renumber-revs > project1.dump
--drop-empty-revs - delete empty revisions
--renumber-revs - renumber revisions
We must specify the full path to the project, i.e. not just the name of the project "Project1", namely "Projects / Project1". Otherwise, the output will get an empty dump file.
In general, the previous two teams can be combinedsvnadmin dump /home/user/svn/reps/projects | svndumpfilter include Projects/Project1 --drop-empty-revs --renumber-revs > project1.dump
- Create a new repository for the project in the “reps” folder
svnadmin create project1
- Upload the cleared dump to the new repository.
svnadmin load project1 < project1.dump
An error occurs at this stepsvnadmin: 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 need to manually create the Projects folder:svn mkdir http://svn.mysite.ru/project1/Projects -m "Creating the Projects folder"
And now we can safely execute:svnadmin load project1 < project1.dump
- Because if you get the structure of a new repository that repeats the old structure, you will need to transfer everything from the Project1 folder to the root of the repository, and then delete the Projects folder
Here I would like to write "Everything" and put an end to it. But still, among these 4 points, there is a fly in the ointment.
If you renamed it during work on the project, then an error will occur at the 2nd step
Invalid copy source path 'старое название проекта'
. A full-time program
svndumpfilter
cannot solve this problem. After some searching, I found a script written in python svndumpfilter2 , which allows to get 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.
- You must specify the path to the physical location of the repository, i.e. / home / user / svn / reps / projects
- Only include key is supported. (it does not need to be specified)
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 Since my publication was postponed a little, a similar article appeared Restoring the SVN repository , but because It seems to me that some problems are not covered there, I decided to publish my article.