# HG changeset patch # User Henrik Stuart # Date 2009-04-24 08:44:39 # Node ID f5c1a9094e4103dd888f1c89761a46d2c1a51767 # Parent 560af1bbfd6e0f5c435b738e31bbf48964c17ed5 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 diff --git a/mercurial/verify.py b/mercurial/verify.py --- a/mercurial/verify.py +++ b/mercurial/verify.py @@ -173,7 +173,17 @@ def _verify(repo): 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 @@ def _verify(repo): 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)