[MERGE] fix for a keyerror in finding least common ancestors

John Arbash Meinel john at arbash-meinel.com
Tue Aug 7 19:09:01 BST 2007


John Arbash Meinel has voted tweak.
Status is now: Conditionally approved
Comment:
What if instead of just assuming 'c' before 'd', we do something like 
'b', 'c', 'd'. So we have the option of coming before or after.

I believe the sort order is based on 'hash(key)'. Specifically:

>>> d = {'a':1, 'b':2, 'c':3, 'd':4}
>>> print d.keys()
['a', 'c', 'b', 'd']

>>> for k in d.keys():
...   print k, hash(k)
...
a -468864544
c -212863774
b -340864157
d -84863387

I'm not sure how to test it, but if you could have 3 keys, one will be 
in the middle, but I don't know if you can have all of them deleted at 
the same time.

The other possibility would be to change the:

  for candidate in active.keys()

to

   for candidate in sorted(active.keys()):

but that seems to be a bit of a performance hit, just so we can test it.

Overall, I'm happy enough with your patch, since it does fix the bug.

Maybe it would be reasonable to test both ['c', 'd'], and ['d', 'c']. 
Since we know that one will always sort before the other.


For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C46B890DA.2060209%40utoronto.ca%3E



More information about the bazaar mailing list