diff -r 44f717c87903 -r 6cd3044985c2 mercurial/util.py --- a/mercurial/util.py Thu Dec 31 09:55:56 2015 +0100 +++ b/mercurial/util.py Wed Dec 30 13:10:53 2015 -0800 @@ -622,6 +622,15 @@ self._cache.clear() + def copy(self): + result = lrucachedict(self._capacity) + n = self._head.prev + # Iterate in oldest-to-newest order, so the copy has the right ordering + for i in range(len(self._cache)): + result[n.key] = n.value + n = n.prev + return result + def _movetohead(self, node): """Mark a node as the newest, making it the new head.