Show More
@@ -35,19 +35,28 b' class revlog:' | |||||
35 | self.index = [] |
|
35 | self.index = [] | |
36 | self.opener = opener |
|
36 | self.opener = opener | |
37 | self.cache = None |
|
37 | self.cache = None | |
38 | self.nodemap = {nullid: -1} |
|
|||
39 | # read the whole index for now, handle on-demand later |
|
38 | # read the whole index for now, handle on-demand later | |
40 | try: |
|
39 | try: | |
41 | n = 0 |
|
40 | n = 0 | |
42 | i = self.opener(self.indexfile).read() |
|
41 | i = self.opener(self.indexfile).read() | |
43 | s = struct.calcsize(indexformat) |
|
42 | s = struct.calcsize(indexformat) | |
|
43 | ||||
|
44 | # preallocate arrays | |||
|
45 | l = len(i)/s | |||
|
46 | self.index = [None] * l | |||
|
47 | m = [None] * l | |||
|
48 | ||||
44 | for f in xrange(0, len(i), s): |
|
49 | for f in xrange(0, len(i), s): | |
45 | # offset, size, base, linkrev, p1, p2, nodeid |
|
50 | # offset, size, base, linkrev, p1, p2, nodeid | |
46 | e = struct.unpack(indexformat, i[f:f + s]) |
|
51 | e = struct.unpack(indexformat, i[f:f + s]) | |
47 |
self. |
|
52 | self.index[n] = e | |
48 | self.index.append(e) |
|
53 | m[n] = (e[6], n) | |
49 | n += 1 |
|
54 | n += 1 | |
50 | except IOError: pass |
|
55 | ||
|
56 | self.nodemap = dict(m) | |||
|
57 | except IOError: | |||
|
58 | self.nodemap = {} | |||
|
59 | self.nodemap[nullid] = -1 | |||
51 |
|
60 | |||
52 | def tip(self): return self.node(len(self.index) - 1) |
|
61 | def tip(self): return self.node(len(self.index) - 1) | |
53 | def count(self): return len(self.index) |
|
62 | def count(self): return len(self.index) | |
@@ -87,6 +96,9 b' class revlog:' | |||||
87 | def diff(self, a, b): |
|
96 | def diff(self, a, b): | |
88 | return mdiff.textdiff(a, b) |
|
97 | return mdiff.textdiff(a, b) | |
89 |
|
98 | |||
|
99 | def patches(self, t, pl): | |||
|
100 | return mdiff.patches(t, pl) | |||
|
101 | ||||
90 | def revision(self, node): |
|
102 | def revision(self, node): | |
91 | if node == nullid: return "" |
|
103 | if node == nullid: return "" | |
92 | if self.cache and self.cache[0] == node: return self.cache[2] |
|
104 | if self.cache and self.cache[0] == node: return self.cache[2] | |
@@ -388,7 +400,7 b' class revlog:' | |||||
388 | dfh.flush() |
|
400 | dfh.flush() | |
389 | ifh.flush() |
|
401 | ifh.flush() | |
390 | text = self.revision(chain) |
|
402 | text = self.revision(chain) | |
391 | text = self.patch(text, delta) |
|
403 | text = self.patches(text, [delta]) | |
392 | chk = self.addrevision(text, transaction, link, p1, p2) |
|
404 | chk = self.addrevision(text, transaction, link, p1, p2) | |
393 | if chk != node: |
|
405 | if chk != node: | |
394 | raise "consistency error adding group" |
|
406 | raise "consistency error adding group" |
General Comments 0
You need to be logged in to leave comments.
Login now