comparison mercurial/dirstateutils/timestamp.py @ 48442:c8ca21962ff4

dirstate: Document Timestamp.second_ambiguous Differential Revision: https://phab.mercurial-scm.org/D11888
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 09 Dec 2021 10:23:41 +0100
parents 000130cfafb6
children 6000f5b25c9b
comparison
equal deleted inserted replaced
48439:9cf5ac8c7109 48442:c8ca21962ff4
19 class timestamp(tuple): 19 class timestamp(tuple):
20 """ 20 """
21 A Unix timestamp with optional nanoseconds precision, 21 A Unix timestamp with optional nanoseconds precision,
22 modulo 2**31 seconds. 22 modulo 2**31 seconds.
23 23
24 A 2-tuple containing: 24 A 3-tuple containing:
25 25
26 `truncated_seconds`: seconds since the Unix epoch, 26 `truncated_seconds`: seconds since the Unix epoch,
27 truncated to its lower 31 bits 27 truncated to its lower 31 bits
28 28
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
32 `second_ambiguous`: whether this timestamp is still "reliable"
33 (see `reliable_mtime_of`) if we drop its sub-second component.
31 """ 34 """
32 35
33 def __new__(cls, value): 36 def __new__(cls, value):
34 truncated_seconds, subsec_nanos, second_ambiguous = value 37 truncated_seconds, subsec_nanos, second_ambiguous = value
35 value = (truncated_seconds & rangemask, subsec_nanos, second_ambiguous) 38 value = (truncated_seconds & rangemask, subsec_nanos, second_ambiguous)
91 94
92 return timestamp((secs, subsec_nanos, False)) 95 return timestamp((secs, subsec_nanos, False))
93 96
94 97
95 def reliable_mtime_of(stat_result, present_mtime): 98 def reliable_mtime_of(stat_result, present_mtime):
96 """same as `mtime_of`, but return None if the date might be ambiguous 99 """Same as `mtime_of`, but return `None` or a `Timestamp` with
100 `second_ambiguous` set if the date might be ambiguous.
97 101
98 A modification time is reliable if it is older than "present_time" (or 102 A modification time is reliable if it is older than "present_time" (or
99 sufficiently in the future). 103 sufficiently in the future).
100 104
101 Otherwise a concurrent modification might happens with the same mtime. 105 Otherwise a concurrent modification might happens with the same mtime.