Show More
@@ -124,14 +124,34 b' class revlog:' | |||||
124 | self.datafile = datafile |
|
124 | self.datafile = datafile | |
125 | self.opener = opener |
|
125 | self.opener = opener | |
126 | self.cache = None |
|
126 | self.cache = None | |
127 | # read the whole index for now, handle on-demand later |
|
127 | ||
128 | try: |
|
128 | try: | |
129 | i = self.opener(self.indexfile).read() |
|
129 | i = self.opener(self.indexfile).read() | |
130 | except IOError: |
|
130 | except IOError: | |
131 | i = "" |
|
131 | i = "" | |
|
132 | ||||
|
133 | if len(i) > 10000: | |||
|
134 | # big index, let's parse it on demand | |||
132 | parser = lazyparser(i) |
|
135 | parser = lazyparser(i) | |
133 | self.index = lazyindex(parser) |
|
136 | self.index = lazyindex(parser) | |
134 | self.nodemap = lazymap(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 | def tip(self): return self.node(len(self.index) - 1) |
|
156 | def tip(self): return self.node(len(self.index) - 1) | |
137 | def count(self): return len(self.index) |
|
157 | def count(self): return len(self.index) |
General Comments 0
You need to be logged in to leave comments.
Login now