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