Mercurial > hg-stable
changeset 47488:4ac418b4a6af
dirstate: introduce a symbolic constant for the NONNORMAL 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/D10927
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 01 Jul 2021 19:15:22 +0200 |
parents | cb29484eaade |
children | 3f13dfa1fa78 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Jul 01 19:04:11 2021 +0200 +++ b/mercurial/dirstate.py Thu Jul 01 19:15:22 2021 +0200 @@ -51,6 +51,9 @@ # a special value used internally for `size` if the file come from the other parent FROM_P2 = -2 +# a special value used internally for `size` if the file is modified/merged/added +NONNORMAL = -1 + class repocache(filecache): """filecache for files in .hg/""" @@ -488,9 +491,9 @@ # being removed, restore that state. entry = self._map.get(f) if entry is not None: - if entry[0] == b'r' and entry[2] in (-1, FROM_P2): + if entry[0] == b'r' and entry[2] in (NONNORMAL, FROM_P2): source = self._map.copymap.get(f) - if entry[2] == -1: + if entry[2] == NONNORMAL: self.merge(f) elif entry[2] == FROM_P2: self.otherparent(f) @@ -499,7 +502,7 @@ return if entry[0] == b'm' or entry[0] == b'n' and entry[2] == FROM_P2: return - self._addpath(f, b'n', 0, -1, -1) + self._addpath(f, b'n', 0, NONNORMAL, -1) self._map.copymap.pop(f, None) def otherparent(self, f): @@ -517,7 +520,7 @@ def add(self, f): '''Mark a file added.''' - self._addpath(f, b'a', 0, -1, -1) + self._addpath(f, b'a', 0, NONNORMAL, -1) self._map.copymap.pop(f, None) def remove(self, f): @@ -530,7 +533,7 @@ if entry is not None: # backup the previous state if entry[0] == b'm': # merge - size = -1 + size = NONNORMAL elif entry[0] == b'n' and entry[2] == FROM_P2: # other parent size = FROM_P2 self._map.otherparentset.add(f)