comparison mercurial/dirstateutils/timestamp.py @ 48451:ca42667c8d26

status: keep second-ambiguous mtimes during fixup Now that we support the feature, we can keep "second ambiguous" mtime during the fixup phase. These are the mtime that would be ambiguous if we did not had sub-second pr?cions. See the v2 format documentation for details. Differential Revision: https://phab.mercurial-scm.org/D11847
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 24 Nov 2021 05:00:28 +0100
parents 111098af6356
children 000130cfafb6
comparison
equal deleted inserted replaced
48450:be2317167a9b 48451:ca42667c8d26
100 100
101 Otherwise a concurrent modification might happens with the same mtime. 101 Otherwise a concurrent modification might happens with the same mtime.
102 """ 102 """
103 file_mtime = mtime_of(stat_result) 103 file_mtime = mtime_of(stat_result)
104 file_second = file_mtime[0] 104 file_second = file_mtime[0]
105 file_ns = file_mtime[1]
105 boundary_second = present_mtime[0] 106 boundary_second = present_mtime[0]
107 boundary_ns = present_mtime[1]
106 # If the mtime of the ambiguous file is younger (or equal) to the starting 108 # If the mtime of the ambiguous file is younger (or equal) to the starting
107 # point of the `status` walk, we cannot garantee that another, racy, write 109 # point of the `status` walk, we cannot garantee that another, racy, write
108 # will not happen right after with the same mtime and we cannot cache the 110 # will not happen right after with the same mtime and we cannot cache the
109 # information. 111 # information.
110 # 112 #
111 # However is the mtime is far away in the future, this is likely some 113 # However if the mtime is far away in the future, this is likely some
112 # mismatch between the current clock and previous file system operation. So 114 # mismatch between the current clock and previous file system operation. So
113 # mtime more than one days in the future are considered fine. 115 # mtime more than one days in the future are considered fine.
114 if boundary_second <= file_second < (3600 * 24 + boundary_second): 116 if boundary_second == file_second:
117 if file_ns and boundary_ns:
118 if file_ns < boundary_ns:
119 return timestamp((file_second, file_ns, True))
120 return None
121 elif boundary_second < file_second < (3600 * 24 + boundary_second):
115 return None 122 return None
116 else: 123 else:
117 return file_mtime 124 return file_mtime