Mercurial > public > mercurial-scm > hg
comparison mercurial/streamclone.py @ 50511:0925eaf09c8b
store: make `walk` return an entry for obsolescence if requested so
Instead of having dedicated code in the streamclone code, we should have the
store deal with advertising the data it contains.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 21 May 2023 02:29:33 +0200 |
parents | a32d739b0ffb |
children | 06d580b8f432 |
comparison
equal
deleted
inserted
replaced
50510:5a62d56e3955 | 50511:0925eaf09c8b |
---|---|
239 | 239 |
240 return True | 240 return True |
241 | 241 |
242 | 242 |
243 # This is it's own function so extensions can override it. | 243 # This is it's own function so extensions can override it. |
244 def _walkstreamfiles(repo, matcher=None, phase=False): | 244 def _walkstreamfiles(repo, matcher=None, phase=False, obsolescence=False): |
245 return repo.store.walk(matcher, phase=phase) | 245 return repo.store.walk(matcher, phase=phase, obsolescence=obsolescence) |
246 | 246 |
247 | 247 |
248 def generatev1(repo): | 248 def generatev1(repo): |
249 """Emit content for version 1 of a streaming clone. | 249 """Emit content for version 1 of a streaming clone. |
250 | 250 |
670 - `name`: file path of the file to copy (to be feed to the vfss) | 670 - `name`: file path of the file to copy (to be feed to the vfss) |
671 - `file-type`: do this file need to be copied with the source lock ? | 671 - `file-type`: do this file need to be copied with the source lock ? |
672 - `size`: the size of the file (or None) | 672 - `size`: the size of the file (or None) |
673 """ | 673 """ |
674 assert repo._currentlock(repo._lockref) is not None | 674 assert repo._currentlock(repo._lockref) is not None |
675 entries = [] | 675 files = [] |
676 totalfilesize = 0 | 676 totalfilesize = 0 |
677 | 677 |
678 matcher = None | 678 matcher = None |
679 if includes or excludes: | 679 if includes or excludes: |
680 matcher = narrowspec.match(repo.root, includes, excludes) | 680 matcher = narrowspec.match(repo.root, includes, excludes) |
681 | 681 |
682 phase = not repo.publishing() | 682 phase = not repo.publishing() |
683 for entry in _walkstreamfiles(repo, matcher, phase=phase): | 683 entries = _walkstreamfiles( |
684 repo, matcher, phase=phase, obsolescence=includeobsmarkers | |
685 ) | |
686 for entry in entries: | |
684 for f in entry.files(): | 687 for f in entry.files(): |
685 file_size = f.file_size(repo.store.vfs) | 688 file_size = f.file_size(repo.store.vfs) |
686 if file_size: | 689 if file_size: |
687 ft = _fileappend | 690 ft = _fileappend |
688 if f.is_volatile: | 691 if f.is_volatile: |
689 ft = _filefull | 692 ft = _filefull |
690 entries.append((_srcstore, f.unencoded_path, ft, file_size)) | 693 files.append((_srcstore, f.unencoded_path, ft, file_size)) |
691 totalfilesize += file_size | 694 totalfilesize += file_size |
692 if includeobsmarkers and repo.svfs.exists(b'obsstore'): | |
693 totalfilesize += repo.svfs.lstat(b'obsstore').st_size | |
694 entries.append((_srcstore, b'obsstore', _filefull, None)) | |
695 for name in cacheutil.cachetocopy(repo): | 695 for name in cacheutil.cachetocopy(repo): |
696 if repo.cachevfs.exists(name): | 696 if repo.cachevfs.exists(name): |
697 totalfilesize += repo.cachevfs.lstat(name).st_size | 697 totalfilesize += repo.cachevfs.lstat(name).st_size |
698 entries.append((_srccache, name, _filefull, None)) | 698 files.append((_srccache, name, _filefull, None)) |
699 return entries, totalfilesize | 699 return files, totalfilesize |
700 | 700 |
701 | 701 |
702 def generatev2(repo, includes, excludes, includeobsmarkers): | 702 def generatev2(repo, includes, excludes, includeobsmarkers): |
703 """Emit content for version 2 of a streaming clone. | 703 """Emit content for version 2 of a streaming clone. |
704 | 704 |