comparison mercurial/util.py @ 30854:0126e422450e stable

util: make sortdict.keys() return a copy dict.keys() is documented to return a copy, so it's surprising that sortdict.keys() did not. I noticed this because we have an extension that calls readlocaltags(). That method tries to remove any tags that point to non-existent revisions (most likely stripped). However, since it's unintentionally working on the instance it's modifying, it sometimes fails to remove tags when there are multiple bad tags in a row. This was not caught because localrepo.tags() does an additional layer of filtering. sortdict is also used in other places, but I have not checked whether its keys() and/or __delitem__() methods are used there.
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 30 Jan 2017 22:58:56 -0800
parents 7005c03f7387
children 3a4c0905f357
comparison
equal deleted inserted replaced
30853:312b861924c8 30854:0126e422450e
548 try: 548 try:
549 self._list.remove(key) 549 self._list.remove(key)
550 except ValueError: 550 except ValueError:
551 pass 551 pass
552 def keys(self): 552 def keys(self):
553 return self._list 553 return self._list[:]
554 def iterkeys(self): 554 def iterkeys(self):
555 return self._list.__iter__() 555 return self._list.__iter__()
556 def iteritems(self): 556 def iteritems(self):
557 for k in self._list: 557 for k in self._list:
558 yield k, self[k] 558 yield k, self[k]