comparison mercurial/pure/parsers.py @ 48250:1730b2fceaa1

dirstate-v2: adds a flag to mark a file as modified Right now, a files with a file system state that requires a lookup (same size, different mtime) will requires a lookup. If the result of that lookup is a modified files, it will remains ambiguous, requiring a lookup on the next status run too. To fix this, we introduce a dedicated flag in the new format. Such flag will allow to record such file as "known modified" avoiding an extra lookup later. As None of the associate code currently exist in the status code, we do the minimal implementation: if we read a dirstate entry with this flag set, we make it as "ambiguous" so that the next status code has to look it up. The same as it would have to without this flag existing anyway. Differential Revision: https://phab.mercurial-scm.org/D11681
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 15 Oct 2021 16:12:00 +0200
parents f7fd629ffb98
children dfc5a505ddc5
comparison
equal deleted inserted replaced
48249:e9faae0f445c 48250:1730b2fceaa1
51 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 3 51 DIRSTATE_V2_HAS_MODE_AND_SIZE = 1 << 3
52 DIRSTATE_V2_HAS_FILE_MTIME = 1 << 4 52 DIRSTATE_V2_HAS_FILE_MTIME = 1 << 4
53 _DIRSTATE_V2_HAS_DIRCTORY_MTIME = 1 << 5 # Unused when Rust is not available 53 _DIRSTATE_V2_HAS_DIRCTORY_MTIME = 1 << 5 # Unused when Rust is not available
54 DIRSTATE_V2_MODE_EXEC_PERM = 1 << 6 54 DIRSTATE_V2_MODE_EXEC_PERM = 1 << 6
55 DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 7 55 DIRSTATE_V2_MODE_IS_SYMLINK = 1 << 7
56 DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIED = 1 << 8
56 57
57 58
58 @attr.s(slots=True, init=False) 59 @attr.s(slots=True, init=False)
59 class DirstateItem(object): 60 class DirstateItem(object):
60 """represent a dirstate entry 61 """represent a dirstate entry
121 122
122 @classmethod 123 @classmethod
123 def from_v2_data(cls, flags, size, mtime): 124 def from_v2_data(cls, flags, size, mtime):
124 """Build a new DirstateItem object from V2 data""" 125 """Build a new DirstateItem object from V2 data"""
125 has_mode_size = bool(flags & DIRSTATE_V2_HAS_MODE_AND_SIZE) 126 has_mode_size = bool(flags & DIRSTATE_V2_HAS_MODE_AND_SIZE)
127 has_meaningful_mtime = bool(flags & DIRSTATE_V2_HAS_FILE_MTIME)
126 mode = None 128 mode = None
129
130 if flags & +DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIED:
131 # we do not have support for this flag in the code yet,
132 # force a lookup for this file.
133 has_mode_size = False
134 has_meaningful_mtime = False
135
127 if has_mode_size: 136 if has_mode_size:
128 assert stat.S_IXUSR == 0o100 137 assert stat.S_IXUSR == 0o100
129 if flags & DIRSTATE_V2_MODE_EXEC_PERM: 138 if flags & DIRSTATE_V2_MODE_EXEC_PERM:
130 mode = 0o755 139 mode = 0o755
131 else: 140 else:
137 return cls( 146 return cls(
138 wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED), 147 wc_tracked=bool(flags & DIRSTATE_V2_WDIR_TRACKED),
139 p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED), 148 p1_tracked=bool(flags & DIRSTATE_V2_P1_TRACKED),
140 p2_info=bool(flags & DIRSTATE_V2_P2_INFO), 149 p2_info=bool(flags & DIRSTATE_V2_P2_INFO),
141 has_meaningful_data=has_mode_size, 150 has_meaningful_data=has_mode_size,
142 has_meaningful_mtime=bool(flags & DIRSTATE_V2_HAS_FILE_MTIME), 151 has_meaningful_mtime=has_meaningful_mtime,
143 parentfiledata=(mode, size, mtime), 152 parentfiledata=(mode, size, mtime),
144 ) 153 )
145 154
146 @classmethod 155 @classmethod
147 def from_v1_data(cls, state, mode, size, mtime): 156 def from_v1_data(cls, state, mode, size, mtime):