Show More
@@ -124,14 +124,34 b' class revlog:' | |||
|
124 | 124 | self.datafile = datafile |
|
125 | 125 | self.opener = opener |
|
126 | 126 | self.cache = None |
|
127 | # read the whole index for now, handle on-demand later | |
|
127 | ||
|
128 | 128 | try: |
|
129 | 129 | i = self.opener(self.indexfile).read() |
|
130 | 130 | except IOError: |
|
131 | 131 | i = "" |
|
132 | parser = lazyparser(i) | |
|
133 | self.index = lazyindex(parser) | |
|
134 | self.nodemap = lazymap(parser) | |
|
132 | ||
|
133 | if len(i) > 10000: | |
|
134 | # big index, let's parse it on demand | |
|
135 | parser = lazyparser(i) | |
|
136 | self.index = lazyindex(parser) | |
|
137 | self.nodemap = lazymap(parser) | |
|
138 | else: | |
|
139 | s = struct.calcsize(indexformat) | |
|
140 | l = len(i) / s | |
|
141 | self.index = [None] * l | |
|
142 | m = [None] * l | |
|
143 | ||
|
144 | n = 0 | |
|
145 | for f in xrange(0, len(i), s): | |
|
146 | # offset, size, base, linkrev, p1, p2, nodeid | |
|
147 | e = struct.unpack(indexformat, i[f:f + s]) | |
|
148 | m[n] = (e[6], n) | |
|
149 | self.index[n] = e | |
|
150 | n += 1 | |
|
151 | ||
|
152 | self.nodemap = dict(m) | |
|
153 | self.nodemap[nullid] = -1 | |
|
154 | ||
|
135 | 155 | |
|
136 | 156 | def tip(self): return self.node(len(self.index) - 1) |
|
137 | 157 | def count(self): return len(self.index) |
General Comments 0
You need to be logged in to leave comments.
Login now