comparison mercurial/util.py @ 33624:524b13fc711f stable

util: fix sortdict.update() to call __setitem__() on PyPy (issue5639) It appears that overriding __setitem__() doesn't work as documented on PyPy. Let's patch it as before bd0fd3ff9916. https://docs.python.org/2/library/collections.html#ordereddict-examples-and-recipes The issue was ui.configitems() wasn't ordered correctly, so the pull command was wrapped in different order.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 02 Aug 2017 22:51:19 +0900
parents 9a2ee9591acc
children 0b3fe3910ef5 86aca74a063b
comparison
equal deleted inserted replaced
33623:6788e648efcf 33624:524b13fc711f
581 581
582 def __setitem__(self, key, value): 582 def __setitem__(self, key, value):
583 if key in self: 583 if key in self:
584 del self[key] 584 del self[key]
585 super(sortdict, self).__setitem__(key, value) 585 super(sortdict, self).__setitem__(key, value)
586
587 if pycompat.ispypy:
588 # __setitem__() isn't called as of PyPy 5.8.0
589 def update(self, src):
590 if isinstance(src, dict):
591 src = src.iteritems()
592 for k, v in src:
593 self[k] = v
586 594
587 @contextlib.contextmanager 595 @contextlib.contextmanager
588 def acceptintervention(tr=None): 596 def acceptintervention(tr=None):
589 """A context manager that closes the transaction on InterventionRequired 597 """A context manager that closes the transaction on InterventionRequired
590 598