You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Stephane Bortzmeyer <bo...@nic.fr> on 2008/05/06 15:16:25 UTC

Copying a part of another repository, *with* its history

I have a repository where I would like to include a subtree of another
repository, ***with its history***. I do not know if it is compatible
with the Subversion model (unique revision number, atomic commits,
etc). I find no solution in The Book or in the FAQ.

The obvious solution is not accepted:

% svn copy svn+ssh://bortzmeyer@foobar.example.com/home/bortzmeyer/one/two https://svn.nic.fr/ReD-AFNIC/Etudes 
svn: Source and dest appear not to be in the same repository (src: 'svn+ssh://bortzmeyer@foobar.example.com/home/bortzmeyer/one/two'; dst: 'https://svn.nic.fr/ReD-AFNIC/Etudes')

I tried the svnadmin dump + load way but I cannot find the right
combination.

% svnadmin dump /home/bortzmeyer/one > tmp/svn
% svndumpfilter include /two < tmp/svn > tmp/svn-filtered
% svnadmin load  --parent-dir /ReD-AFNIC/Etudes /var/lib/svn < tmp/svn-filtered

But svnadmin load fails:

...
<<< Started new transaction, based on original revision 4
svnadmin: File not found: transaction '92-1', path '/ReD-AFNIC/Etudes/two'
     * adding path : ReD-AFNIC/Etudes/two ... %

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Stephane Bortzmeyer <bo...@nic.fr>.
On Tue, May 06, 2008 at 11:34:56AM -0700,
 Blair Zajac <bl...@orcaware.com> wrote 
 a message of 12 lines which said:

> If you don't need to merge the repositories, you can use svn:externals:

Good idea, but I prefer to delete the old repository and, yes, I need
to merge.

(The solution I posted in my previous message worked, I was able to
import all the parts of the old repository I needed. It is not obvious
so the moral lesson is: think twice before organizing into several
repositories. Unlike CVS, Subversion allows you to change the
directories inside one repository but not between repositories.)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Blair Zajac <bl...@orcaware.com>.
Stephane Bortzmeyer wrote:
> I have a repository where I would like to include a subtree of another
> repository, ***with its history***. I do not know if it is compatible
> with the Subversion model (unique revision number, atomic commits,
> etc). I find no solution in The Book or in the FAQ.

If you don't need to merge the repositories, you can use svn:externals:

http://svnbook.red-bean.com/en/1.4/svn.advanced.externals.html

Regards,
Blair

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Stephane Bortzmeyer <bo...@nic.fr>.
On Tue, May 06, 2008 at 09:04:11AM -0700,
 Kevin Grover <ke...@kevingrover.net> wrote 
 a message of 158 lines which said:

> Sorry about the lack of details, hopefully this is enough of a
> pointer to move you in the right direction.  My biggest problems
> were 1) re-mapping directories; and 2) making sure leading
> directories where created ONLY if needed.

Perfectly right. I documented the whole thing (in French) on my blog
<http://www.bortzmeyer.org/copy-subversion-subtree.html>. Many thanks
again.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Les Mikesell <le...@gmail.com>.
Stephane Bortzmeyer wrote:
>> 
>> 2) You have to be careful about which directories exist and which need to be
>> created
> 
> That was the trick *and* I needed to commit as well, not just to
> create the directories in a working copy as I did once :-(

You can 'svn mkdir URL' to add directories directly in the repository.


-- 
   Les Mikesell
    lesmikesell@gmail.com



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Ryan Schmidt <su...@ryandesign.com>.
On May 7, 2008, at 7:44 AM, Les Mikesell wrote:

> Ryan Schmidt wrote:
>>> Some warnings: the revision numbers are not preserved  
>>> (obviously), the
>>> dates are, but, now, in the new repository, the order of  
>>> revisions is
>>> no longer the chronological order.
>> Correct, the revisions are no longer chronological with this  
>> approach. If you want to merge two or more repositories and  
>> maintain the chronological property of revisions (i.e. interleave  
>> and renumber the revisions of both repositories) there exist  
>> scripts which will do that. svndumptool will do this, and I think  
>> there are other scripts as well.
>
> Is there anything that will convert something from cvs and merge it  
> in date order?  Or fix a repository after a cvs2svn dump has been  
> loaded?

I think there's an option in cvs2svn to have it write out an svn  
dumpfile, so you could cvs2svn your original repositories, then use  
svndumptool to merge the various dumpfiles keeping the revisions in  
chronological order, and import the result into the final Subversion  
repository.

Not sure about fixing a repository that already has non-chronological  
revisions after the fact. svndumpfilter and similar dump-combining  
scripts may assume that the original dumpfiles are in chronological  
order already and may fail to do the right thing if they're not. But  
you could try it out, or ask the authors of the scripts.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Les Mikesell <le...@gmail.com>.
Ryan Schmidt wrote:
> 
>> Some warnings: the revision numbers are not preserved (obviously), the
>> dates are, but, now, in the new repository, the order of revisions is
>> no longer the chronological order.
> 
> Correct, the revisions are no longer chronological with this approach. 
> If you want to merge two or more repositories and maintain the 
> chronological property of revisions (i.e. interleave and renumber the 
> revisions of both repositories) there exist scripts which will do that. 
> svndumptool will do this, and I think there are other scripts as well.

Is there anything that will convert something from cvs and merge it in 
date order?  Or fix a repository after a cvs2svn dump has been loaded?

-- 
   Les Mikesell
    lesmikesell@gmail.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Ryan Schmidt <su...@ryandesign.com>.
On May 6, 2008, at 2:45 PM, Stephane Bortzmeyer wrote:

> On Tue, May 06, 2008 at 09:04:11AM -0700,
>  Kevin Grover <ke...@kevingrover.net> wrote
>  a message of 158 lines which said:
>
>> The tough points are:
>> 1) You may have to edit the dump file to get the paths to be what  
>> you want
>> in the destination repository
>
> In my case, it was apparently not necessary. If it had been, I would
> have used sed to edit "Node-path" lines in the dump.

