Mercurial > hg
comparison mercurial/dirstatemap.py @ 47905:c0d6a59a7704
dirstate-item: add dedicated "legacy" constructor for `addfile` case
This way the internal details of how a DirstateItem is encoded is encapsulated
within the DirstateItem. This will finally give use some latitude to change the
data we store in a DirstateItem.
The addfile logic will likely be rewritten eventually and these dedicated
constructor can be removed at that time.
In the mean-time this should help with hiding internal details of DirstateItem
and to migrate it to new internal storage and logic.
Differential Revision: https://phab.mercurial-scm.org/D11330
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 16 Jul 2021 18:12:27 +0200 |
parents | 822c67420c77 |
children | 50ded8854f8d |
comparison
equal
deleted
inserted
replaced
47904:822c67420c77 | 47905:c0d6a59a7704 |
---|---|
186 """Add a tracked file to the dirstate.""" | 186 """Add a tracked file to the dirstate.""" |
187 if added: | 187 if added: |
188 assert not merged | 188 assert not merged |
189 assert not possibly_dirty | 189 assert not possibly_dirty |
190 assert not from_p2 | 190 assert not from_p2 |
191 state = b'a' | 191 new_entry = DirstateItem.new_added() |
192 size = NONNORMAL | |
193 mtime = AMBIGUOUS_TIME | |
194 elif merged: | 192 elif merged: |
195 assert not possibly_dirty | 193 assert not possibly_dirty |
196 assert not from_p2 | 194 assert not from_p2 |
197 state = b'm' | 195 new_entry = DirstateItem.new_merged() |
198 size = FROM_P2 | |
199 mtime = AMBIGUOUS_TIME | |
200 elif from_p2: | 196 elif from_p2: |
201 assert not possibly_dirty | 197 assert not possibly_dirty |
202 state = b'n' | 198 new_entry = DirstateItem.new_from_p2() |
203 size = FROM_P2 | |
204 mtime = AMBIGUOUS_TIME | |
205 elif possibly_dirty: | 199 elif possibly_dirty: |
206 state = b'n' | 200 new_entry = DirstateItem.new_possibly_dirty() |
207 size = NONNORMAL | |
208 mtime = AMBIGUOUS_TIME | |
209 else: | 201 else: |
210 assert size != FROM_P2 | |
211 assert size != NONNORMAL | |
212 assert size is not None | 202 assert size is not None |
213 assert mtime is not None | 203 assert mtime is not None |
214 | |
215 state = b'n' | |
216 size = size & rangemask | 204 size = size & rangemask |
217 mtime = mtime & rangemask | 205 mtime = mtime & rangemask |
218 assert state is not None | 206 new_entry = DirstateItem.new_normal(mode, size, mtime) |
219 assert size is not None | |
220 assert mtime is not None | |
221 old_entry = self.get(f) | 207 old_entry = self.get(f) |
222 self._dirs_incr(f, old_entry) | 208 self._dirs_incr(f, old_entry) |
223 e = self._map[f] = DirstateItem.from_v1_data(state, mode, size, mtime) | 209 self._map[f] = new_entry |
224 if e.dm_nonnormal: | 210 if new_entry.dm_nonnormal: |
225 self.nonnormalset.add(f) | 211 self.nonnormalset.add(f) |
226 if e.dm_otherparent: | 212 if new_entry.dm_otherparent: |
227 self.otherparentset.add(f) | 213 self.otherparentset.add(f) |
228 | 214 |
229 def reset_state( | 215 def reset_state( |
230 self, | 216 self, |
231 filename, | 217 filename, |