comparison hgext/remotefilelog/remotefilelogserver.py @ 50505:521fec115dad

store: use a StoreEntry object instead of tuple for store files We want to make the store return more semantic information instead of a stream of file path. To achieve this, we start with adding a simple object that hold the same information as the tuple it replace, and do a simple update to the user code to fetch and use the same information. From there, we will be able to iteratively upgrade the codebase toward better objects.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 08:56:23 +0200
parents 53e9422a9b45
children 5a2fb64d38b2
comparison
equal deleted inserted replaced
50504:814f55775b21 50505:521fec115dad
160 if not fp.endswith(b'.i') and not fp.endswith( 160 if not fp.endswith(b'.i') and not fp.endswith(
161 b'.d' 161 b'.d'
162 ): 162 ):
163 n = util.pconvert(fp[striplen:]) 163 n = util.pconvert(fp[striplen:])
164 d = store.decodedir(n) 164 d = store.decodedir(n)
165 t = store.FILETYPE_OTHER 165 yield store.StoreEntry(
166 yield (t, d, st.st_size) 166 unencoded_path=d,
167 is_revlog=True,
168 revlog_type=None,
169 is_revlog_main=False,
170 is_volatile=False,
171 file_size=st.st_size,
172 )
173
167 if kind == stat.S_IFDIR: 174 if kind == stat.S_IFDIR:
168 visit.append(fp) 175 visit.append(fp)
169 176
170 if scmutil.istreemanifest(repo): 177 if scmutil.istreemanifest(repo):
171 for (t, u, s) in repo.store.datafiles(): 178 for entry in repo.store.datafiles():
179 u = entry.unencoded_path
172 if u.startswith(b'meta/') and ( 180 if u.startswith(b'meta/') and (
173 u.endswith(b'.i') or u.endswith(b'.d') 181 u.endswith(b'.i') or u.endswith(b'.d')
174 ): 182 ):
175 yield (t, u, s) 183 yield entry
176 184
177 # Return .d and .i files that do not match the shallow pattern 185 # Return .d and .i files that do not match the shallow pattern
178 match = state.match 186 match = state.match
179 if match and not match.always(): 187 if match and not match.always():
180 for (t, u, s) in repo.store.datafiles(): 188 for entry in repo.store.datafiles():
189 u = entry.unencoded_path
181 f = u[5:-2] # trim data/... and .i/.d 190 f = u[5:-2] # trim data/... and .i/.d
182 if not state.match(f): 191 if not state.match(f):
183 yield (t, u, s) 192 yield entry
184 193
185 for x in repo.store.topfiles(): 194 for x in repo.store.topfiles():
186 if state.noflatmf and x[1][:11] == b'00manifest.': 195 if state.noflatmf and x[1][:11] == b'00manifest.':
187 continue 196 continue
188 yield x 197 yield x