Show More
@@ -225,3 +225,54 b' class filelog(object):' | |||
|
225 | 225 | |
|
226 | 226 | def _addrevision(self, *args, **kwargs): |
|
227 | 227 | return self._revlog._addrevision(*args, **kwargs) |
|
228 | ||
|
229 | class narrowfilelog(filelog): | |
|
230 | """Filelog variation to be used with narrow stores.""" | |
|
231 | ||
|
232 | def __init__(self, opener, path, narrowmatch): | |
|
233 | super(narrowfilelog, self).__init__(opener, path) | |
|
234 | self._narrowmatch = narrowmatch | |
|
235 | ||
|
236 | def renamed(self, node): | |
|
237 | res = super(narrowfilelog, self).renamed(node) | |
|
238 | ||
|
239 | # Renames that come from outside the narrowspec are problematic | |
|
240 | # because we may lack the base text for the rename. This can result | |
|
241 | # in code attempting to walk the ancestry or compute a diff | |
|
242 | # encountering a missing revision. We address this by silently | |
|
243 | # removing rename metadata if the source file is outside the | |
|
244 | # narrow spec. | |
|
245 | # | |
|
246 | # A better solution would be to see if the base revision is available, | |
|
247 | # rather than assuming it isn't. | |
|
248 | # | |
|
249 | # An even better solution would be to teach all consumers of rename | |
|
250 | # metadata that the base revision may not be available. | |
|
251 | # | |
|
252 | # TODO consider better ways of doing this. | |
|
253 | if res and not self._narrowmatch(res[0]): | |
|
254 | return None | |
|
255 | ||
|
256 | return res | |
|
257 | ||
|
258 | def size(self, rev): | |
|
259 | # Because we have a custom renamed() that may lie, we need to call | |
|
260 | # the base renamed() to report accurate results. | |
|
261 | node = self.node(rev) | |
|
262 | if super(narrowfilelog, self).renamed(node): | |
|
263 | return len(self.read(node)) | |
|
264 | else: | |
|
265 | return super(narrowfilelog, self).size(rev) | |
|
266 | ||
|
267 | def cmp(self, node, text): | |
|
268 | different = super(narrowfilelog, self).cmp(node, text) | |
|
269 | ||
|
270 | # Because renamed() may lie, we may get false positives for | |
|
271 | # different content. Check for this by comparing against the original | |
|
272 | # renamed() implementation. | |
|
273 | if different: | |
|
274 | if super(narrowfilelog, self).renamed(node): | |
|
275 | t2 = self.read(node) | |
|
276 | return t2 != text | |
|
277 | ||
|
278 | return different |
@@ -743,9 +743,22 b' class revlogfilestorage(object):' | |||
|
743 | 743 | |
|
744 | 744 | return filelog.filelog(self.svfs, path) |
|
745 | 745 | |
|
746 | @interfaceutil.implementer(repository.ilocalrepositoryfilestorage) | |
|
747 | class revlognarrowfilestorage(object): | |
|
748 | """File storage when using revlogs and narrow files.""" | |
|
749 | ||
|
750 | def file(self, path): | |
|
751 | if path[0] == b'/': | |
|
752 | path = path[1:] | |
|
753 | ||
|
754 | return filelog.narrowfilelog(self.svfs, path, self.narrowmatch()) | |
|
755 | ||
|
746 | 756 | def makefilestorage(requirements, **kwargs): |
|
747 | 757 | """Produce a type conforming to ``ilocalrepositoryfilestorage``.""" |
|
748 | return revlogfilestorage | |
|
758 | if repository.NARROW_REQUIREMENT in requirements: | |
|
759 | return revlognarrowfilestorage | |
|
760 | else: | |
|
761 | return revlogfilestorage | |
|
749 | 762 | |
|
750 | 763 | # List of repository interfaces and factory functions for them. Each |
|
751 | 764 | # will be called in order during ``makelocalrepository()`` to iteratively |
General Comments 0
You need to be logged in to leave comments.
Login now