?discover and lock branches

John Arbash Meinel john at arbash-meinel.com
Sat Apr 11 18:32:04 BST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


...

> Let me make sure I understand. 
> The .bzr directory of a standalone barnch has 'branch' and 'repository'
> directories.
> The .bzr directory of a shared repo has a 'repository' directory (and no
> 'branch' directory).
> The .bzr directory of a branch in a shared repo has a 'branch' directory
> (bit no 'repository' directory).
> Every .bzr directory has a 'branch-lock' directory.
> I just tried it, and that seems right.

All true.

> 
> So if I want backup just a single branch (shared or standalone) all I
> need to do is lock it and copy it.
> If I want to back up a shared repo, I need to lock all of its "children"
> branches first, then lock itself and then copy them all.
> 
> Did I get that right?
> 
> I really appreciate your help!
> 
> -M

You don't need to "lock" an object to copy it. (Assuming the statement
that the lock you would be taking is a "write_lock". In bzr, all 'read
locks' are no-ops (except for some Workingtree locks).

If you want to copy a group of branches, all you really need is the
'Branch.last_revision()' information. So if I was doing something like
this I would:

1) Iterate to find all Branches, and their basic information
(Branch.last_revision(), etc). This can be done purely with a 'read lock'.
2) Fetch all the revisions from the repository to another repository
3) Create branches in the target repository with the information found
in step 1.

Now, you can do this a bit more "concurrently" by just doing:

for path in `bzr branches`:
  bzr branch $path $target_repo/$path

This effectively just read locks one branch at a time, and copies the
data out.

The only reason you might want to take out write locks on the branches
is if there is 'inter-branch' information that you need to preserve.
(lib1 @ revno 20 should exactly match lib2 @ revno 256, so you want to
lock out someone committing to one branch while you are copying the other.)

However, if you have that constraint, it is much better to record that
at a different level. (That is what 'nested-trees' are about, but you
can do it in a variety of ways.)

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkng1BQACgkQJdeBCYSNAAMRoQCfWcirPfZh9sgF65qczK2GJwab
I6sAnR8TtccPnYLk19zM/SZwLLzD6MrE
=xYqv
-----END PGP SIGNATURE-----



More information about the bazaar mailing list