Editing a dumpfile by hand (or with sed) can be tricky to get right.  
You may be able to use svndumptool to edit the dumpfile more safely.

http://svn.borg.ch/svndumptool/


>> 2) You have to be careful about which directories exist and which  
>> need to be
>> created
>
> That was the trick *and* I needed to commit as well, not just to
> create the directories in a working copy as I did once :-(

Correct, the directory into which you want to load the dump must  
already exist in the repository.


>> To prevent accidentally editing the 'old' source, you should 'svn  
>> delete'
>> the path from the source repository after successfully migrating it.
>
> Right.
>
>> Tools: svndumpfilter (comes with CLI svn install), svn_load_dir.pl  
>> (and
>> there's also a newer re-implementation in python, call svnload.py  
>> (I think).
>
> I used only regular "svnadmin load". svn_load_dir.pl seems to be for a
> different use.

Correct, svn_load_dirs.pl is not relevant to this problem.


> Many thanks for the help, I do some more tests and I'll try with my
> real repository soon.
>
> Some warnings: the revision numbers are not preserved (obviously), the
> dates are, but, now, in the new repository, the order of revisions is
> no longer the chronological order.

Correct, the revisions are no longer chronological with this  
approach. If you want to merge two or more repositories and maintain  
the chronological property of revisions (i.e. interleave and renumber  
the revisions of both repositories) there exist scripts which will do  
that. svndumptool will do this, and I think there are other scripts  
as well.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: Copying a part of another repository, *with* its history

Posted by Stephane Bortzmeyer <bo...@nic.fr>.
On Tue, May 06, 2008 at 09:04:11AM -0700,
 Kevin Grover <ke...@kevingrover.net> wrote 
 a message of 158 lines which said:

> The tough points are:
> 1) You may have to edit the dump file to get the paths to be what you want
> in the destination repository

In my case, it was apparently not necessary. If it had been, I would
have used sed to edit "Node-path" lines in the dump.

> 2) You have to be careful about which directories exist and which need to be
> created

That was the trick *and* I needed to commit as well, not just to
create the directories in a working copy as I did once :-(
 
> To prevent accidentally editing the 'old' source, you should 'svn delete'
> the path from the source repository after successfully migrating it.

Right.
 
> Tools: svndumpfilter (comes with CLI svn install), svn_load_dir.pl (and
> there's also a newer re-implementation in python, call svnload.py (I think).

I used only regular "svnadmin load". svn_load_dir.pl seems to be for a
different use.
 
Many thanks for the help, I do some more tests and I'll try with my
real repository soon.

Some warnings: the revision numbers are not preserved (obviously), the
dates are, but, now, in the new repository, the order of revisions is
no longer the chronological order.

I attach a shell script which I used to test the procedure. It
demonstrates the steps to perform.

Re: Copying a part of another repository, *with* its history

Posted by Kevin Grover <ke...@kevingrover.net>.
On Tue, May 6, 2008 at 8:16 AM, Stephane Bortzmeyer <bo...@nic.fr>
wrote:

> I have a repository where I would like to include a subtree of another
> repository, ***with its history***. I do not know if it is compatible
> with the Subversion model (unique revision number, atomic commits,
> etc). I find no solution in The Book or in the FAQ.
>
> The obvious solution is not accepted:
>
> % svn copy svn+ssh://bortzmeyer@foobar.example.com/home/bortzmeyer/one/two
> https://svn.nic.fr/ReD-AFNIC/Etudes
> svn: Source and dest appear not to be in the same repository (src:
> 'svn+ssh://bortzmeyer@foobar.example.com/home/bortzmeyer/one/two'; dst: '
> https://svn.nic.fr/ReD-AFNIC/Etudes')
>
> I tried the svnadmin dump + load way but I cannot find the right
> combination.
>
> % svnadmin dump /home/bortzmeyer/one > tmp/svn
> % svndumpfilter include /two < tmp/svn > tmp/svn-filtered
> % svnadmin load  --parent-dir /ReD-AFNIC/Etudes /var/lib/svn <
> tmp/svn-filtered
>
> But svnadmin load fails:
>
> ...
> <<< Started new transaction, based on original revision 4
> svnadmin: File not found: transaction '92-1', path '/ReD-AFNIC/Etudes/two'
>     * adding path : ReD-AFNIC/Etudes/two ... %
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>


You can do it.  But, it requires some work.

You 'svnadmin dump' the source repository (and filter out the paths you
want).  Then, you 'svnadmin load' those paths into the new repository.

The tough points are:
1) You may have to edit the dump file to get the paths to be what you want
in the destination repository
2) You have to be careful about which directories exist and which need to be
created

To prevent accidentally editing the 'old' source, you should 'svn delete'
the path from the source repository after successfully migrating it.

Tools: svndumpfilter (comes with CLI svn install), svn_load_dir.pl (and
there's also a newer re-implementation in python, call svnload.py (I think).

I've done this when I have a directory in my test repository that I want to
'promote' to it's own repository.  I had to fight to get the initial
directories right.

NOTE: if you have merges or anything that depended on version number in the
source repository, they will not be correct in the destination repository.

Sorry about the lack of details, hopefully this is enough of a pointer to
move you in the right direction.  My biggest problems were 1) re-mapping
directories; and 2) making sure leading directories where created ONLY if
needed.

- Kevin