[MERGE] Packs. Kthxbye.
John Arbash Meinel
john at arbash-meinel.com
Thu Oct 18 21:19:43 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
> Your "plan_autopack_combinations" seems interesting. I'm not sure if the
> algorithm is 100% correct.
> Take this example: existing_packs = 50, 40, 12, 7, 3
> 50+40+12+7+3 = 112
> pack_distribution = 100, 10, 1, 1
> I tried to walk through what it would do, but it seems to do very weird
> when trying to add them in.
It seems I was wrong in my guess. It does what I would expect it to, just the
way the loop was written confused me.
It would probably be good to have a few more tests.
Also, I agree with Ian that returning [0, ] is a little odd. You can add
if pack_operations[-1] == [0, ]:
Which will remove it before returning.
The current algorithm ensures that you get approximately the right pack sizes.
A given repack won't pack it to more than 2x the expected size. (If you are
trying to pack to 100, and you have 2 packs of size 99, you will get one with 198.)
So you can have a test for something like:
existing = [(50, '50'), (40, '40'), (12, '12'), (7, '7'), (3, '3')]
[[102, ['50', '40', '12']], [10, ['7', '3']]]
The only thing I don't like is that these functions are defined as regular
class functions, but have 0 dependency on self. So it would be nice if they
were @staticmethod so that you wouldn't have to instantiate a repository to
Though I believe you don't prefer staticmethods for some reason.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the bazaar