Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 8641:33686ef26f04
revlog: move stat inside lazyparser
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 27 May 2009 14:44:51 -0500 |
parents | 7659eecd9da2 |
children | 648af8a6aa41 |
comparison
equal
deleted
inserted
replaced
8640:8536119f2f94 | 8641:33686ef26f04 |
---|---|
117 | 117 |
118 # lazyparser is not safe to use on windows if win32 extensions not | 118 # lazyparser is not safe to use on windows if win32 extensions not |
119 # available. it keeps file handle open, which make it not possible | 119 # available. it keeps file handle open, which make it not possible |
120 # to break hardlinks on local cloned repos. | 120 # to break hardlinks on local cloned repos. |
121 | 121 |
122 def __init__(self, dataf, size): | 122 def __init__(self, dataf): |
123 try: | |
124 size = util.fstat(dataf).st_size | |
125 except AttributeError: | |
126 size = 0 | |
123 self.dataf = dataf | 127 self.dataf = dataf |
124 self.s = struct.calcsize(indexformatng) | 128 self.s = struct.calcsize(indexformatng) |
125 self.datasize = size | 129 self.datasize = size |
126 self.l = size/self.s | 130 self.l = size/self.s |
127 self.index = [None] * self.l | 131 self.index = [None] * self.l |
360 class revlogio(object): | 364 class revlogio(object): |
361 def __init__(self): | 365 def __init__(self): |
362 self.size = struct.calcsize(indexformatng) | 366 self.size = struct.calcsize(indexformatng) |
363 | 367 |
364 def parseindex(self, fp, data, inline): | 368 def parseindex(self, fp, data, inline): |
365 size = len(data) | 369 if len(data) == _prereadsize: |
366 if size == _prereadsize: | |
367 if util.openhardlinks() and not inline: | 370 if util.openhardlinks() and not inline: |
368 try: | |
369 size = util.fstat(fp).st_size | |
370 except AttributeError: | |
371 size = 0 | |
372 # big index, let's parse it on demand | 371 # big index, let's parse it on demand |
373 parser = lazyparser(fp, size) | 372 parser = lazyparser(fp) |
374 index = lazyindex(parser) | 373 index = lazyindex(parser) |
375 nodemap = lazymap(parser) | 374 nodemap = lazymap(parser) |
376 e = list(index[0]) | 375 e = list(index[0]) |
377 type = gettype(e[0]) | 376 type = gettype(e[0]) |
378 e[0] = offset_type(0, type) | 377 e[0] = offset_type(0, type) |