[MERGE] Inventory-free checkout

John Arbash Meinel john at arbash-meinel.com
Wed Feb 27 15:09:09 GMT 2008


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

Aaron Bentley wrote:
| John Arbash Meinel wrote:
|> Aaron Bentley wrote:
|>> John Arbash Meinel wrote:
|>>> So list(wt) should actually be raising a DeprecationError.
|>> I saw that too, but I need that functionality.  So the only reasons to
|>> deprecate it would be to change the name or return type.
|>>
|> You seem to only *need* to know if there is more than just a root.
|> Having to build up the inventory and then stat the whole filesystem
|> seems like a bad way to find that out.
|
| That's not what I'm doing.  There is more than one implementation of
| WorkingTree.__iter__, and the WorkingTree4.__iter__ implementation uses
| the dirstate directly, not Inventory.
|
| I was very careful to make sure that at no time was an inventory
| generated.  I set up pdb to break at WorkingTree4._make_inventory.  I
| fixed all the callers until there were none left.
|


So the contentious point was this:
- -    if len(wt.inventory) > 1:  # more than just a root
+    if len(list(wt)) > 1:  # more than just a root
~         raise errors.WorkingTreeAlreadyPopulated(base=wt.basedir)
~     file_trans_id = {}
~     top_pb = bzrlib.ui.ui_factory.nested_progress_bar()

As that 'list()' will create entries for the whole tree and then only cares if
there is >1. Having given it some space we have:

1) You aren't supposed to be calling this function when you have more than just
a root (since it is an error to do so). It seems fine to take a bit longer in an
error condition, as long as the common case is fast.

2) We could do something like:
try:
~  counter = iter(wt)
~  counter.next()
~  counter.next()
except StopIteration:
~  # There are < 2 nodes, so it is safe to build here, at most there is a root
else:
~  # There are >= 2 entries, the working tree is populated
~  raise errors.WorkingTree...

Either way is fine, and I believe Aaron and I agreed on the rest of the patch.

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

iD8DBQFHxX0UJdeBCYSNAAMRAiRIAJwOH88pAQcwnZLj5RpCjDBU6i/FHgCginZu
U8bf77Bn6zvOjbNvqgm858w=
=9Kxw
-----END PGP SIGNATURE-----



More information about the bazaar mailing list