Patchwork D10928: dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker

login
register
mail settings
Submitter phabricator
Date July 2, 2021, 3:18 p.m.
Message ID <differential-rev-PHID-DREV-g5nb265472r7whzzrag2-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49242/
State Superseded
Headers show

Comments

phabricator - July 2, 2021, 3:18 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This is going to be clearer and easier to track than -1. Ultimately I would
  like to get ride of this special value everywhere but in the lower level,
  however we need to clarify the API first. This changeset is part of such
  clarification.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/dirstate.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -54,6 +54,9 @@ 
 # a special value used internally for `size` if the file is modified/merged/added
 NONNORMAL = -1
 
+# a special value used internally for `time` if the time is ambigeous
+AMBIGUOUS_TIME = -1
+
 
 class repocache(filecache):
     """filecache for files in .hg/"""
@@ -502,7 +505,7 @@ 
                     return
                 if entry[0] == b'm' or entry[0] == b'n' and entry[2] == FROM_P2:
                     return
-        self._addpath(f, b'n', 0, NONNORMAL, -1)
+        self._addpath(f, b'n', 0, NONNORMAL, AMBIGUOUS_TIME)
         self._map.copymap.pop(f, None)
 
     def otherparent(self, f):
@@ -512,15 +515,15 @@ 
             raise error.Abort(msg)
         if f in self and self[f] == b'n':
             # merge-like
-            self._addpath(f, b'm', 0, FROM_P2, -1)
+            self._addpath(f, b'm', 0, FROM_P2, AMBIGUOUS_TIME)
         else:
             # add-like
-            self._addpath(f, b'n', 0, FROM_P2, -1)
+            self._addpath(f, b'n', 0, FROM_P2, AMBIGUOUS_TIME)
         self._map.copymap.pop(f, None)
 
     def add(self, f):
         '''Mark a file added.'''
-        self._addpath(f, b'a', 0, NONNORMAL, -1)
+        self._addpath(f, b'a', 0, NONNORMAL, AMBIGUOUS_TIME)
         self._map.copymap.pop(f, None)
 
     def remove(self, f):
@@ -1537,7 +1540,7 @@ 
         if oldstate == b"?" and "_alldirs" in self.__dict__:
             self._alldirs.addpath(f)
         self._map[f] = dirstatetuple(state, mode, size, mtime)
-        if state != b'n' or mtime == -1:
+        if state != b'n' or mtime == AMBIGUOUS_TIME:
             self.nonnormalset.add(f)
         if size == FROM_P2:
             self.otherparentset.add(f)
@@ -1581,7 +1584,7 @@ 
         for f in files:
             e = self.get(f)
             if e is not None and e[0] == b'n' and e[3] == now:
-                self._map[f] = dirstatetuple(e[0], e[1], e[2], -1)
+                self._map[f] = dirstatetuple(e[0], e[1], e[2], AMBIGUOUS_TIME)
                 self.nonnormalset.add(f)
 
     def nonnormalentries(self):
@@ -1592,7 +1595,7 @@ 
             nonnorm = set()
             otherparent = set()
             for fname, e in pycompat.iteritems(self._map):
-                if e[0] != b'n' or e[3] == -1:
+                if e[0] != b'n' or e[3] == AMBIGUOUS_TIME:
                     nonnorm.add(fname)
                 if e[0] == b'n' and e[2] == FROM_P2:
                     otherparent.add(fname)