merge local commits to svn repo as svn branch

Jelmer Vernooij jelmer at vernstok.nl
Mon May 4 16:33:53 BST 2009


Hi Michael,

Michael Goerz wrote:
> In my scenario, I want to use bzr to interact with subversion repositories.
>
> So, I start out with a bzr checkout of my repo:
>  %localhost:~> bzr co svn://svnhost/repo/trunk trunk
> I can make changes and commit them completely transparently to the repository.
> Now, suppose I unexpectedly get disconnected  from the network for a while. I
> do
>  %localhost:~/trunk> bzr unbind
> and make several local commits to my bzr branch. Other people continue to work
> on the svn repo and make several commits on the trunk there. When I get back on
> the network, I do
>  %localhost:~/trunk> bzr bind
>
> At this point it seems I have two possibilities to get my changes back to the
> central svn repo:
>
> A)
>  %localhost:~/trunk> bzr up
>  [resolve conflicts]
>  %localhost:~/trunk> bzr ci
> The result of this is that all my changes appear in a single commit, mashing
> together all the local commits I did on my bzr branch. If I've done a lot of
> local commits, this does not seem desirable.
>   
You can set "push_merged_revisions = True" in the configuration, in
which case bzr-svn will also push the right hand side revisions (shown
indented by "bzr log") onto branches/<nick>.
> B)
>  %localhost:~/trunk> bzr merge svn://svnhost/repo/trunk
>  %localhost:~/trunk> bzr ci --local -m "Reconciled with trunk HEAD"
>  %localhost:~/trunk> bzr svn-push svn://svnhost/repo/trunk
> This will make all the local commits that I did while being disconnected
> visible to the svn repository. However, the changes that appear to happen in
> the individual revisions on the svn server will be somewhat weird. Suppose I
> made my bzr branch from the svn repo at R100, and made 2 local commits. Other
> people made three commits R101, R102, R103 on the svn server. Now when I push
> in my local commits as described above as R104, R105, and R106 for the
> "reconciliation commit", it will look like R104 completely undid all the
> changes from R101-R103, and R106 reintroduced them.
>
> The problem here is of course that subversion doesn't have true branches in the
> way bzr has them and my local bzr branch is flattened into the trunk. And ideal
> situation would be to merge my bzr branch into an svn branch (at
> svn://repo/branches/my-branch), and then later merge that branch to the trunk
> using svn. If I knew in advance that I'm going to be disconnected I could
> create the svn branch first, and then to a bzr checkout of that branch. But if
> I don't know in advance it would be nice if I could create a branch from the
> R100 revision
>  %svnhost:~> svn cp -r100 file:///repo/trunk file:///repo/branches/my-branch
> and then somehow make my bzr checkout believe that it's a checkout of
> my-branch instead of the trunk. 'bzr switch' doesn't work in this case, since
> you can't switch while you have local changes.
>
> What would you recommend in a scenario like this?
>   
You might want to check out bzr-rebase, that will make sure you end up
with a "flat" history in all case (no merges). That seems to match your
work flow in Subversion better.

Cheers,

jelmer



More information about the bazaar mailing list