store: introduce a EntryFile object to actually access file info
For now a StoreEntry match a single file, but the goal is to eventually combine
multiple file in a higher level Entry, so we need to introduce this distinction
and use it first.
--- a/hgext/narrow/narrowcommands.py Mon May 15 08:56:23 2023 +0200
+++ b/hgext/narrow/narrowcommands.py Mon May 15 08:56:40 2023 +0200
@@ -293,7 +293,8 @@
if f.startswith(b'data/'):
file = f[5:-2]
if not newmatch(file):
- todelete.append(f)
+ for file_ in entry.files():
+ todelete.append(file_.unencoded_path)
elif f.startswith(b'meta/'):
dir = f[5:-13]
dirs = sorted(pathutil.dirs({dir})) + [dir]
@@ -306,7 +307,8 @@
if visit == b'all':
break
if not include:
- todelete.append(f)
+ for file_ in entry.files():
+ todelete.append(file_.unencoded_path)
repo.destroying()
--- a/mercurial/store.py Mon May 15 08:56:23 2023 +0200
+++ b/mercurial/store.py Mon May 15 08:56:40 2023 +0200
@@ -466,6 +466,24 @@
is_volatile = attr.ib(default=False)
file_size = attr.ib(default=None)
+ def files(self):
+ return [
+ StoreFile(
+ unencoded_path=self.unencoded_path,
+ file_size=self.file_size,
+ is_volatile=self.is_volatile,
+ )
+ ]
+
+
+@attr.s(slots=True)
+class StoreFile:
+ """a file matching an entry"""
+
+ unencoded_path = attr.ib()
+ file_size = attr.ib()
+ is_volatile = attr.ib(default=False)
+
class basicstore:
'''base class for local repository stores'''
--- a/mercurial/streamclone.py Mon May 15 08:56:23 2023 +0200
+++ b/mercurial/streamclone.py Mon May 15 08:56:40 2023 +0200
@@ -270,9 +270,10 @@
with repo.lock():
repo.ui.debug(b'scanning\n')
for entry in _walkstreamfiles(repo):
- if entry.file_size:
- entries.append((entry.unencoded_path, entry.file_size))
- total_bytes += entry.file_size
+ for f in entry.files():
+ if f.file_size:
+ entries.append((f.unencoded_path, f.file_size))
+ total_bytes += f.file_size
_test_sync_point_walk_1(repo)
_test_sync_point_walk_2(repo)
@@ -678,14 +679,13 @@
matcher = narrowspec.match(repo.root, includes, excludes)
for entry in _walkstreamfiles(repo, matcher):
- if entry.file_size:
- ft = _fileappend
- if entry.is_volatile:
- ft = _filefull
- entries.append(
- (_srcstore, entry.unencoded_path, ft, entry.file_size)
- )
- totalfilesize += entry.file_size
+ for f in entry.files():
+ if f.file_size:
+ ft = _fileappend
+ if f.is_volatile:
+ ft = _filefull
+ entries.append((_srcstore, f.unencoded_path, ft, f.file_size))
+ totalfilesize += f.file_size
for name in _walkstreamfullstorefiles(repo):
if repo.svfs.exists(name):
totalfilesize += repo.svfs.lstat(name).st_size
--- a/mercurial/verify.py Mon May 15 08:56:23 2023 +0200
+++ b/mercurial/verify.py Mon May 15 08:56:40 2023 +0200
@@ -408,11 +408,12 @@
revlogv1 = self.revlogv1
undecodable = []
for entry in repo.store.datafiles(undecodable=undecodable):
- f = entry.unencoded_path
- size = entry.file_size
- if (size > 0 or not revlogv1) and f.startswith(b'meta/'):
- storefiles.add(_normpath(f))
- subdirs.add(os.path.dirname(f))
+ for file_ in entry.files():
+ f = file_.unencoded_path
+ size = file_.file_size
+ if (size > 0 or not revlogv1) and f.startswith(b'meta/'):
+ storefiles.add(_normpath(f))
+ subdirs.add(os.path.dirname(f))
for f in undecodable:
self._err(None, _(b"cannot decode filename '%s'") % f)
subdirprogress = ui.makeprogress(
@@ -475,10 +476,11 @@
storefiles = set()
undecodable = []
for entry in repo.store.datafiles(undecodable=undecodable):
- size = entry.file_size
- f = entry.unencoded_path
- if (size > 0 or not revlogv1) and f.startswith(b'data/'):
- storefiles.add(_normpath(f))
+ for file_ in entry.files():
+ size = file_.file_size
+ f = file_.unencoded_path
+ if (size > 0 or not revlogv1) and f.startswith(b'data/'):
+ storefiles.add(_normpath(f))
for f in undecodable:
self._err(None, _(b"cannot decode filename '%s'") % f)