verify: avoid exception on missing file revlog
authorHenrik Stuart <hg@hstuart.dk>
Fri, 24 Apr 2009 10:44:39 +0200
changeset 8291 f5c1a9094e41
parent 8290 560af1bbfd6e
child 8292 29540554def8
verify: avoid exception on missing file revlog Previously, accessing the filelinkrevs of a specific file that happens to have already been unlinked from the filesystem, e.g. due to a partial rollback having occurred, will trigger a KeyError being raised. Co-contributor: Sune Foldager <cryo@cyanite.org>
mercurial/verify.py
--- a/mercurial/verify.py	Sun Apr 19 20:02:32 2009 +0200
+++ b/mercurial/verify.py	Fri Apr 24 10:44:39 2009 +0200
@@ -173,7 +173,17 @@
 
     files = sorted(set(filenodes) | set(filelinkrevs))
     for f in files:
-        lr = filelinkrevs[f][0]
+        try:
+            linkrevs = filelinkrevs[f]
+        except KeyError:
+            # in manifest but not in changelog
+            linkrevs = []
+
+        if linkrevs:
+            lr = linkrevs[0]
+        else:
+            lr = None
+
         try:
             fl = repo.file(f)
         except error.RevlogError, e:
@@ -191,7 +201,7 @@
         for i in fl:
             revisions += 1
             n = fl.node(i)
-            lr = checkentry(fl, i, n, seen, filelinkrevs.get(f, []), f)
+            lr = checkentry(fl, i, n, seen, linkrevs, f)
             if f in filenodes:
                 if havemf and n not in filenodes[f]:
                     err(lr, _("%s not in manifests") % (short(n)), f)