comparison mercurial/context.py @ 48395:9ae0353c9f5d

status: move the boundary comparison logic within the timestamp module Some extensions will need it too. So lets isolate the logic. It also makes things clearer. Differential Revision: https://phab.mercurial-scm.org/D11799
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 23 Nov 2021 18:03:51 +0100
parents 322525db4c98
children 576040155dba
comparison
equal deleted inserted replaced
48394:eea70e3539ed 48395:9ae0353c9f5d
1821 clean.append(f) 1821 clean.append(f)
1822 else: 1822 else:
1823 s = self[f].lstat() 1823 s = self[f].lstat()
1824 mode = s.st_mode 1824 mode = s.st_mode
1825 size = s.st_size 1825 size = s.st_size
1826 file_mtime = timestamp.mtime_of(s) 1826 file_mtime = timestamp.reliable_mtime_of(s, mtime_boundary)
1827 cache_info = (mode, size, file_mtime) 1827 if file_mtime is not None:
1828 1828 cache_info = (mode, size, file_mtime)
1829 file_second = file_mtime[0] 1829 fixup.append((f, cache_info))
1830 boundary_second = mtime_boundary[0] 1830 else:
1831 # If the mtime of the ambiguous file is younger (or equal)
1832 # to the starting point of the `status` walk, we cannot
1833 # garantee that another, racy, write will not happen right
1834 # after with the same mtime and we cannot cache the
1835 # information.
1836 #
1837 # However is the mtime is far away in the future, this is
1838 # likely some mismatch between the current clock and
1839 # previous file system operation. So mtime more than one days
1840 # in the future are considered fine.
1841 if (
1842 boundary_second
1843 <= file_second
1844 < (3600 * 24 + boundary_second)
1845 ):
1846 clean.append(f) 1831 clean.append(f)
1847 else:
1848 fixup.append((f, cache_info))
1849 except (IOError, OSError): 1832 except (IOError, OSError):
1850 # A file become inaccessible in between? Mark it as deleted, 1833 # A file become inaccessible in between? Mark it as deleted,
1851 # matching dirstate behavior (issue5584). 1834 # matching dirstate behavior (issue5584).
1852 # The dirstate has more complex behavior around whether a 1835 # The dirstate has more complex behavior around whether a
1853 # missing file matches a directory, etc, but we don't need to 1836 # missing file matches a directory, etc, but we don't need to