Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/revlog.py @ 1784:2e0a288ca93e
revalidate revlog data after locking the repo (issue132)
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Wed, 22 Feb 2006 07:26:29 +0100 |
parents | d457fec76ab0 |
children | 5ac811b720de |
comparison
equal
deleted
inserted
replaced
1783:35a05f177267 | 1784:2e0a288ca93e |
---|---|
11 """ | 11 """ |
12 | 12 |
13 from node import * | 13 from node import * |
14 from i18n import gettext as _ | 14 from i18n import gettext as _ |
15 from demandload import demandload | 15 from demandload import demandload |
16 demandload(globals(), "binascii errno heapq mdiff sha struct zlib") | 16 demandload(globals(), "binascii errno heapq mdiff os sha struct zlib") |
17 | 17 |
18 def hash(text, p1, p2): | 18 def hash(text, p1, p2): |
19 """generate a hash from the given text and its parent hashes | 19 """generate a hash from the given text and its parent hashes |
20 | 20 |
21 This hash combines both the current file contents and its history | 21 This hash combines both the current file contents and its history |
185 and can be used to implement COW semantics or the like. | 185 and can be used to implement COW semantics or the like. |
186 """ | 186 """ |
187 self.indexfile = indexfile | 187 self.indexfile = indexfile |
188 self.datafile = datafile | 188 self.datafile = datafile |
189 self.opener = opener | 189 self.opener = opener |
190 | |
191 self.indexstat = None | |
190 self.cache = None | 192 self.cache = None |
191 self.chunkcache = None | 193 self.chunkcache = None |
192 | 194 self.load() |
195 | |
196 def load(self): | |
193 try: | 197 try: |
194 i = self.opener(self.indexfile).read() | 198 f = self.opener(self.indexfile) |
195 except IOError, inst: | 199 except IOError, inst: |
196 if inst.errno != errno.ENOENT: | 200 if inst.errno != errno.ENOENT: |
197 raise | 201 raise |
198 i = "" | 202 i = "" |
203 else: | |
204 try: | |
205 st = os.fstat(f.fileno()) | |
206 except AttributeError, inst: | |
207 st = None | |
208 else: | |
209 oldst = self.indexstat | |
210 if (oldst and st.st_dev == oldst.st_dev | |
211 and st.st_ino == oldst.st_ino | |
212 and st.st_mtime == oldst.st_mtime | |
213 and st.st_ctime == oldst.st_ctime): | |
214 return | |
215 self.indexstat = st | |
216 i = f.read() | |
199 | 217 |
200 if i and i[:4] != "\0\0\0\0": | 218 if i and i[:4] != "\0\0\0\0": |
201 raise RevlogError(_("incompatible revlog signature on %s") % | 219 raise RevlogError(_("incompatible revlog signature on %s") % |
202 self.indexfile) | 220 self.indexfile) |
203 | 221 |