Mercurial > hg
diff mercurial/pure/parsers.py @ 47665:a4443f66be6a
dirstate-item: add a `from_v1_data` constructor
This class method is dedicated to building a DirstateItem from the data
available in the "dirstate-v1" format. Since that format is frozen, this
constructor will never change (unlike the `__init__` one).
Differential Revision: https://phab.mercurial-scm.org/D11118
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 13 Jul 2021 13:06:50 +0200 |
parents | 119b9c8db94d |
children | e53256a9f9c5 |
line wrap: on
line diff
--- a/mercurial/pure/parsers.py Tue Jul 13 13:04:49 2021 +0200 +++ b/mercurial/pure/parsers.py Tue Jul 13 13:06:50 2021 +0200 @@ -67,6 +67,20 @@ self._size = size self._mtime = mtime + @classmethod + def from_v1_data(cls, state, mode, size, mtime): + """Build a new DirstateItem object from V1 data + + 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, + ) + def __getitem__(self, idx): if idx == 0 or idx == -4: msg = b"do not use item[x], use item.state" @@ -546,7 +560,7 @@ if b'\0' in f: f, c = f.split(b'\0') copymap[f] = c - dmap[f] = DirstateItem(*e[:4]) + dmap[f] = DirstateItem.from_v1_data(*e[:4]) return parents