##// END OF EJS Templates
store: make `walk` return an entry for obsolescence if requested so...
marmoute -
r51407:0925eaf0 default
parent child Browse files
Show More
@@ -145,7 +145,9 b' def onetimesetup(ui):'
145 )
145 )
146
146
147 # don't clone filelogs to shallow clients
147 # don't clone filelogs to shallow clients
148 def _walkstreamfiles(orig, repo, matcher=None, phase=False):
148 def _walkstreamfiles(
149 orig, repo, matcher=None, phase=False, obsolescence=False
150 ):
149 if state.shallowremote:
151 if state.shallowremote:
150 # if we are shallow ourselves, stream our local commits
152 # if we are shallow ourselves, stream our local commits
151 if shallowutil.isenabled(repo):
153 if shallowutil.isenabled(repo):
@@ -200,7 +202,9 b' def onetimesetup(ui):'
200 _(b"Cannot clone from a shallow repo to a full repo.")
202 _(b"Cannot clone from a shallow repo to a full repo.")
201 )
203 )
202 else:
204 else:
203 for x in orig(repo, matcher, phase=phase):
205 for x in orig(
206 repo, matcher, phase=phase, obsolescence=obsolescence
207 ):
204 yield x
208 yield x
205
209
206 extensions.wrapfunction(streamclone, b'_walkstreamfiles', _walkstreamfiles)
210 extensions.wrapfunction(streamclone, b'_walkstreamfiles', _walkstreamfiles)
@@ -685,13 +685,22 b' class basicstore:'
685 details=file_details,
685 details=file_details,
686 )
686 )
687
687
688 def top_entries(self, phase=False) -> Generator[BaseStoreEntry, None, None]:
688 def top_entries(
689 self, phase=False, obsolescence=False
690 ) -> Generator[BaseStoreEntry, None, None]:
689 if phase and self.vfs.exists(b'phaseroots'):
691 if phase and self.vfs.exists(b'phaseroots'):
690 yield SimpleStoreEntry(
692 yield SimpleStoreEntry(
691 entry_path=b'phaseroots',
693 entry_path=b'phaseroots',
692 is_volatile=True,
694 is_volatile=True,
693 )
695 )
694
696
697 if obsolescence and self.vfs.exists(b'obsstore'):
698 # XXX if we had the file size it could be non-volatile
699 yield SimpleStoreEntry(
700 entry_path=b'obsstore',
701 is_volatile=True,
702 )
703
695 files = reversed(self._walk(b'', False))
704 files = reversed(self._walk(b'', False))
696
705
697 changelogs = collections.defaultdict(dict)
706 changelogs = collections.defaultdict(dict)
@@ -733,7 +742,7 b' class basicstore:'
733 )
742 )
734
743
735 def walk(
744 def walk(
736 self, matcher=None, phase=False
745 self, matcher=None, phase=False, obsolescence=False
737 ) -> Generator[BaseStoreEntry, None, None]:
746 ) -> Generator[BaseStoreEntry, None, None]:
738 """return files related to data storage (ie: revlogs)
747 """return files related to data storage (ie: revlogs)
739
748
@@ -745,7 +754,7 b' class basicstore:'
745 # yield data files first
754 # yield data files first
746 for x in self.data_entries(matcher):
755 for x in self.data_entries(matcher):
747 yield x
756 yield x
748 for x in self.top_entries(phase=phase):
757 for x in self.top_entries(phase=phase, obsolescence=obsolescence):
749 yield x
758 yield x
750
759
751 def copylist(self):
760 def copylist(self):
@@ -241,8 +241,8 b' def allowservergeneration(repo):'
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):
@@ -672,7 +672,7 b' def _v2_walk(repo, includes, excludes, i'
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
@@ -680,23 +680,23 b' def _v2_walk(repo, includes, excludes, i'
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):
General Comments 0
You need to be logged in to leave comments. Login now