[MERGE] (0.17) Branch.revision_id_to_dotted_revno and .get_revision_id_to_revno_map

John Arbash Meinel john at arbash-meinel.com
Tue Apr 17 22:41:18 BST 2007

The recent discussions made me realize that our current method of
mapping revision_ids => revnos should be refactored into a helper
function. There are a few places that we use it, and it would be better
to pull it out so that it is tested and can be reused.

So this patch adds 2 members to Branch:

The former works like 'revision_id_to_revno' except it supports
non-mainline revisions. The latter generates (and caches) a map used by
the former.

It also updates annotate and RevisionSpec_revno to use this new map.

To make this a bit easier to test, I also refactored some of the
branch_implementation code, and updated MemoryTree with a new api

I don't have direct tests for the MemoryTree functions, because we don't
have any 'mutable_tree' or 'memory_tree' tests. (At least, nothing is
testing set_parent_trees() which is essentially the same thing as

I can rewrite things in terms of set_parent_trees(), it just makes test
setup more difficult.

I also moved TestCaseWithBranch into branch_implementations/__init__.py
since it makes more sense there than in test_branch.py. (Having a test
import from another test seems less clean than importing from
branch_implementations itself).

And I added the helper function "create_tree_with_merge()" which creates
a MemoryTree with a single merge. I think of it as an example that can
be followed to set up simple revision histories for all the tests that
are currently writing to disk when they don't need to.

I'm not trying to get this merged for 0.16, as it is an api update, so
it is more focused on 0.17. But I was looking to update some plugins,
and I realized this would have been good to have.


More information about the bazaar mailing list