Mercurial > hg-stable
changeset 8641:33686ef26f04
revlog: move stat inside lazyparser
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 27 May 2009 14:44:51 -0500 |
parents | 8536119f2f94 |
children | 2ed353a413b1 |
files | mercurial/revlog.py |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Mon May 25 12:48:15 2009 -0500 +++ b/mercurial/revlog.py Wed May 27 14:44:51 2009 -0500 @@ -119,7 +119,11 @@ # available. it keeps file handle open, which make it not possible # to break hardlinks on local cloned repos. - def __init__(self, dataf, size): + def __init__(self, dataf): + try: + size = util.fstat(dataf).st_size + except AttributeError: + size = 0 self.dataf = dataf self.s = struct.calcsize(indexformatng) self.datasize = size @@ -362,15 +366,10 @@ self.size = struct.calcsize(indexformatng) def parseindex(self, fp, data, inline): - size = len(data) - if size == _prereadsize: + if len(data) == _prereadsize: if util.openhardlinks() and not inline: - try: - size = util.fstat(fp).st_size - except AttributeError: - size = 0 # big index, let's parse it on demand - parser = lazyparser(fp, size) + parser = lazyparser(fp) index = lazyindex(parser) nodemap = lazymap(parser) e = list(index[0])