changeset 8291:f5c1a9094e41

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>
author Henrik Stuart <hg@hstuart.dk>
date Fri, 24 Apr 2009 10:44:39 +0200
parents 560af1bbfd6e
children 29540554def8
files mercurial/verify.py
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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)