Mercurial > public > mercurial-scm > hg-stable
diff mercurial/util.py @ 27576:6cd3044985c2
lrucachedict: add copy method
This diff implements the standard dict copy() method for lrucachedicts, which
will be used in the pushrebase extension to make a copy of the manifestcache.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Wed, 30 Dec 2015 13:10:53 -0800 |
parents | 4eeef1b2d689 |
children | 37df458d60c2 |
line wrap: on
line diff
--- 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.