# HG changeset patch # User Pierre-Yves David # Date 1493739814 -7200 # Node ID 9f09cabe679e8082970bb1a6b72688bbefe6185c # Parent ef8beb602b418100d3968f9a6459077fd3b87e3f obscache: skip writing to disk if the data did not changed This will avoid rewriting the cache for every single transaction. diff -r ef8beb602b41 -r 9f09cabe679e hgext3rd/evolve/obscache.py --- 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"""