comparison mercurial/pure/parsers.py @ 47926:05f2be3affe3

dirstate-item: have all the logic go through the v1_ accessors We are about to change the internal attribute. Having all the logic using the old "legacy" accessors will help to have a smooth transition. Differential Revision: https://phab.mercurial-scm.org/D11363
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 26 Aug 2021 16:50:14 +0200
parents ba9491be5e0c
children b81f52ca8075
comparison
equal deleted inserted replaced
47925:ba9491be5e0c 47926:05f2be3affe3
223 self._size = size 223 self._size = size
224 self._mtime = 0 224 self._mtime = 0
225 225
226 @property 226 @property
227 def mode(self): 227 def mode(self):
228 return self._mode 228 return self.v1_mode()
229 229
230 @property 230 @property
231 def size(self): 231 def size(self):
232 return self._size 232 return self.v1_size()
233 233
234 @property 234 @property
235 def mtime(self): 235 def mtime(self):
236 return self._mtime 236 return self.v1_mtime()
237 237
238 @property 238 @property
239 def state(self): 239 def state(self):
240 """ 240 """
241 States are: 241 States are:
246 246
247 XXX This "state" is a bit obscure and mostly a direct expression of the 247 XXX This "state" is a bit obscure and mostly a direct expression of the
248 dirstatev1 format. It would make sense to ultimately deprecate it in 248 dirstatev1 format. It would make sense to ultimately deprecate it in
249 favor of the more "semantic" attributes. 249 favor of the more "semantic" attributes.
250 """ 250 """
251 return self._state 251 return self.v1_state()
252 252
253 @property 253 @property
254 def tracked(self): 254 def tracked(self):
255 """True is the file is tracked in the working copy""" 255 """True is the file is tracked in the working copy"""
256 return self._state in b"nma" 256 return self.v1_state() in b"nma"
257 257
258 @property 258 @property
259 def added(self): 259 def added(self):
260 """True if the file has been added""" 260 """True if the file has been added"""
261 return self._state == b'a' 261 return self.v1_state() == b'a'
262 262
263 @property 263 @property
264 def merged(self): 264 def merged(self):
265 """True if the file has been merged 265 """True if the file has been merged
266 266
267 Should only be set if a merge is in progress in the dirstate 267 Should only be set if a merge is in progress in the dirstate
268 """ 268 """
269 return self._state == b'm' 269 return self.v1_state() == b'm'
270 270
271 @property 271 @property
272 def from_p2(self): 272 def from_p2(self):
273 """True if the file have been fetched from p2 during the current merge 273 """True if the file have been fetched from p2 during the current merge
274 274
275 This is only True is the file is currently tracked. 275 This is only True is the file is currently tracked.
276 276
277 Should only be set if a merge is in progress in the dirstate 277 Should only be set if a merge is in progress in the dirstate
278 """ 278 """
279 return self._state == b'n' and self._size == FROM_P2 279 return self.v1_state() == b'n' and self.v1_size() == FROM_P2
280 280
281 @property 281 @property
282 def from_p2_removed(self): 282 def from_p2_removed(self):
283 """True if the file has been removed, but was "from_p2" initially 283 """True if the file has been removed, but was "from_p2" initially
284 284
285 This property seems like an abstraction leakage and should probably be 285 This property seems like an abstraction leakage and should probably be
286 dealt in this class (or maybe the dirstatemap) directly. 286 dealt in this class (or maybe the dirstatemap) directly.
287 """ 287 """
288 return self._state == b'r' and self._size == FROM_P2 288 return self.v1_state() == b'r' and self.v1_size() == FROM_P2
289 289
290 @property 290 @property
291 def removed(self): 291 def removed(self):
292 """True if the file has been removed""" 292 """True if the file has been removed"""
293 return self._state == b'r' 293 return self.v1_state() == b'r'
294 294
295 @property 295 @property
296 def merged_removed(self): 296 def merged_removed(self):
297 """True if the file has been removed, but was "merged" initially 297 """True if the file has been removed, but was "merged" initially
298 298
299 This property seems like an abstraction leakage and should probably be 299 This property seems like an abstraction leakage and should probably be
300 dealt in this class (or maybe the dirstatemap) directly. 300 dealt in this class (or maybe the dirstatemap) directly.
301 """ 301 """
302 return self._state == b'r' and self._size == NONNORMAL 302 return self.v1_state() == b'r' and self.v1_size() == NONNORMAL
303 303
304 @property 304 @property
305 def dm_nonnormal(self): 305 def dm_nonnormal(self):
306 """True is the entry is non-normal in the dirstatemap sense 306 """True is the entry is non-normal in the dirstatemap sense
307 307
308 There is no reason for any code, but the dirstatemap one to use this. 308 There is no reason for any code, but the dirstatemap one to use this.
309 """ 309 """
310 return self.state != b'n' or self.mtime == AMBIGUOUS_TIME 310 return self.v1_state() != b'n' or self.v1_mtime() == AMBIGUOUS_TIME
311 311
312 @property 312 @property
313 def dm_otherparent(self): 313 def dm_otherparent(self):
314 """True is the entry is `otherparent` in the dirstatemap sense 314 """True is the entry is `otherparent` in the dirstatemap sense
315 315
316 There is no reason for any code, but the dirstatemap one to use this. 316 There is no reason for any code, but the dirstatemap one to use this.
317 """ 317 """
318 return self._size == FROM_P2 318 return self.v1_size() == FROM_P2
319 319
320 def v1_state(self): 320 def v1_state(self):
321 """return a "state" suitable for v1 serialization""" 321 """return a "state" suitable for v1 serialization"""
322 return self._state 322 return self._state
323 323
333 """return a "mtime" suitable for v1 serialization""" 333 """return a "mtime" suitable for v1 serialization"""
334 return self._mtime 334 return self._mtime
335 335
336 def need_delay(self, now): 336 def need_delay(self, now):
337 """True if the stored mtime would be ambiguous with the current time""" 337 """True if the stored mtime would be ambiguous with the current time"""
338 return self._state == b'n' and self._mtime == now 338 return self.v1_state() == b'n' and self.v1_mtime() == now
339 339
340 340
341 def gettype(q): 341 def gettype(q):
342 return int(q & 0xFFFF) 342 return int(q & 0xFFFF)
343 343