views:

1949

answers:

3

A bit of background first:

  • I am using "base" code from a remote SVN repository, not under my control. The code is not tagged (yet), so I always need to keep up with the trunk.

  • For a number of reasons (the most important being that our local extensions to the code are of a "niche" nature, and intended to solve a specific problem with the project in which the code is used) I can't use the remote repository to do version control of any modifications I make locally.

  • I have a local SVN repository in which I am currently doing the "local" versioning.

The problem I'm faced with: I can't figure out if there's a good way to have the code simultaneously synchronized with both repositories. That is, I would like to keep the "remote" version information (so that I can merge in future changes), but I would also like to have "local" version information at the same time (i.e., within the same directory structure).

At the moment I am doing this using two different directories, both containing identical code, but each containing different versioning information. Obviously this is quite a bit of overhead, especially since the code in the two directories needs to be synchronized independently.

Is there a way to do this in subversion? Or do you have suggestions about alternative ways of approaching this?

+3  A: 

You can have your local repository where you commit your changes, as you already have done. Further you would do a periodic merge from the base repository in order to merge the changes done in the base trunk into your local repository.

The only difficult thing is that you need to keep track of the revisions from which you've already merged from the base repository.

This could look like this:

svn merge -r X:Y baseRepositoryURL // merge from base repo
svn commit                         // commit the changes to local repo
svn merge -r Y:Z baseRepositoryURL // merge from base repo
svn commit                         // commit the changes to local repo

Where X is the revision of your initial checkout, Y is the head revision a the time of the first merge and Z is the head revision a the time of the second merge. You see the pattern. Furthermore it is important that you are in the base directory of your local checkout when issueing the commands.

boutta
That's probably an easier to maintain alternative to what I'm doing now, but still needs "manual" version management... Anyway, thanks for the suggestion, will give it at least a try for a couple of days before resorting to git :-)
Alex
If bothSVN servers have version 1.5 the manual tracking of the revisions isn't needed anymore. But only under SVN 1.5
boutta
+5  A: 

I did this using git svn, with my development done in a git repository. The remote development is done in subversion. I made a git svn clone of the subversion repository, which I push to a real git repository. A cronjob runs "git svn rebase && git push" every now and again to create a git mirror of the subversion repo.

In order to merge the subversion changes, I have 2 remotes in my local git copy - the "local development" origin and the "from subversion mirror" origin. Whenever I feel the need, I can merge changes from the subversion mirror into our development tree. Local changes are not affected, they live apart and don't mess up the svn mirror.

I used gitosis to set up and administer the git repositories. The steps would be something like this (from memory, may be wrong):

# set up the mirror
git svn clone -s $SVN
git remote add origin git@$MACHINE:svnmirror.git
git push
# + cron job to do git svn rebase && git push every N hours/minutes

# set up the local working copy for development
git clone git://$MACHINE/svnmirror.git
# that's an anonymous, read only clone 
# no push to the svn mirror for developers - only cronjob user can push there
git remote add newproject git@$MACHINE:myproject.git
git push newproject
# now do the real deal
git clone git://$MACHINE/myproject.git
# hack hack hack
git push # origin master not needed
git remote add svnmirror git://$MACHINE/svnmirror.git
git merge svnmirror/master
git push
rq
Git looks impressive. Seems to me like you could do much more than with svn.
boutta
Thanks, I this is almost exactly what I was looking for. Off to learning git!
Alex
Boutta, What can svn do that git can't?
csexton
I am stuck at a similar situation needing to sync two svn repos. I tried your instructions, but I constantly get "bash: git-receive-pack: command not found". Any ideas?
Shoan
Have you installed git on the server? Is the installed bin dir in your $PATH? I use this with git 1.6.0.2, maybe git-receive-pack has changed names since?
rq
A: 

Thank you so much boutta For your help

Mursil