dirstate inventory after an add loses SHAs

John Arbash Meinel john at arbash-meinel.com
Fri Sep 7 18:59:54 BST 2007


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

Ian Clatworthy wrote:
> I'm profiling some new code that uses iter_changes as the main commit
> loop and I'm seeing something I'm not expecting. After a file is added
> and 'bzr add' is run, every file gets a cache miss and needs it's SHA
> caclulated again in dirstate.update_entry().
> 
> I've been avoiding the dirstate code until now but it looks like the
> time has come for me to dive into it. It's look like the smart_add()
> code on mutuabletree is assuming an old-style inventory and maybe
> calling write_inventory(inv) on workingtree4 is causing the problem?
> 
> Any tips on where to start looking from the dirstate gurus?
> 
> Ian C.
> 
> 

write_inventory() will indeed wipe all of the cached state out of the Dirstate.

There are 2 possibilities:

1) Look closer at "apply_inventory_delta()"

I believe that is the function that 'smart_add()' is supposed to be using. And
it needs a custom implementation for WT4.

It was written with the idea in mind that we can tell the WT that we need it to
update a couple records, without having to redo the entire inventory.

However, at the moment it is a trivial wrapper for _write_inventory() because
we never took the time to fix it.

2) Fix DirState.set_state_from_inventory, so that it is sure to re-use any
fingerprints it has lying around.

It may just be that "update_minimal" needs to be updated to preserve values.
I'm not really sure what is going on.

I do see the lines:

    def update_minimal(self, key, minikind, executable=False, fingerprint='',
                       packed_stat=None, size=0, path_utf8=None):
...
        if packed_stat is None:
            packed_stat = DirState.NULLSTAT
        entry_index, present = self._find_entry_index(key, block)
        new_details = (minikind, fingerprint, size, executable, packed_stat)

So it looks like we might be able to just update set_state_from_inventory to
pass in the old pack_stat value.

I don't see why set_state_from_inventory would be modifying every entry,
though. So it might actually be related to "set_parent_trees()".

John
=:->

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

iD8DBQFG4ZGaJdeBCYSNAAMRAnuGAJ9yvBeUhL+n7BEOaYe/+CPWx6F44QCghRc4
VaWJ3oEBi79YNOC4i2vsSuk=
=940Z
-----END PGP SIGNATURE-----



More information about the bazaar mailing list