Mercurial > public > mercurial-scm > hg-stable
changeset 52389:a260d326458f
stream: create a `e.preserve_volatiles` method directly on StoreEntry
For cache, we will need an atomic operation that detect the file and preserve
it, so we start by creating an API that make such atomic operation possible. We
will actually make things atomic in the next changesets.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 02 Dec 2024 17:00:12 +0100 |
parents | 46574e588017 |
children | 11484a19cd77 |
files | mercurial/store.py mercurial/streamclone.py |
diffstat | 2 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/store.py Mon Dec 02 16:01:00 2024 +0100 +++ b/mercurial/store.py Mon Dec 02 17:00:12 2024 +0100 @@ -524,6 +524,16 @@ assert vfs is not None return [f.get_stream(vfs, volatiles) for f in self.files()] + def preserve_volatiles(self, vfs, volatiles): + """Use a VolatileManager to preserve the state of any volatile file + + This is useful for code that need a consistent view of the content like stream clone. + """ + if self.maybe_volatile: + for f in self.files(): + if f.is_volatile: + volatiles(vfs.join(f.unencoded_path)) + @attr.s(slots=True, init=False) class SimpleStoreEntry(BaseStoreEntry):
--- a/mercurial/streamclone.py Mon Dec 02 16:01:00 2024 +0100 +++ b/mercurial/streamclone.py Mon Dec 02 17:00:12 2024 +0100 @@ -714,9 +714,8 @@ with util.nogc(): # record the expected size of every file for k, vfs, e in entries: + e.preserve_volatiles(vfs, volatiles) for f in e.files(): - if f.is_volatile: - volatiles(vfs.join(f.unencoded_path)) file_count += 1 totalfilesize += f.file_size(vfs) @@ -777,11 +776,11 @@ # make sure we preserve volatile files for k, vfs, e in entries: if e.maybe_volatile: + e.preserve_volatiles(vfs, volatiles) for f in e.files(): if f.is_volatile: # record the expected size under lock f.file_size(vfs) - volatiles(vfs.join(f.unencoded_path)) total_entry_count = len(entries)