[PATCH] dirstate: fix generator/list error when using python 2.7

Benoit Boissinot bboissin at gmail.com
Sun Feb 10 18:37:56 CST 2013


On Sun, Feb 10, 2013 at 9:44 PM, Durham Goode <durham at fb.com> wrote:

> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1360527819 28800
> # Node ID 9c384e0ef7f5c860ea774bbdc5e0c30e3e7421e8
> # Parent  013fcd112f13f31a35ea6a40d8cd1c6923cdaf20
> dirstate: fix generator/list error when using python 2.7
>
> util.statfiles returns a generator on python 2.7 with c extensions
> disabled.
> This caused util.statfiles(...) [0] to break in tests. Since we're only
> stat'ing one file, I just changed it to call lstat directly.
>
> diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
> --- a/mercurial/dirstate.py
> +++ b/mercurial/dirstate.py
> @@ -687,7 +687,11 @@
>                      # Report ignored items in the dmap as long as they
> are not
>                      # under a symlink directory.
>                      if ignore(nf) and audit_path.check(nf):
> -                        results[nf] = util.statfiles([join(nf)])[0]
> +                        try:
> +                            results[nf] = lstat(join(nf))
> +                        except OSError:
> +                            # file doesn't exist
>

If that's what you actually want to catch (like what was done previously),
you need to check errno for ENOENT


> +                            results[nf] = None
>                      else:
>                          # It's either missing or under a symlink directory
>                          results[nf] = None
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130211/7e745ceb/attachment.html>


More information about the Mercurial-devel mailing list