Mercurial > hg
diff mercurial/pure/parsers.py @ 47895:22c39f8acf78
dirstate-item: feed more information to `__init__`
Instead of processing the "rich" value at the `dirstatemap` level, we can now directly pass them to the DirstateItem object. This will make the object free to store whatever its want and to implements it logic whatever its want.
For now… we simply process the flag and store the same good old value. However
this pave the way for doing things differently once the rest of dirstatemap
code is updated.
Nobody call this code yet.
Differential Revision: https://phab.mercurial-scm.org/D11320
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 16 Jul 2021 16:52:53 +0200 |
parents | 3853e6ee160d |
children | c0d6a59a7704 |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Fri Aug 20 22:35:52 2021 +0200 +++ b/mercurial/pure/parsers.py Fri Jul 16 16:52:53 2021 +0200 @@ -61,11 +61,62 @@ _size = attr.ib() _mtime = attr.ib() - def __init__(self, state, mode, size, mtime): - self._state = state - self._mode = mode - self._size = size - self._mtime = mtime + def __init__( + self, + wc_tracked=False, + p1_tracked=False, + p2_tracked=False, + merged=False, + clean_p1=False, + clean_p2=False, + possibly_dirty=False, + parentfiledata=None, + ): + if merged and (clean_p1 or clean_p2): + msg = b'`merged` argument incompatible with `clean_p1`/`clean_p2`' + raise error.ProgrammingError(msg) + + self._state = None + self._mode = 0 + self._size = NONNORMAL + self._mtime = AMBIGUOUS_TIME + if not (p1_tracked or p2_tracked or wc_tracked): + pass # the object has no state to record + elif merged: + self._state = b'm' + self._size = FROM_P2 + self._mtime = AMBIGUOUS_TIME + elif not (p1_tracked or p2_tracked) and wc_tracked: + self._state = b'a' + self._size = NONNORMAL + self._mtime = AMBIGUOUS_TIME + elif (p1_tracked or p2_tracked) and not wc_tracked: + self._state = b'r' + self._size = 0 + self._mtime = 0 + elif clean_p2 and wc_tracked: + self._state = b'n' + self._size = FROM_P2 + self._mtime = AMBIGUOUS_TIME + elif not p1_tracked and p2_tracked and wc_tracked: + self._state = b'n' + self._size = FROM_P2 + self._mtime = AMBIGUOUS_TIME + elif possibly_dirty: + self._state = b'n' + self._size = NONNORMAL + self._mtime = AMBIGUOUS_TIME + elif wc_tracked: + # this is a "normal" file + if parentfiledata is None: + msg = b'failed to pass parentfiledata for a normal file' + raise error.ProgrammingError(msg) + self._state = b'n' + self._mode = parentfiledata[0] + self._size = parentfiledata[1] + self._mtime = parentfiledata[2] + else: + assert False, 'unreachable' @classmethod def from_v1_data(cls, state, mode, size, mtime): @@ -74,12 +125,12 @@ Since the dirstate-v1 format is frozen, the signature of this function is not expected to change, unlike the __init__ one. """ - return cls( - state=state, - mode=mode, - size=size, - mtime=mtime, - ) + instance = cls() + instance._state = state + instance._mode = mode + instance._size = size + instance._mtime = mtime + return instance def set_possibly_dirty(self): """Mark a file as "possibly dirty"