dirstate: drop comparison primitive on the timestamp class
All comparison are now managed without using operator :
- the status mtime comparisons is handled by the DirstateItem,
- the fixup reliability check,
- the update "hack".
So we no longer needs the operator and should discourage its usage.
Differential Revision: https://phab.mercurial-scm.org/D11841
--- a/mercurial/dirstateutils/timestamp.py Tue Nov 23 18:13:33 2021 +0100
+++ b/mercurial/dirstateutils/timestamp.py Tue Nov 23 19:27:17 2021 +0100
@@ -9,6 +9,8 @@
import os
import stat
+from .. import error
+
rangemask = 0x7FFFFFFF
@@ -34,25 +36,14 @@
return super(timestamp, cls).__new__(cls, value)
def __eq__(self, other):
- self_secs, self_subsec_nanos = self
- other_secs, other_subsec_nanos = other
- return self_secs == other_secs and (
- self_subsec_nanos == other_subsec_nanos
- or self_subsec_nanos == 0
- or other_subsec_nanos == 0
+ raise error.ProgrammingError(
+ 'timestamp should never be compared directly'
)
def __gt__(self, other):
- self_secs, self_subsec_nanos = self
- other_secs, other_subsec_nanos = other
- if self_secs > other_secs:
- return True
- if self_secs < other_secs:
- return False
- if self_subsec_nanos == 0 or other_subsec_nanos == 0:
- # they are considered equal, so not "greater than"
- return False
- return self_subsec_nanos > other_subsec_nanos
+ raise error.ProgrammingError(
+ 'timestamp should never be compared directly'
+ )
def get_fs_now(vfs):