[PATCH 4 of 6] verify: avoid exception on missing file revlog

Brodie Rao dackze at gmail.com
Tue Apr 21 14:57:18 CDT 2009


On Apr 21, 2009, at 1:33 PM, Henrik Stuart wrote:

> # HG changeset patch
> # User Henrik Stuart <hg at hstuart.dk>
> # Date 1240224937 -7200
> # Node ID 67570c919a84ff2d067af019a47beb8a2ac97ded
> # Parent  bdd6ec1c2f1c66ef7afc7ae7ce1bc503ede12c9f
> 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 at cyanite.org>
>
> diff -r bdd6ec1c2f1c -r 67570c919a84 mercurial/verify.py
> --- a/mercurial/verify.py	Sun Apr 19 20:02:32 2009 +0200
> +++ b/mercurial/verify.py	Mon Apr 20 12:55:37 2009 +0200
> @@ -173,6 +173,10 @@
>
>     files = util.sort(util.unique(filenodes.keys() +  
> filelinkrevs.keys()))
>     for f in files:
> +        if not filelinkrevs.has_key(f):

Could you use "if f in filelinkrevs:" instead? dict.has_key is  
deprecated in Python 2.6, and the in keyword is a bit more readable.

> +            err(None, _("missing revlog for file '%s'") % f)
> +            continue
> +
>         lr = filelinkrevs[f][0]
>         try:
>             fl = repo.file(f)



More information about the Mercurial-devel mailing list