Patchwork D11841: dirstate: drop comparison primitive on the timestamp class

login
register
mail settings
Submitter phabricator
Date Dec. 2, 2021, 7:03 p.m.
Message ID <differential-rev-PHID-DREV-mt2hl3r342wphrqfljaq-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50167/
State Superseded
Headers show

Comments

phabricator - Dec. 2, 2021, 7:03 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11841

AFFECTED FILES
  mercurial/dirstateutils/timestamp.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/dirstateutils/timestamp.py b/mercurial/dirstateutils/timestamp.py
--- a/mercurial/dirstateutils/timestamp.py
+++ b/mercurial/dirstateutils/timestamp.py
@@ -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):