--- a/mercurial/localrepo.py Mon Jan 30 13:01:16 2006 +1300
+++ b/mercurial/localrepo.py Mon Jan 30 19:34:35 2006 +1300
@@ -1679,11 +1679,17 @@
self.ui.warn(msg + "\n")
errors[0] += 1
+ def checksize(obj, name):
+ d = obj.checksize()
+ if d[0]:
+ err(_("%s data length off by %d bytes") % (name, d[0]))
+ if d[1]:
+ err(_("%s index contains %d extra bytes") % (name, d[1]))
+
seen = {}
self.ui.status(_("checking changesets\n"))
- d = self.changelog.checksize()
- if d:
- err(_("changeset data short %d bytes") % d)
+ checksize(self.changelog, "changelog")
+
for i in range(self.changelog.count()):
changesets += 1
n = self.changelog.node(i)
@@ -1713,9 +1719,8 @@
seen = {}
self.ui.status(_("checking manifests\n"))
- d = self.manifest.checksize()
- if d:
- err(_("manifest data short %d bytes") % d)
+ checksize(self.manifest, "manifest")
+
for i in range(self.manifest.count()):
n = self.manifest.node(i)
l = self.manifest.linkrev(n)
@@ -1771,9 +1776,7 @@
continue
files += 1
fl = self.file(f)
- d = fl.checksize()
- if d:
- err(_("%s file data short %d bytes") % (f, d))
+ checksize(fl, f)
nodes = {nullid: 1}
seen = {}
--- a/mercurial/revlog.py Mon Jan 30 13:01:16 2006 +1300
+++ b/mercurial/revlog.py Mon Jan 30 19:34:35 2006 +1300
@@ -213,7 +213,7 @@
m = [None] * l
n = 0
- for f in xrange(0, len(i), s):
+ for f in xrange(0, l * s, s):
# offset, size, base, linkrev, p1, p2, nodeid
e = struct.unpack(indexformat, i[f:f + s])
m[n] = (e[6], n)
@@ -841,14 +841,29 @@
expected = 0
if self.count():
expected = self.end(self.count() - 1)
+
try:
f = self.opener(self.datafile)
f.seek(0, 2)
actual = f.tell()
- return expected - actual
+ dd = actual - expected
except IOError, inst:
- if inst.errno == errno.ENOENT:
- return 0
- raise
+ if inst.errno != errno.ENOENT:
+ raise
+ dd = 0
+
+ try:
+ f = self.opener(self.indexfile)
+ f.seek(0, 2)
+ actual = f.tell()
+ s = struct.calcsize(indexformat)
+ i = actual / s
+ di = actual - (i * s)
+ except IOError, inst:
+ if inst.errno != errno.ENOENT:
+ raise
+ di = 0
+
+ return (dd, di)