[MERGE/RFC] 'PackCollection._remove_pack_from_memory()' removes the entry from .packs

John Arbash Meinel john at arbash-meinel.com
Sun Oct 26 15:32:03 GMT 2008


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

I'm trying to decide if the current behavior is correct or an accident,
but there are no direct tests for '_remove_pack_from_memory()'.

At the moment, the function is defined as:
    def _remove_pack_from_memory(self, pack):
        """Remove pack from the packs accessed by this repository.

        Only affects memory state, until self._save_pack_names() is invoked.
        """
        self._names.pop(pack.name)
        self._packs_by_name.pop(pack.name)
        self._remove_pack_indices(pack)


Which removes it from the 'by-name' structures, and removes the indices.

However, there is another member, specifically:

  RepositoryPackCollection.packs

Which is a list of Pack objects.

This list does *not* get updated when you call _remove_pack_from_memory.
So if you do:

>>> repo = Repository.open('.')
>>> print len(repo._pack_collection.packs)
3
>>> repo.pack()
>>> print len(repo._pack_collection.packs)
4

While on the other hand:
>>> print len(repo._pack_collection.all_packs())
1

Also, calling "RepoPackCollection.add_pack_to_memory()" *does* do:
        self.packs.append(pack)

Which makes me feel that _remove_pack_from_memory() should be symmetrical.

I'm running into this because in my testing I was passing
PackCollection.packs directly to Packer, while the existing code goes
through PackCollection.all_packs()

Anyway, the fix is trivial and attached. I just didn't know what the
contents of RepositoryPackCollection.packs() should be.

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

iEYEARECAAYFAkkEjXMACgkQJdeBCYSNAAPv/wCdFkzbfg+zv4Byy74OXljbi0U7
aXEAn1Sno0h2zNb3xsscfTF2NFw6DsyA
=5Xah
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: remove_pack.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20081026/3cc088cc/attachment.diff 


More information about the bazaar mailing list