comparison mercurial/dirstateutils/timestamp.py @ 48398:111098af6356

dirstate-item: add a "second_ambiguous` flag in the mtime tuple This will be used to support the `mtime-second-ambiguous` flag from dirstate v2. See format documentation for details. For now, we only make it possible to store the information, no other logic have been added. Differential Revision: https://phab.mercurial-scm.org/D11842
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 24 Nov 2021 04:40:00 +0100
parents 8d585aa9becf
children ca42667c8d26
comparison
equal deleted inserted replaced
48397:8d585aa9becf 48398:111098af6356
29 `subsecond_nanoseconds`: number of nanoseconds since `truncated_seconds`. 29 `subsecond_nanoseconds`: number of nanoseconds since `truncated_seconds`.
30 When this is zero, the sub-second precision is considered unknown. 30 When this is zero, the sub-second precision is considered unknown.
31 """ 31 """
32 32
33 def __new__(cls, value): 33 def __new__(cls, value):
34 truncated_seconds, subsec_nanos = value 34 truncated_seconds, subsec_nanos, second_ambiguous = value
35 value = (truncated_seconds & rangemask, subsec_nanos) 35 value = (truncated_seconds & rangemask, subsec_nanos, second_ambiguous)
36 return super(timestamp, cls).__new__(cls, value) 36 return super(timestamp, cls).__new__(cls, value)
37 37
38 def __eq__(self, other): 38 def __eq__(self, other):
39 raise error.ProgrammingError( 39 raise error.ProgrammingError(
40 'timestamp should never be compared directly' 40 'timestamp should never be compared directly'
87 else: 87 else:
88 billion = int(1e9) 88 billion = int(1e9)
89 secs = nanos // billion 89 secs = nanos // billion
90 subsec_nanos = nanos % billion 90 subsec_nanos = nanos % billion
91 91
92 return timestamp((secs, subsec_nanos)) 92 return timestamp((secs, subsec_nanos, False))
93 93
94 94
95 def reliable_mtime_of(stat_result, present_mtime): 95 def reliable_mtime_of(stat_result, present_mtime):
96 """same as `mtime_of`, but return None if the date might be ambiguous 96 """same as `mtime_of`, but return None if the date might be ambiguous
97 97