[PATCH 4 of 7] util: make filestat.__eq__ return True if both of self and old have None stat

Yuya Nishihara yuya at tcha.org
Sat Jun 10 23:26:20 EDT 2017


On Fri, 09 Jun 2017 13:08:24 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
> # Date 1496981268 -32400
> #      Fri Jun 09 13:07:48 2017 +0900
> # Node ID c14fcdcf528768538d1557b2ce0905db4c91bb85
> # Parent  650b77396c6ea684d7ffca6c5e0921482eaffd49
> util: make filestat.__eq__ return True if both of self and old have None stat
> 
> For convenience to compare two filestat objects regardless of
> None-ness of stat field.
> 
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -1525,6 +1525,10 @@ class filestat(object):
>                      self.stat.st_ctime == old.stat.st_ctime and
>                      self.stat.st_mtime == old.stat.st_mtime)
>          except AttributeError:
> +            pass
> +        try:
> +            return self.stat is None and old.stat is None
> +        except AttributeError:
>              return False

Nit: this could be 'self.stat is old.stat'.


More information about the Mercurial-devel mailing list