make_branch_and_memory_tree is not directly substitutable for make_branch_and_tree

Bug #574980 reported by Andrew Bennetts
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Wishlist
Unassigned

Bug Description

Many tests that use make_branch_and_tree could probably in principle use make_branch_and_memory_tree, and run faster as a result.

Unfortunately, it is not a drop-in replacement. Specifically while this works:

    tree = self.make_branch_and_tree('my-tree')
    tree.commit('a commit')

This does not:

    tree = self.make_branch_and_memory_tree('my-tree')
    tree.commit('a commit')

Instead, you have to add some ugly boilerplate:

    tree = self.make_branch_and_memory_tree('my-tree')
    tree.lock_write()
    tree.add([''], ['root-id'])
    tree.commit('a commit')
    tree.unlock()

That's a lot of lines to say "create a tree that has a commit."

Andrew Bennetts (spiv)
tags: added: test
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 574980] Re: make_branch_and_memory_tree is not directly substitutable for make_branch_and_tree

Have you seen TreeBuilder?

Revision history for this message
John A Meinel (jameinel) wrote : Re: [Bug 574980] Re: make_branch_and_memory_tree is not directly substitutable for make_branch_and_tree

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

Robert Collins wrote:
> Have you seen TreeBuilder?
>

Well, there is the ugliness, and there is the problem with
"make_branch_and_memory_tree" not really creating memory structures when
using TestCaseWithTransport (vs TestCaseWithMemoryTransport), and having
to do some voodoo with attributes and MemoryTransportServer, IIRC. (I'm
sure I don't remember correctly, or I would give more details... :)

John
=:->

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

iEYEARECAAYFAkvgM80ACgkQJdeBCYSNAAM/9ACfcWnSo/w55p+RzDDMnDv9GkX9
2m4An3tXgAX5UQeHxzwS1kLHJPB8ygwF
=9f+8
-----END PGP SIGNATURE-----

Revision history for this message
Andrew Bennetts (spiv) wrote :

Robert Collins wrote:
> Have you seen TreeBuilder?

Not really — but in the case that inspired this bug report I actually
don't care about the tree contents at all. For the tests I was writing
and updating I actually just wanted to make a revision without caring
about any details except its revid and which repo object it was created
in.

I suppose BranchBuilder might have been a better fit, but the existing
tests were using make_branch_and_tree.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 574980] Re: make_branch_and_memory_tree is not directly substitutable for make_branch_and_tree

I think branch builder would have been a better fit for you then.

Vincent Ladeuil (vila)
tags: added: selftest
removed: test
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.