Mercurial > hg-stable
changeset 47489:3f13dfa1fa78
dirstate: introduce a symbolic constant for the AMBIGUOUS_TIME marker
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.
Differential Revision: https://phab.mercurial-scm.org/D10928
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 01 Jul 2021 19:15:30 +0200 |
parents | 4ac418b4a6af |
children | 5eb65ec12465 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 10 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Jul 01 19:15:22 2021 +0200 +++ b/mercurial/dirstate.py Thu Jul 01 19:15:30 2021 +0200 @@ -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)