You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Christoph Bartoschek <ba...@or.uni-bonn.de> on 2011/03/14 16:08:57 UTC

Merging from foreign repositories

Hi,

I would like to merge all changes in a directory from repository A to a 
directory in repository B.

My idea was to do a loop over all iterations and merge them to dirB:

svn merge -c rev file:///path/to/rep/A/dirA  dirB

My problem is that for the revision where dirA is created in repositoryA 
nothing is done. The next revision then fails because it misses a directory:

$ svn merge -r 0:1 file:///path/to/rep/A/dirA .
$ svn merge -r 1:2 file:///path/to/rep/A/dirA .
--- Merging (from foreign repository) r2 into '.':
   C utils
Summary of conflicts:
  Tree conflicts: 1


You see that the first command does nothing although dirA and lots of subdirs 
were created in revision 1.

How can this be fixed?

Christoph

Re: Merging from foreign repositories

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Christoph Bartoschek wrote on Mon, Mar 14, 2011 at 16:08:57 +0100:
> Hi,
> 
> I would like to merge all changes in a directory from repository A to a 
> directory in repository B.
> 
> My idea was to do a loop over all iterations and merge them to dirB:
> 
> svn merge -c rev file:///path/to/rep/A/dirA  dirB
> 
> My problem is that for the revision where dirA is created in repositoryA 
> nothing is done. The next revision then fails because it misses a directory:
> 
> $ svn merge -r 0:1 file:///path/to/rep/A/dirA .
> $ svn merge -r 1:2 file:///path/to/rep/A/dirA .
> --- Merging (from foreign repository) r2 into '.':
>    C utils
> Summary of conflicts:
>   Tree conflicts: 1
> 
> 
> You see that the first command does nothing although dirA and lots of subdirs 
> were created in revision 1.
> 
> How can this be fixed?
> 

svn merge -c 1 file:///path/to/rep/A/

(i.e., for the revision creating the dir, give the parent as the target)

> Christoph

Re: Merging from foreign repositories

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Mar 14, 2011 at 05:53:04PM +0100, Christoph Bartoschek wrote:
> Am Montag, 14. März 2011 schrieb Stefan Sperling:
> > You can probably write your hook script to be smart enough to do it.
> > But I suppose in your situation the dump/load approach is easier than
> > trying to play tricks with merging.
> 
> I do not have admin access to repository B. I can only check in into the 
> parent directory of dirB and below.

That's unfortunate.

This won't help you right now, but once Subversion 1.7 has been released,
you can use the new svnrdump tool to do this. It doesn't require admin
access because it works with any remote repository (and can also load
dump files into them):
http://subversion.apache.org/docs/release-notes/1.7.html#svnrdump

Re: Merging from foreign repositories

Posted by Christoph Bartoschek <ba...@or.uni-bonn.de>.
Am Montag, 14. März 2011 schrieb Stefan Sperling:
> On Mon, Mar 14, 2011 at 05:05:14PM +0100, Christoph Bartoschek wrote:
> > thanks for your suggestion. But the commit that created dirA also created
> > lots of other directories. I am only interessted in dirA.
> 
> Then let's just agree that the other stuff added in that commit
> is a merge conflict. So you svn revert -R all of that stuff after
> performing the merge and before committing the merge result.
> 
> > I wrote that I want to do this incrementally because I would like to
> > replicate each change in directory dirA of repository A to directory
> > dirB of repository B with a commit hook.
> 
> Since you're writing hook scripts, it sounds like you have a way to get
> an incremental dump file of each revision committed to repository A.
> If so, why not load them into repository B using svnadmin load?
> 
> svnadmin dump --incremental --deltas -rREV /path/to/reposA > REV.dump
> svnadmin load --parent-dir /branches/fromA /path/to/reposB < REV.dump
> 
> > Apparently this does not work with the commit that creates dirA. It seems
> > as if subversion is not able to do this. I will have to do this
> > manually.
> 
> You can probably write your hook script to be smart enough to do it.
> But I suppose in your situation the dump/load approach is easier than
> trying to play tricks with merging.

I do not have admin access to repository B. I can only check in into the 
parent directory of dirB and below.

Christoph

Re: Merging from foreign repositories

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Mar 14, 2011 at 05:05:14PM +0100, Christoph Bartoschek wrote:
> thanks for your suggestion. But the commit that created dirA also created lots 
> of other directories. I am only interessted in dirA. 

Then let's just agree that the other stuff added in that commit
is a merge conflict. So you svn revert -R all of that stuff after
performing the merge and before committing the merge result.

> I wrote that I want to do this incrementally because I would like to replicate 
> each change in directory dirA of repository A to directory dirB of repository 
> B with a commit hook.

Since you're writing hook scripts, it sounds like you have a way to get 
an incremental dump file of each revision committed to repository A.
If so, why not load them into repository B using svnadmin load?

svnadmin dump --incremental --deltas -rREV /path/to/reposA > REV.dump
svnadmin load --parent-dir /branches/fromA /path/to/reposB < REV.dump

> Apparently this does not work with the commit that creates dirA. It seems as 
> if subversion is not able to do this. I will have to do this manually.

