mercurial/repoview.py
changeset 22282 4092d12ba18a
parent 22261 eba48f2b9b74
child 22367 c5df4af17110
equal deleted inserted replaced
22280:7eef5a87ce3f 22282:4092d12ba18a
    66 
    66 
    67     We calculate a sha1 of repo heads and the content of the obsstore and write
    67     We calculate a sha1 of repo heads and the content of the obsstore and write
    68     it to the cache. Upon reading we can easily validate by checking the hash
    68     it to the cache. Upon reading we can easily validate by checking the hash
    69     against the stored one and discard the cache in case the hashes don't match.
    69     against the stored one and discard the cache in case the hashes don't match.
    70     """
    70     """
    71     h = util.sha1(''.join(repo.heads()))
    71     h = util.sha1()
       
    72     h.update(''.join(repo.heads()))
    72     h.update(str(hash(frozenset(hideable))))
    73     h.update(str(hash(frozenset(hideable))))
    73     return h.digest()
    74     return h.digest()
    74 
    75 
    75 def trywritehiddencache(repo, hideable, hidden):
    76 def trywritehiddencache(repo, hideable, hidden):
    76     """write cache of hidden changesets to disk
    77     """write cache of hidden changesets to disk
    86         try:
    87         try:
    87             wlock = repo.wlock(wait=False)
    88             wlock = repo.wlock(wait=False)
    88             # write cache to file
    89             # write cache to file
    89             newhash = cachehash(repo, hideable)
    90             newhash = cachehash(repo, hideable)
    90             sortedset = sorted(hidden)
    91             sortedset = sorted(hidden)
    91             data = struct.pack('>%iI' % len(sortedset), *sortedset)
    92             data = struct.pack('>%ii' % len(sortedset), *sortedset)
    92             fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True)
    93             fh = repo.vfs.open(cachefile, 'w+b', atomictemp=True)
    93             fh.write(struct.pack(">H", cacheversion))
    94             fh.write(struct.pack(">H", cacheversion))
    94             fh.write(newhash)
    95             fh.write(newhash)
    95             fh.write(data)
    96             fh.write(data)
    96         except (IOError, OSError):
    97         except (IOError, OSError):
   114             newhash = cachehash(repo, hideable)
   115             newhash = cachehash(repo, hideable)
   115             if (cacheversion, oldhash) == (version, newhash):
   116             if (cacheversion, oldhash) == (version, newhash):
   116                 # cache is valid, so we can start reading the hidden revs
   117                 # cache is valid, so we can start reading the hidden revs
   117                 data = fh.read()
   118                 data = fh.read()
   118                 count = len(data) / 4
   119                 count = len(data) / 4
   119                 hidden = frozenset(struct.unpack('>%iI' % count, data))
   120                 hidden = frozenset(struct.unpack('>%ii' % count, data))
   120         return hidden
   121         return hidden
   121     finally:
   122     finally:
   122         if fh:
   123         if fh:
   123             fh.close()
   124             fh.close()
   124 
   125