# HG changeset patch # User Pierre-Yves David # Date 1493734214 -7200 # Node ID b33bc2f37e8915505631f256d1fae527093eb71b # Parent a786240c95bd30937d2b4e33feb01fbb2cf4e3f8 obscache: have the obsstore fix empty file cachekey Before this change, the missing file and empty file returned different value. diff -r a786240c95bd -r b33bc2f37e89 hgext3rd/evolve/obscache.py --- a/hgext3rd/evolve/obscache.py Tue May 02 17:44:12 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Tue May 02 16:10:14 2017 +0200 @@ -56,6 +56,10 @@ If the index specified is higher than the current obsstore file length, cachekey will be set to None.""" + # default value + obsstoresize = 0 + keydata = '' + # try to get actual data from the obsstore try: with self.svfs('obsstore') as obsfile: obsfile.seek(0, 2) @@ -65,13 +69,14 @@ elif obsstoresize < index: return obsstoresize, None actualsize = min(index, self._obskeysize) - obsfile.seek(index - actualsize, 0) - keydata = obsfile.read(actualsize) - return obsstoresize, hashlib.sha1(keydata).digest() + if actualsize: + obsfile.seek(index - actualsize, 0) + keydata = obsfile.read(actualsize) except (OSError, IOError) as e: if e.errno != errno.ENOENT: raise - return 0, node.nullid + key = hashlib.sha1(keydata).digest() + return obsstoresize, key obsstore.__class__ = cachekeyobsstore