Show More
@@ -337,7 +337,7 b' def vfsinit(orig, self, othervfs):' | |||||
337 | setattr(self, name, getattr(othervfs, name)) |
|
337 | setattr(self, name, getattr(othervfs, name)) | |
338 |
|
338 | |||
339 |
|
339 | |||
340 |
def _prefetchfiles(repo, rev |
|
340 | def _prefetchfiles(repo, revmatches): | |
341 | """Ensure that required LFS blobs are present, fetching them as a group if |
|
341 | """Ensure that required LFS blobs are present, fetching them as a group if | |
342 | needed.""" |
|
342 | needed.""" | |
343 | if not util.safehasattr(repo.svfs, b'lfslocalblobstore'): |
|
343 | if not util.safehasattr(repo.svfs, b'lfslocalblobstore'): | |
@@ -347,7 +347,7 b' def _prefetchfiles(repo, revs, match):' | |||||
347 | oids = set() |
|
347 | oids = set() | |
348 | localstore = repo.svfs.lfslocalblobstore |
|
348 | localstore = repo.svfs.lfslocalblobstore | |
349 |
|
349 | |||
350 | for rev in revs: |
|
350 | for rev, match in revmatches: | |
351 | ctx = repo[rev] |
|
351 | ctx = repo[rev] | |
352 | for f in ctx.walk(match): |
|
352 | for f in ctx.walk(match): | |
353 | p = pointerfromctx(ctx, f) |
|
353 | p = pointerfromctx(ctx, f) |
@@ -1118,10 +1118,10 b' def exchangepull(orig, repo, remote, *ar' | |||||
1118 | return orig(repo, remote, *args, **kwargs) |
|
1118 | return orig(repo, remote, *args, **kwargs) | |
1119 |
|
1119 | |||
1120 |
|
1120 | |||
1121 |
def _fileprefetchhook(repo, rev |
|
1121 | def _fileprefetchhook(repo, revmatches): | |
1122 | if isenabled(repo): |
|
1122 | if isenabled(repo): | |
1123 | allfiles = [] |
|
1123 | allfiles = [] | |
1124 | for rev in revs: |
|
1124 | for rev, match in revmatches: | |
1125 | if rev == nodemod.wdirrev or rev is None: |
|
1125 | if rev == nodemod.wdirrev or rev is None: | |
1126 | continue |
|
1126 | continue | |
1127 | ctx = repo[rev] |
|
1127 | ctx = repo[rev] |
@@ -364,7 +364,7 b' def archive(' | |||||
364 | if total: |
|
364 | if total: | |
365 | files.sort() |
|
365 | files.sort() | |
366 | scmutil.prefetchfiles( |
|
366 | scmutil.prefetchfiles( | |
367 |
repo, [ctx.rev() |
|
367 | repo, [(ctx.rev(), scmutil.matchfiles(repo, files))] | |
368 | ) |
|
368 | ) | |
369 | progress = repo.ui.makeprogress( |
|
369 | progress = repo.ui.makeprogress( | |
370 | _(b'archiving'), unit=_(b'files'), total=total |
|
370 | _(b'archiving'), unit=_(b'files'), total=total |
@@ -2138,7 +2138,9 b' def _prefetchchangedfiles(repo, revs, ma' | |||||
2138 | for file in repo[rev].files(): |
|
2138 | for file in repo[rev].files(): | |
2139 | if not match or match(file): |
|
2139 | if not match or match(file): | |
2140 | allfiles.add(file) |
|
2140 | allfiles.add(file) | |
2141 |
|
|
2141 | match = scmutil.matchfiles(repo, allfiles) | |
|
2142 | revmatches = [(rev, match) for rev in revs] | |||
|
2143 | scmutil.prefetchfiles(repo, revmatches) | |||
2142 |
|
2144 | |||
2143 |
|
2145 | |||
2144 | def export( |
|
2146 | def export( | |
@@ -2997,14 +2999,14 b' def cat(ui, repo, ctx, matcher, basefm, ' | |||||
2997 | try: |
|
2999 | try: | |
2998 | if mfnode and mfl[mfnode].find(file)[0]: |
|
3000 | if mfnode and mfl[mfnode].find(file)[0]: | |
2999 | if _catfmtneedsdata(basefm): |
|
3001 | if _catfmtneedsdata(basefm): | |
3000 |
scmutil.prefetchfiles(repo, [ctx.rev() |
|
3002 | scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)]) | |
3001 | write(file) |
|
3003 | write(file) | |
3002 | return 0 |
|
3004 | return 0 | |
3003 | except KeyError: |
|
3005 | except KeyError: | |
3004 | pass |
|
3006 | pass | |
3005 |
|
3007 | |||
3006 | if _catfmtneedsdata(basefm): |
|
3008 | if _catfmtneedsdata(basefm): | |
3007 |
scmutil.prefetchfiles(repo, [ctx.rev() |
|
3009 | scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)]) | |
3008 |
|
3010 | |||
3009 | for abs in ctx.walk(matcher): |
|
3011 | for abs in ctx.walk(matcher): | |
3010 | write(abs) |
|
3012 | write(abs) | |
@@ -3769,11 +3771,11 b' def revert(ui, repo, ctx, parents, *pats' | |||||
3769 | needdata = (b'revert', b'add', b'undelete') |
|
3771 | needdata = (b'revert', b'add', b'undelete') | |
3770 | oplist = [actions[name][0] for name in needdata] |
|
3772 | oplist = [actions[name][0] for name in needdata] | |
3771 | prefetch = scmutil.prefetchfiles |
|
3773 | prefetch = scmutil.prefetchfiles | |
3772 | matchfiles = scmutil.matchfiles |
|
3774 | matchfiles = scmutil.matchfiles( | |
|
3775 | repo, [f for sublist in oplist for f in sublist]) | |||
3773 | prefetch( |
|
3776 | prefetch( | |
3774 | repo, |
|
3777 | repo, | |
3775 | [ctx.rev()], |
|
3778 | [(ctx.rev(), matchfiles)], | |
3776 | matchfiles(repo, [f for sublist in oplist for f in sublist]), |
|
|||
3777 | ) |
|
3779 | ) | |
3778 | match = scmutil.match(repo[None], pats) |
|
3780 | match = scmutil.match(repo[None], pats) | |
3779 | _performrevert( |
|
3781 | _performrevert( |
@@ -2540,8 +2540,8 b' class overlayworkingctx(committablectx):' | |||||
2540 | # using things like remotefilelog. |
|
2540 | # using things like remotefilelog. | |
2541 | scmutil.prefetchfiles( |
|
2541 | scmutil.prefetchfiles( | |
2542 | self.repo(), |
|
2542 | self.repo(), | |
2543 |
[self.p1().rev() |
|
2543 | [(self.p1().rev(), | |
2544 | scmutil.matchfiles(self.repo(), self._cache.keys()), |
|
2544 | scmutil.matchfiles(self.repo(), self._cache.keys()))], | |
2545 | ) |
|
2545 | ) | |
2546 |
|
2546 | |||
2547 | for path in self._cache.keys(): |
|
2547 | for path in self._cache.keys(): |
@@ -1121,8 +1121,9 b' def _prefetchfiles(repo, ctx, actions):' | |||||
1121 | matchfiles = scmutil.matchfiles |
|
1121 | matchfiles = scmutil.matchfiles | |
1122 | prefetch( |
|
1122 | prefetch( | |
1123 | repo, |
|
1123 | repo, | |
1124 |
[ctx.rev() |
|
1124 | [(ctx.rev(), | |
1125 | matchfiles(repo, [f for sublist in oplist for f, args, msg in sublist]), |
|
1125 | matchfiles(repo, | |
|
1126 | [f for sublist in oplist for f, args, msg in sublist]))], | |||
1126 | ) |
|
1127 | ) | |
1127 |
|
1128 | |||
1128 |
|
1129 |
@@ -2666,7 +2666,11 b' def diffhunks(' | |||||
2666 | prefetchmatch = scmutil.matchfiles( |
|
2666 | prefetchmatch = scmutil.matchfiles( | |
2667 | repo, list(modifiedset | addedset | removedset) |
|
2667 | repo, list(modifiedset | addedset | removedset) | |
2668 | ) |
|
2668 | ) | |
2669 | scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch) |
|
2669 | revmatches = [ | |
|
2670 | (ctx1.rev(), prefetchmatch), | |||
|
2671 | (ctx2.rev(), prefetchmatch), | |||
|
2672 | ] | |||
|
2673 | scmutil.prefetchfiles(repo, revmatches) | |||
2670 |
|
2674 | |||
2671 | def difffn(opts, losedata): |
|
2675 | def difffn(opts, losedata): | |
2672 | return trydiff( |
|
2676 | return trydiff( |
@@ -1880,18 +1880,30 b' class simplekeyvaluefile(object):' | |||||
1880 | ] |
|
1880 | ] | |
1881 |
|
1881 | |||
1882 |
|
1882 | |||
1883 |
def prefetchfiles(repo, rev |
|
1883 | def prefetchfiles(repo, revmatches): | |
1884 | """Invokes the registered file prefetch functions, allowing extensions to |
|
1884 | """Invokes the registered file prefetch functions, allowing extensions to | |
1885 | ensure the corresponding files are available locally, before the command |
|
1885 | ensure the corresponding files are available locally, before the command | |
1886 |
uses them. |
|
1886 | uses them. | |
1887 | if match: |
|
1887 | ||
|
1888 | Args: | |||
|
1889 | revmatches: a list of (revision, match) tuples to indicate the files to | |||
|
1890 | fetch at each revision. If any of the match elements is None, it matches | |||
|
1891 | all files. | |||
|
1892 | """ | |||
|
1893 | def _matcher(m): | |||
|
1894 | if m: | |||
|
1895 | assert isinstance(m, matchmod.basematcher) | |||
1888 | # The command itself will complain about files that don't exist, so |
|
1896 | # The command itself will complain about files that don't exist, so | |
1889 | # don't duplicate the message. |
|
1897 | # don't duplicate the message. | |
1890 |
|
|
1898 | return matchmod.badmatch(m, lambda fn, msg: None) | |
1891 | else: |
|
1899 | else: | |
1892 |
|
|
1900 | return matchall(repo) | |
1893 |
|
1901 | |||
1894 | fileprefetchhooks(repo, revs, match) |
|
1902 | revbadmatches = [ | |
|
1903 | (rev, _matcher(match)) for (rev, match) in revmatches | |||
|
1904 | ] | |||
|
1905 | ||||
|
1906 | fileprefetchhooks(repo, revbadmatches) | |||
1895 |
|
1907 | |||
1896 |
|
1908 | |||
1897 | # a list of (repo, revs, match) prefetch functions |
|
1909 | # a list of (repo, revs, match) prefetch functions |
@@ -639,7 +639,7 b' class hgsubrepo(abstractsubrepo):' | |||||
639 | rev = self._state[1] |
|
639 | rev = self._state[1] | |
640 | ctx = self._repo[rev] |
|
640 | ctx = self._repo[rev] | |
641 | scmutil.prefetchfiles( |
|
641 | scmutil.prefetchfiles( | |
642 |
self._repo, [ctx.rev() |
|
642 | self._repo, [(ctx.rev(), scmutil.matchfiles(self._repo, files))] | |
643 | ) |
|
643 | ) | |
644 | total = abstractsubrepo.archive(self, archiver, prefix, match) |
|
644 | total = abstractsubrepo.archive(self, archiver, prefix, match) | |
645 | for subpath in ctx.substate: |
|
645 | for subpath in ctx.substate: |
General Comments 0
You need to be logged in to leave comments.
Login now