codecraig
codecraig

Reputation: 3158

SVN Merge Branch from one Repo into Trunk of other Repo

I have two repositories which live on separate servers, call them repo-1 and repo-2.

To start both "trunks" were equal:

repo-1/trunk == repo-2/trunk

Meanwhile changes were being commited to repo-1/trunk and I was working on and commiting changes to repo-2/trunk.

Now I need to merge changes from repo-1/trunk into repo-2/trunk.

I thought I would copy repo-1/trunk into repo-2/tags/r1_20090224, then merge that tag into my local working copy of repo-2/trunk (i.e. c:\dev\repo2-trunk).

Any suggestions on how to do this? I'm trying to use TortoiseSVN and performing "Merge two different trees", I used the following settings:

From: repo-2/trunk To: repo-2/tags/r1_20090224 Working Copy: c:\dev\repo2-trunk

I also tried swapping the "from" and "to"...but no luck. By trying either of those two merge options I either end up with the following outcome:

  1. If I merge from trunk to tag (into my local copy of repo-2/trunk) I lose my trunk changes and get the tag changes.

  2. If I merge from tag to trunk (into my local copy of repo-2/trunk) I lose my tag changes and keep my trunk changes.

Any suggestions on to do this??

Upvotes: 5

Views: 4793

Answers (4)

vladr
vladr

Reputation: 66721

If svn merge were to fail you across the two sites/servers:

svn: Unusable URI: it does not refer to this repository

Then use the following approach:

  1. identify the revision level at which repo-2 started diverge from repo-1, say 123, then:
  2. svn co http://server1/repo-1/trunk
  3. svn diff -r123:HEAD http://server2/repo-2/trunk >repo2.patches
  4. patch -p0 -i repo2.patches
  5. screen for any conflicts and resolve them
  6. svn ci --message "merged from repo-2"

Upvotes: 1

Brent.Longborough
Brent.Longborough

Reputation: 9775

It's not entirely clear, but you need to merge from the base of the two trees, i.e. the point at which the two trunks were the same.

Sander beat me to it, so credit to him, but here are a couple more tips:

  1. Get these two repositories joined up into one as soon as possible; Subversion wasn't really designed to work like this. Or alternatively move to a DVCS like git or bazaar or ...
  2. If you stick with Subversion, conventionally this kind of stuff is done with branches, not tags. Tags are normally used as marker points, and are not committed to.

Upvotes: 1

Assaf Lavie
Assaf Lavie

Reputation: 76153

SVK might be able to help if you find yourself constantly managing multiple repositories over time that need to be synced every once in a while.

Upvotes: 0

Sander Rijken
Sander Rijken

Reputation: 21615

First figure out the revision where the trees were the same. Then merge that from that revision to HEAD of the repo-1 repository to your repo-2 working copy.

Using the commandline client it's similar to this, if you want to merge changes between r123 and r456

svn merge http://domain.tld/repos1@123 http://domain.tld/repos1@456 repos2-workingcopy

Upvotes: 1

Related Questions