mercurial/posix.py
changeset 49815 464fe8b8f474
parent 49812 58dff81ffba1
child 49816 ae93ada06454
equal deleted inserted replaced
49814:1d1b244a91b6 49815:464fe8b8f474
    18 import sys
    18 import sys
    19 import tempfile
    19 import tempfile
    20 import unicodedata
    20 import unicodedata
    21 
    21 
    22 from typing import (
    22 from typing import (
       
    23     Any,
    23     Iterable,
    24     Iterable,
    24     Iterator,
    25     Iterator,
    25     List,
    26     List,
    26     NoReturn,
    27     NoReturn,
    27     Optional,
    28     Optional,
   670     """
   671     """
   671     pass
   672     pass
   672 
   673 
   673 
   674 
   674 class cachestat:
   675 class cachestat:
   675     def __init__(self, path):
   676     def __init__(self, path: bytes) -> None:
   676         self.stat = os.stat(path)
   677         self.stat = os.stat(path)
   677 
   678 
   678     def cacheable(self):
   679     def cacheable(self) -> bool:
   679         return bool(self.stat.st_ino)
   680         return bool(self.stat.st_ino)
   680 
   681 
   681     __hash__ = object.__hash__
   682     __hash__ = object.__hash__
   682 
   683 
   683     def __eq__(self, other):
   684     def __eq__(self, other: Any) -> bool:
   684         try:
   685         try:
   685             # Only dev, ino, size, mtime and atime are likely to change. Out
   686             # Only dev, ino, size, mtime and atime are likely to change. Out
   686             # of these, we shouldn't compare atime but should compare the
   687             # of these, we shouldn't compare atime but should compare the
   687             # rest. However, one of the other fields changing indicates
   688             # rest. However, one of the other fields changing indicates
   688             # something fishy going on, so return False if anything but atime
   689             # something fishy going on, so return False if anything but atime
   699                 and self.stat[stat.ST_CTIME] == other.stat[stat.ST_CTIME]
   700                 and self.stat[stat.ST_CTIME] == other.stat[stat.ST_CTIME]
   700             )
   701             )
   701         except AttributeError:
   702         except AttributeError:
   702             return False
   703             return False
   703 
   704 
   704     def __ne__(self, other):
   705     def __ne__(self, other: Any) -> bool:
   705         return not self == other
   706         return not self == other
   706 
   707 
   707 
   708 
   708 def statislink(st: Optional[os.stat_result]) -> bool:
   709 def statislink(st: Optional[os.stat_result]) -> bool:
   709     '''check whether a stat result is a symlink'''
   710     '''check whether a stat result is a symlink'''