comparison mercurial/pure/parsers.py @ 48232:f7fd629ffb98

dirstate-v2: Separate HAS_FILE_MTIME and HAS_DIRECTORY_MTIME flags Previously the same flag was used, with its meaning based on whether the node otherwise identifies a file tracked anywhere. In addition to being more explicit, this enables storing a directory mtime if a given path used to be tracked in a parent commit (so the dirstate still has data about it) but became a directory in the working copy. (However this is not done yet as it would require a larger change, replacing the `dirstate_map::NodeData` enum with struct fields.) Differential Revision: https://phab.mercurial-scm.org/D11662
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 14 Oct 2021 16:39:16 +0200
parents db5897321351
children 1730b2fceaa1
comparison
equal deleted inserted replaced
48231:0524c1359bfc 48232:f7fd629ffb98
47 # Bits of the `flags` byte inside a node in the file format 47 # Bits of the `flags` byte inside a node in the file format
48 DIRSTATE_V2_WDIR_TRACKED = 1 << 0 48 DIRSTATE_V2_WDIR_TRACKED = 1 << 0
49 DIRSTATE_V2_P1_TRACKED = 1 << 1 49 DIRSTATE_V2_P1_TRACKED = 1 << 1
50 DIRSTATE_V2_P2_INFO = 1 << 2 50 DIRSTATE_V2_P2_INFO = 1 << 2
51 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 3 51 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 3
52 DIRSTATE_V2_HAS_MTIME = 1 << 4 52 DIRSTATE_V2_HAS_FILE_MTIME = 1 << 4
53 DIRSTATE_V2_MODE_EXEC_PERM = 1 << 5 53 _DIRSTATE_V2_HAS_DIRCTORY_MTIME = 1 << 5 # Unused when Rust is not available
54 DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 6 54 DIRSTATE_V2_MODE_EXEC_PERM = 1 << 6
55 DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 7
55 56
56 57
57 @attr.s(slots=True, init=False) 58 @attr.s(slots=True, init=False)
58 class DirstateItem(object): 59 class DirstateItem(object):
59 """represent a dirstate entry 60 """represent a dirstate entry
136 return cls( 137 return cls(
137 wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED), 138 wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED),
138 p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED), 139 p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED),
139 p2_info=bool(flags & DIRSTATE_V2_P2_INFO), 140 p2_info=bool(flags & DIRSTATE_V2_P2_INFO),
140 has_meaningful_data=has_mode_size, 141 has_meaningful_data=has_mode_size,
141 has_meaningful_mtime=bool(flags & DIRSTATE_V2_HAS_MTIME), 142 has_meaningful_mtime=bool(flags & DIRSTATE_V2_HAS_FILE_MTIME),
142 parentfiledata=(mode, size, mtime), 143 parentfiledata=(mode, size, mtime),
143 ) 144 )
144 145
145 @classmethod 146 @classmethod
146 def from_v1_data(cls, state, mode, size, mtime): 147 def from_v1_data(cls, state, mode, size, mtime):
327 if self.mode & stat.S_IXUSR: 328 if self.mode & stat.S_IXUSR:
328 flags |= DIRSTATE_V2_MODE_EXEC_PERM 329 flags |= DIRSTATE_V2_MODE_EXEC_PERM
329 if stat.S_ISLNK(self.mode): 330 if stat.S_ISLNK(self.mode):
330 flags |= DIRSTATE_V2_MODE_IS_SYMLINK 331 flags |= DIRSTATE_V2_MODE_IS_SYMLINK
331 if self._mtime is not None: 332 if self._mtime is not None:
332 flags |= DIRSTATE_V2_HAS_MTIME 333 flags |= DIRSTATE_V2_HAS_FILE_MTIME
333 return (flags, self._size or 0, self._mtime or 0) 334 return (flags, self._size or 0, self._mtime or 0)
334 335
335 def v1_state(self): 336 def v1_state(self):
336 """return a "state" suitable for v1 serialization""" 337 """return a "state" suitable for v1 serialization"""
337 if not self.any_tracked: 338 if not self.any_tracked: