# HG changeset patch # User Pierre-Yves David # Date 2021-08-27 15:59:00 # Node ID dbf2d03850a24ce46c70bde16f977902dc5dd2c0 # Parent 0d185f73c619b592bf0a0cf62df207a5c0d69859 dirstate-item: implement `v1_size` with higher level block This is much easier to read and maintain. Differential Revision: https://phab.mercurial-scm.org/D11374 diff --git a/mercurial/pure/parsers.py b/mercurial/pure/parsers.py --- a/mercurial/pure/parsers.py +++ b/mercurial/pure/parsers.py @@ -354,32 +354,22 @@ class DirstateItem(object): # the object has no state to record, this is -currently- # unsupported raise RuntimeError('untracked item') - elif not self._wc_tracked: - # File was deleted - if self._merged: - return NONNORMAL - elif self._clean_p2: - return FROM_P2 - else: - return 0 - elif self._merged: + elif self.merged_removed: + return NONNORMAL + elif self.from_p2_removed: return FROM_P2 - elif not (self._p1_tracked or self._p2_tracked) and self._wc_tracked: - # Added + elif self.removed: + return 0 + elif self.merged: + return FROM_P2 + elif self.added: return NONNORMAL - elif self._clean_p2 and self._wc_tracked: - return FROM_P2 - elif not self._p1_tracked and self._p2_tracked and self._wc_tracked: + elif self.from_p2: return FROM_P2 elif self._possibly_dirty: - if self._size is None: - return NONNORMAL - else: - return self._size - elif self._wc_tracked: + return self._size if self._size is not None else NONNORMAL + else: return self._size - else: - raise RuntimeError('unreachable') def v1_mtime(self): """return a "mtime" suitable for v1 serialization"""