Пример #1
0
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        s = self.size
        cache = None
        index = []
        nodemap = {nullid: nullrev}
        n = off = 0
        # if we're not using lazymap, always read the whole index
        data = fp.read()
        l = len(data) - s
        append = index.append
        if inline:
            cache = (0, data)
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                if e[1] < 0:
                    break
                off += e[1] + s
        else:
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                off += s

        e = list(index[0])
        type = gettype(e[0])
        e[0] = offset_type(0, type)
        index[0] = e

        return index, nodemap, cache
Пример #2
0
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        s = self.size
        cache = None
        index = []
        nodemap =  {nullid: nullrev}
        n = off = 0
        # if we're not using lazymap, always read the whole index
        data = fp.read()
        l = len(data) - s
        append = index.append
        if inline:
            cache = (0, data)
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                if e[1] < 0:
                    break
                off += e[1] + s
        else:
            while off <= l:
                e = _unpack(indexformatng, data[off:off + s])
                nodemap[e[7]] = n
                append(e)
                n += 1
                off += s

        e = list(index[0])
        type = gettype(e[0])
        e[0] = offset_type(0, type)
        index[0] = e

        return index, nodemap, cache
    def parseindex(self, fp, data, inline):
        if len(data) == _prereadsize:
            if util.openhardlinks() and not inline:
                # big index, let's parse it on demand
                parser = lazyparser(fp)
                index = lazyindex(parser)
                nodemap = lazymap(parser)
                e = list(index[0])
                type = gettype(e[0])
                e[0] = offset_type(0, type)
                index[0] = e
                return index, nodemap, None
            else:
                data += fp.read()

        # call the C implementation to parse the index data
        index, nodemap, cache = parsers.parse_index(data, inline)
        return index, nodemap, cache
Пример #4
0
    def parseindex(self, fp, data, inline):
        if len(data) == _prereadsize:
            if util.openhardlinks() and not inline:
                # big index, let's parse it on demand
                parser = lazyparser(fp)
                index = lazyindex(parser)
                nodemap = lazymap(parser)
                e = list(index[0])
                type = gettype(e[0])
                e[0] = offset_type(0, type)
                index[0] = e
                return index, nodemap, None
            else:
                data += fp.read()

        # call the C implementation to parse the index data
        index, nodemap, cache = parsers.parse_index(data, inline)
        return index, nodemap, cache
Пример #5
0
    def parseindex(self, fp, inline):
        try:
            size = util.fstat(fp).st_size
        except AttributeError:
            size = 0

        if util.openhardlinks() and not inline and size > 1000000:
            # big index, let's parse it on demand
            parser = lazyparser(fp, size)
            index = lazyindex(parser)
            nodemap = lazymap(parser)
            e = list(index[0])
            type = gettype(e[0])
            e[0] = offset_type(0, type)
            index[0] = e
            return index, nodemap, None

        data = fp.read()
        # call the C implementation to parse the index data
        index, nodemap, cache = parsers.parse_index(data, inline)
        return index, nodemap, cache