##// END OF EJS Templates
Simplify integrity checking...
mpm@selenic.com -
r26:9cf83bf9 default
parent child Browse files
Show More
@@ -39,7 +39,7 b' class revlog:'
39 i = self.opener(self.indexfile).read()
39 i = self.opener(self.indexfile).read()
40 s = struct.calcsize(indexformat)
40 s = struct.calcsize(indexformat)
41 for f in range(0, len(i), s):
41 for f in range(0, len(i), s):
42 # offset, size, base, linkrev, p1, p2, nodeid, changeset
42 # offset, size, base, linkrev, p1, p2, nodeid
43 e = struct.unpack(indexformat, i[f:f + s])
43 e = struct.unpack(indexformat, i[f:f + s])
44 self.nodemap[e[6]] = n
44 self.nodemap[e[6]] = n
45 self.index.append(e)
45 self.index.append(e)
@@ -48,7 +48,7 b' class revlog:'
48
48
49 def tip(self): return self.node(len(self.index) - 1)
49 def tip(self): return self.node(len(self.index) - 1)
50 def count(self): return len(self.index)
50 def count(self): return len(self.index)
51 def node(self, rev): return rev < 0 and nullid or self.index[rev][6]
51 def node(self, rev): return (rev < 0) and nullid or self.index[rev][6]
52 def rev(self, node): return self.nodemap[node]
52 def rev(self, node): return self.nodemap[node]
53 def linkrev(self, node): return self.index[self.nodemap[node]][3]
53 def linkrev(self, node): return self.index[self.nodemap[node]][3]
54 def parents(self, node):
54 def parents(self, node):
@@ -103,8 +103,8 b' class revlog:'
103 last = last + s
103 last = last + s
104
104
105 (p1, p2) = self.parents(node)
105 (p1, p2) = self.parents(node)
106 if self.node(rev) != hash(text, p1, p2):
106 if node != hash(text, p1, p2):
107 raise "Consistency check failed on %s:%d" % (self.datafile, rev)
107 raise "integrity check failed on %s:%d" % (self.datafile, rev)
108
108
109 self.cache = (node, rev, text)
109 self.cache = (node, rev, text)
110 return text
110 return text
@@ -123,14 +123,6 b' class revlog:'
123 start = self.start(self.base(t))
123 start = self.start(self.base(t))
124 end = self.end(t)
124 end = self.end(t)
125 prev = self.revision(self.tip())
125 prev = self.revision(self.tip())
126 if 0:
127 dd = self.diff(prev, text)
128 tt = self.patch(prev, dd)
129 if tt != text:
130 print prev
131 print text
132 print tt
133 raise "diff+patch failed"
134 data = compress(self.diff(prev, text))
126 data = compress(self.diff(prev, text))
135
127
136 # full versions are inserted when the needed deltas
128 # full versions are inserted when the needed deltas
@@ -151,9 +143,9 b' class revlog:'
151 self.nodemap[node] = n
143 self.nodemap[node] = n
152 entry = struct.pack(indexformat, *e)
144 entry = struct.pack(indexformat, *e)
153
145
154 transaction.add(self.datafile, e[0] - 1)
146 transaction.add(self.datafile, e[0])
155 self.opener(self.datafile, "a").write(data)
147 self.opener(self.datafile, "a").write(data)
156 transaction.add(self.indexfile, (n + 1) * len(entry) - 1)
148 transaction.add(self.indexfile, (n + 1) * len(entry))
157 self.opener(self.indexfile, "a").write(entry)
149 self.opener(self.indexfile, "a").write(entry)
158
150
159 self.cache = (node, n, text)
151 self.cache = (node, n, text)
General Comments 0
You need to be logged in to leave comments. Login now