You can probably write your hook script to be smart enough to do it. 
But I suppose in your situation the dump/load approach is easier than
trying to play tricks with merging.

Re: Merging from foreign repositories

Posted by Christoph Bartoschek <ba...@or.uni-bonn.de>.
Am Montag, 14. März 2011 schrieb Stefan Sperling:
> On Mon, Mar 14, 2011 at 04:08:57PM +0100, Christoph Bartoschek wrote:
> > Hi,
> > 
> > I would like to merge all changes in a directory from repository A to a
> > directory in repository B.
> > 
> > My idea was to do a loop over all iterations and merge them to dirB:
> > 
> > svn merge -c rev file:///path/to/rep/A/dirA  dirB
> > 
> > My problem is that for the revision where dirA is created in repositoryA
> > nothing is done.
> > 
> > You see that the first command does nothing although dirA and lots of
> > subdirs were created in revision 1.
> 
> The addition of dirA is a change on the *parent* of dirA.
> 
> So merge the parent folder into the target's parent folder first,
> preferrably using a two-URL merge (Last time I tried this, with
> TortoiseSVN, it would only work with a two-URL merge. I'm not sure if the
> CLI client has the same requirement. But since both use the same libraries
> that is not unlikely):
> 
> svn merge file:///path/to/rep/A/@rev-1 file:///path/to/rep/A/@rev
> parent-dir
> 
> This will add dirA into parent-dir. Commit this.
> 
> Next, you could experiment with renaming dirA to dirB.
> But if you ever merge at a higher level in the tree, so that changes
> made upstream in dirA appear as part of the diff, you will get tree
> conflicts since dirA won't be found at your end.
> So not renaming it might save you some headaches later.
> I'd recommend keeping the name.
> 
> Now, the following revs can apply cleanly.
> There is no need to loop over the revs, you can apply the entire
> range at once, giving you single commit that contains all the changes
> made upstream.
> 
> svn merge file:///path/to/rep/A/dirA@rev+1 file:///path/to/rep/A/dirA@HEAD
> dirA or if you decided to rename:
> svn merge file:///path/to/rep/A/dirA@rev+1 file:///path/to/rep/A/dirA@HEAD
> dirB
> 
> If you have a real need to cherry-pick individual changes merged from
> the foreign repository to branches in your own repository, you will
> need to loop over all the revs, of course, and merge them individually.
> 
> Note that there is no merge tracking with foreign repos merges,
> so make sure to note which revisions have already been merged from
> the foreign repository (e.g. in the log message).


Hi,

thanks for your suggestion. But the commit that created dirA also created lots 
of other directories. I am only interessted in dirA. 

I wrote that I want to do this incrementally because I would like to replicate 
each change in directory dirA of repository A to directory dirB of repository 
B with a commit hook.

Apparently this does not work with the commit that creates dirA. It seems as 
if subversion is not able to do this. I will have to do this manually.

Unfortunately the automatic merging still does not work after fixing the 
creation of dirA. I describe it in another main.

Christoph

Re: Merging from foreign repositories

Posted by Stefan Sperling <st...@elego.de>.
On Mon, Mar 14, 2011 at 04:08:57PM +0100, Christoph Bartoschek wrote:
> Hi,
> 
> I would like to merge all changes in a directory from repository A to a 
> directory in repository B.
> 
> My idea was to do a loop over all iterations and merge them to dirB:
> 
> svn merge -c rev file:///path/to/rep/A/dirA  dirB
> 
> My problem is that for the revision where dirA is created in repositoryA 
> nothing is done.

> You see that the first command does nothing although dirA and lots of subdirs 
> were created in revision 1.

The addition of dirA is a change on the *parent* of dirA.

So merge the parent folder into the target's parent folder first,
preferrably using a two-URL merge (Last time I tried this, with TortoiseSVN,
it would only work with a two-URL merge. I'm not sure if the CLI client
has the same requirement. But since both use the same libraries that is not
unlikely):

svn merge file:///path/to/rep/A/@rev-1 file:///path/to/rep/A/@rev parent-dir

This will add dirA into parent-dir. Commit this.

Next, you could experiment with renaming dirA to dirB.
But if you ever merge at a higher level in the tree, so that changes
made upstream in dirA appear as part of the diff, you will get tree
conflicts since dirA won't be found at your end.
So not renaming it might save you some headaches later.
I'd recommend keeping the name.

Now, the following revs can apply cleanly.
There is no need to loop over the revs, you can apply the entire
range at once, giving you single commit that contains all the changes
made upstream.

svn merge file:///path/to/rep/A/dirA@rev+1 file:///path/to/rep/A/dirA@HEAD dirA
or if you decided to rename:
svn merge file:///path/to/rep/A/dirA@rev+1 file:///path/to/rep/A/dirA@HEAD dirB

If you have a real need to cherry-pick individual changes merged from
the foreign repository to branches in your own repository, you will
need to loop over all the revs, of course, and merge them individually.

Note that there is no merge tracking with foreign repos merges,
so make sure to note which revisions have already been merged from
the foreign repository (e.g. in the log message).