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

login
register
mail settings
Submitter Katsunori FUJIWARA
Date June 9, 2017, 4:08 a.m.
Message ID <c14fcdcf528768538d15.1496981304@speaknoevil>
Download mbox | patch
Permalink /patch/21263/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - June 9, 2017, 4:08 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@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.
Yuya Nishihara - June 11, 2017, 3:26 a.m.
On Fri, 09 Jun 2017 13:08:24 +0900, FUJIWARA Katsunori wrote:
> # HG changeset patch
> # User FUJIWARA Katsunori <foozy@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'.
Katsunori FUJIWARA - June 11, 2017, 9:51 p.m.
At Sun, 11 Jun 2017 12:26:20 +0900,
Yuya Nishihara wrote:
> 
> On Fri, 09 Jun 2017 13:08:24 +0900, FUJIWARA Katsunori wrote:
> > # HG changeset patch
> > # User FUJIWARA Katsunori <foozy@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'.
> 

Ah, you are right! Should I follow up for this change ?
Yuya Nishihara - June 12, 2017, 12:23 p.m.
On Mon, 12 Jun 2017 06:51:52 +0900, FUJIWARA Katsunori wrote:
> At Sun, 11 Jun 2017 12:26:20 +0900,
> Yuya Nishihara wrote:
> > 
> > On Fri, 09 Jun 2017 13:08:24 +0900, FUJIWARA Katsunori wrote:
> > > # HG changeset patch
> > > # User FUJIWARA Katsunori <foozy@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'.
> > 
> 
> Ah, you are right! Should I follow up for this change ?

This is just a cosmetic issue. If you prefer my version, please send a follow
up.

Patch

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
 
     def isambig(self, old):