Using local Bazaar checkouts from a remote Subversion repository

John Szakmeister john at szakmeister.net
Wed Oct 20 09:16:12 BST 2010


On Tue, Oct 19, 2010 at 3:11 PM, Tom Browder <tom.browder at gmail.com> wrote:
[snip]
> John, thanks, great blogs.  I had seen them early on and didn't know
> enough then to realize the impact of what you said.  I also found that
> I was wrong about the binding issue.  As a consequence I am starting
> over and including my corrections after the fact as I think I now have
> a working solution.
>
> A recap of my original situation:
>
> repo 1: subversion repo on remote host A (accessed via vpn to company network)
>
>  note that repo 1 is the master source repository (and it is backed
> up onto multiple disks with svn hotcopy)
>
> repo 2: bzr repo on local network host B, checked out from repo 1
>
> repo 3; bzr repo on local network host C, checked out from repo 2
>
> The fundamental original question was how to update repo 1 from repo 2?

FYI, I staged this on my local machine and got:
    :: svnadmin create repo
    :: svn co file://`pwd`/repo wc
    Checked out revision 0.
    :: cd wc
    :: svn mkdir trunk tags branches
    A         trunk
    A         tags
    A         branches
    :: svn ci -m "Initial commit."
    Adding         branches
    Adding         tags
    Adding         trunk

    Committed revision 1.
    :: cd ..
    :: bzr co file://`pwd`/repo/trunk bzr-branch1
    Initialising Subversion metadata cache in
/Users/jszakmeister/.bazaar/svn-cache/0b15f387-bce9-41bd-8e2b-2ea06a23bc94.
    :: bzr co bzr-branch1 bzr-branch2
    :: cd bzr-branch2/
    :: echo hi > hi.txt
    :: bzr add
    adding hi.txt
    :: bzr ci -m "Add hi."
    bzr: ERROR: Cannot commit to branch
BzrBranch7(file:///Users/jszakmeister/tmp/test-co/bzr-branch2/). It is
bound to BzrBranch7(file:///Users/jszakmeister/tmp/test-co/bzr-branch1/),
which is bound to file:///Users/jszakmeister/tmp/test-co/repo/trunk.

So, apparently the bzr devs disallowed chaining in this way.  BTW,
that was with bzr 2.2.1.

> One point I didn't make earlier was that I am the major user of that
> company subversion repo (actually a subversion branch) and no one will
> likely be using it, so I essentially have complete control--i.e.,
> there should be no merge surprises).

That's helpful, but you might still want to consider a slightly
different workflow if that ever changes.

> After John's questions, I went back and did experiments where I added
> new files in the working trees on all the hosts, changed bindings, and
> generally mucked around to see how I could get it all to work for my
> weird (but I suspect not unheard of) work flow.
>
> My working concept of operations now is this:
>
> 1. Normal operations:
>
> repo 2 is unbound
>
> I work in repo 3 (my laptop, at home) which stays bound to repo 2 on
> my home network and commits are done regularly
>
> repo2 is backed up periodically by pulling into backup repos on host B
> (from System Admin Guide, using bzr as its own backup)
>
> periodically on host B I will rebind repo2 to repo 1, update repo2 and
> commit pending merges to repo 1, then unbind repo 2 again

No need to rebind.  Just 'bzr push'.  And bzr-svn will let you know if
you're doing something questionable (like re-ordering the mainline).

> 2. Mobile operations (work on laptop while away from my network as
> well as the company network):
>
> I work in repo 3 (my laptop, on the road) which normally stays unbound
>
> periodically I will rebind repo3 to repo 1 (a change in parent!),
> update repo3 and commit pending merges to repo 1, then unbind repo 3

Again, no need to do this rebind/unbind dance... just use 'bzr push'.
Bazaar is made to run disconnected, so it's designed to make working
in a disconnected way easy, hence the 'push' command. :-)

> 3.  Return to home network from a road trip
>
> rebind repo 3 to repo 2, update and commit
>
> bind repo 2 to repo 1, update and commit, unbind repo 2

If your latest changes are already in repo 1, then you can just 'bzr
pull' in repo 2.  Or, just 'bzr push' from repo 3 to repo 2.  No need
to do both, unless your latest changes are not in repo 1.

> return to normal operations [1]
>
> From my brief experiments that seems to work okay with no loss of data
> (except probably weird tags and logs).  I have done 'bzr version-info'
> on repos 2 and 3 after all changes, additions, commits, updates, and
> merges and gotten the same revision spec in repos 2 and 3.

There should be no weird tags or logs.  The one thing you may want to
watch out for is ghosts.  They occur when you branch locally, but that
never makes it to the Subversion server.  When the local branch is
merged in, it will ultimately reference revisions that don't exist in
Subversion, and you end up with a ghost.  Previous versions of Bazaar
were worse about ghosts, and would traceback.  I think they've largely
been put to rest, but because of previous problems, you may want to
consider avoiding them.

> Now, granted, if there were someone else in the mix things might not be so easy.
>
> BTW, one thing I really appreciate about bazaar is the ability to tag
> revisions--I had to leave the subversion developers list in
> frustration a long time ago because I could not convince anyone of the
> utility of tags as CVS uses them rather than the "cheap directory
> copy" of subversion.

I don't mind the "cheap copy" aspect so much as there isn't a way to
leverage the tag name when trying to compare versions, without using
full URLs.  That, and I was never fond of having to drop in a
pre-commit script to keep folks from editing the contents in a tag.

> Ideas and comments welcome.

The only thing I'd really recommend is having a little less
binding/unbinding going on.  I'm not entirely sure what happens when
repo 3 has revisions not present in repo 2, and you've rebound it...
Okay, so I just tried that out, and it looks like a good way to
introduce ghosts... so yet another reason to avoid it, in my head. :-)

That's one more thing you should look out for.  Ghosts will change
what you see.  From repo 3, you'll see all the branching and merging
happening, but if you 'bzr branch' repo 1 somewhere else, and look at
the log, you'll see that you can't peer into that separate line of
history anymore.

So, make sure to sit down and observe what's happend from several
different angles.  BTW, I'd also consider hosting Bazaar on host A,
instead of Subversion, especially if your the only consumer.  bzr ->
svn -> bzr is not lossless in every case.  Having bzr on host A means
you can keep the high fidelity. :-)

> Thanks again, John.

You're welcome!

-John



More information about the bazaar mailing list