[MERGE] Inventory-free checkout

John Arbash Meinel john at arbash-meinel.com
Thu Jan 3 22:32:15 GMT 2008


Aaron Bentley wrote:
> John Arbash Meinel wrote:
>> Aaron Bentley wrote:
>> I also see this comment:
>>     # should be deprecated - this is slow and in any case treating them as a
>>     # container is (we now know) bad style -- mbp 20070302
>>     ## @deprecated_method(zero_fifteen)
>>     def __iter__(self):
> 
>> 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.
> 
>> Actually, looking at the implementation, it has to go to
>> "self._inventory" and then stat every file in the inventory to see if it
>> really does exist.
> 
>> So unless list(wt) does something else than list(wt.__iter__()), we
>> really need to do something different here.
> 
> Well, I was planning on doing
> 
> for num, _unused in enumerate(wt):
>     if num > 1:
>         raise Foo()
> 
> But now it's sounding like you think iterating through wt is the wrong API.
> 

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.

You have the overhead of build up an Inventory, and the overhead of all
of the InventoryEntries (in theory you could only build up ones that you
actually iterate). And then you have the overhead of statting the
filesystem.

> Perhaps I should mention that, for reasons I do not understand, the
> WorkingTree being passed in has a file-id for .bzrignore, but no file.
> So if I were to do iter_all_file_ids, an exception would be raised.
> 
> Aaron

Well, why was it succeeding in the past? If you were doing
"len(wt.inventory) > 1" then you would have had a failure, since
.bzrignore would have an entry.

I would investigate it further, because obviously something is wrong.
The old code didn't check the filesystem and succeeded. I wouldn't
really want to start making it a requirement.

It sounds like it might be one of those cases where the in-memory
inventory is out of sync with the on-disk one. And your refactoring is
causing something to be created at a different time.

Also, as your changes are meant to make it so that we don't need to
create an Inventory, using an api that goes to wt._inventory seems wrong.

Maybe we would want a "WT.is_empty()" function, or WT.is_populated().

John
=:->





More information about the bazaar mailing list