Mercurial > evolve
changeset 2309:9f09cabe679e
obscache: skip writing to disk if the data did not changed
This will avoid rewriting the cache for every single transaction.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 02 May 2017 17:43:34 +0200 |
parents | ef8beb602b41 |
children | 26d638e419df |
files | hgext3rd/evolve/obscache.py |
diffstat | 1 files changed, 8 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obscache.py Tue May 02 16:19:05 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Tue May 02 17:43:34 2017 +0200 @@ -205,6 +205,7 @@ # - obsstore-file-size (in bytes), # - obsstore "cache key" self._cachekey = None + self._ondiskkey = None self._data = bytearray() def get(self, rev): @@ -302,7 +303,7 @@ """save the data to disk""" # XXX it happens that the obsstore is (buggilly) always up to date on disk - if self._cachekey is None or self._cachekey == emptykey: + if self._cachekey is None or self._cachekey == self._ondiskkey: return with repo.vfs(self._filepath, 'w', atomictemp=True) as cachefile: @@ -317,11 +318,12 @@ data = repo.vfs.tryread(self._filepath) if not data: self._cachekey = emptykey - return - - headersize = struct.calcsize(self._headerformat) - self._cachekey = struct.unpack(self._headerformat, data[:headersize]) - self._data = bytearray(data[headersize:]) + self._data = bytearray() + else: + headersize = struct.calcsize(self._headerformat) + self._cachekey = struct.unpack(self._headerformat, data[:headersize]) + self._data = bytearray(data[headersize:]) + self._ondiskkey = self._cachekey def _computeobsoleteset(orig, repo): """the set of obsolete revisions"""