changeset 1493:1a216cb4ee64

verify: add check for mismatch of index and data length
author Matt Mackall <mpm@selenic.com>
date Wed, 02 Nov 2005 19:26:23 -0800
parents 5f0522d31967
children 249ca10d37f4
files mercurial/localrepo.py mercurial/revlog.py
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Nov 02 18:59:40 2005 -0800
+++ b/mercurial/localrepo.py	Wed Nov 02 19:26:23 2005 -0800
@@ -1602,6 +1602,9 @@
 
         seen = {}
         self.ui.status(_("checking changesets\n"))
+        d = self.changelog.checksize()
+        if d:
+            err(_("changeset data short %d bytes") % d)
         for i in range(self.changelog.count()):
             changesets += 1
             n = self.changelog.node(i)
@@ -1631,6 +1634,9 @@
 
         seen = {}
         self.ui.status(_("checking manifests\n"))
+        d = self.manifest.checksize()
+        if d:
+            err(_("manifest data short %d bytes") % d)
         for i in range(self.manifest.count()):
             n = self.manifest.node(i)
             l = self.manifest.linkrev(n)
@@ -1685,6 +1691,10 @@
             if f == "/dev/null": continue
             files += 1
             fl = self.file(f)
+            d = fl.checksize()
+            if d:
+                err(_("%s file data short %d bytes") % (f, d))
+
             nodes = { nullid: 1 }
             seen = {}
             for i in range(fl.count()):
--- a/mercurial/revlog.py	Wed Nov 02 18:59:40 2005 -0800
+++ b/mercurial/revlog.py	Wed Nov 02 19:26:23 2005 -0800
@@ -823,3 +823,12 @@
         dfh.close()
         ifh.close()
         return node
+
+    def checksize(self):
+        expected = 0
+        if self.count():
+            expected = self.end(self.count() - 1)
+        f = self.opener(self.datafile)
+        f.seek(0, 2)
+        actual = f.tell()
+        return expected - actual