[PATCH] util: also catch IndexError

Augie Fackler raf at durin42.com
Wed Oct 14 09:29:02 CDT 2015


On Tue, Oct 13, 2015 at 04:08:26PM -0700, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean at farley.io>
> # Date 1444777530 25200
> #      Tue Oct 13 16:05:30 2015 -0700
> # Node ID ef250ea05243630e486d04fa98d6481b25d32135
> # Parent  a38924f7680c6b7d95e14ade999c35748c9dcafd
> util: also catch IndexError
>
> This makes life so, so much easier for hgwatchman, which provides a named tuple
> but throws an IndexError instead of a TypeError.

Can we fix hgwatchman behavior to actually match what stat is returning?

>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -961,11 +961,11 @@ def statmtimesec(st):
>      to represent nanoseconds. If 'nsec' is close to 1 sec, 'int(st.st_mtime)'
>      can be 'sec + 1'. (issue4836)
>      """
>      try:
>          return st[stat.ST_MTIME]
> -    except TypeError:
> +    except (TypeError, IndexError):
>          # osutil.stat doesn't allow index access and its st_mtime is int
>          return st.st_mtime
>
>  # File system features
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list