Show More
@@ -337,7 +337,7 b' def vfsinit(orig, self, othervfs):' | |||
|
337 | 337 | setattr(self, name, getattr(othervfs, name)) |
|
338 | 338 | |
|
339 | 339 | |
|
340 |
def _prefetchfiles(repo, rev |
|
|
340 | def _prefetchfiles(repo, revmatches): | |
|
341 | 341 | """Ensure that required LFS blobs are present, fetching them as a group if |
|
342 | 342 | needed.""" |
|
343 | 343 | if not util.safehasattr(repo.svfs, b'lfslocalblobstore'): |
@@ -347,7 +347,7 b' def _prefetchfiles(repo, revs, match):' | |||
|
347 | 347 | oids = set() |
|
348 | 348 | localstore = repo.svfs.lfslocalblobstore |
|
349 | 349 | |
|
350 | for rev in revs: | |
|
350 | for rev, match in revmatches: | |
|
351 | 351 | ctx = repo[rev] |
|
352 | 352 | for f in ctx.walk(match): |
|
353 | 353 | p = pointerfromctx(ctx, f) |
@@ -148,7 +148,7 b' from mercurial import (' | |||
|
148 | 148 | extensions, |
|
149 | 149 | hg, |
|
150 | 150 | localrepo, |
|
151 | match, | |
|
151 | match as matchmod, | |
|
152 | 152 | merge, |
|
153 | 153 | node as nodemod, |
|
154 | 154 | patch, |
@@ -824,12 +824,12 b' def filelogrevset(orig, repo, subset, x)' | |||
|
824 | 824 | |
|
825 | 825 | # i18n: "filelog" is a keyword |
|
826 | 826 | pat = revset.getstring(x, _(b"filelog requires a pattern")) |
|
827 | m = match.match( | |
|
827 | m = matchmod.match( | |
|
828 | 828 | repo.root, repo.getcwd(), [pat], default=b'relpath', ctx=repo[None] |
|
829 | 829 | ) |
|
830 | 830 | s = set() |
|
831 | 831 | |
|
832 | if not match.patkind(pat): | |
|
832 | if not matchmod.patkind(pat): | |
|
833 | 833 | # slow |
|
834 | 834 | for r in subset: |
|
835 | 835 | ctx = repo[r] |
@@ -1118,10 +1118,10 b' def exchangepull(orig, repo, remote, *ar' | |||
|
1118 | 1118 | return orig(repo, remote, *args, **kwargs) |
|
1119 | 1119 | |
|
1120 | 1120 | |
|
1121 |
def _fileprefetchhook(repo, rev |
|
|
1121 | def _fileprefetchhook(repo, revmatches): | |
|
1122 | 1122 | if isenabled(repo): |
|
1123 | 1123 | allfiles = [] |
|
1124 | for rev in revs: | |
|
1124 | for rev, match in revmatches: | |
|
1125 | 1125 | if rev == nodemod.wdirrev or rev is None: |
|
1126 | 1126 | continue |
|
1127 | 1127 | ctx = repo[rev] |
@@ -364,7 +364,7 b' def archive(' | |||
|
364 | 364 | if total: |
|
365 | 365 | files.sort() |
|
366 | 366 | scmutil.prefetchfiles( |
|
367 |
repo, [ctx.rev() |
|
|
367 | repo, [(ctx.rev(), scmutil.matchfiles(repo, files))] | |
|
368 | 368 | ) |
|
369 | 369 | progress = repo.ui.makeprogress( |
|
370 | 370 | _(b'archiving'), unit=_(b'files'), total=total |
@@ -2138,7 +2138,9 b' def _prefetchchangedfiles(repo, revs, ma' | |||
|
2138 | 2138 | for file in repo[rev].files(): |
|
2139 | 2139 | if not match or match(file): |
|
2140 | 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 | 2146 | def export( |
@@ -2997,14 +2999,14 b' def cat(ui, repo, ctx, matcher, basefm, ' | |||
|
2997 | 2999 | try: |
|
2998 | 3000 | if mfnode and mfl[mfnode].find(file)[0]: |
|
2999 | 3001 | if _catfmtneedsdata(basefm): |
|
3000 |
scmutil.prefetchfiles(repo, [ctx.rev() |
|
|
3002 | scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)]) | |
|
3001 | 3003 | write(file) |
|
3002 | 3004 | return 0 |
|
3003 | 3005 | except KeyError: |
|
3004 | 3006 | pass |
|
3005 | 3007 | |
|
3006 | 3008 | if _catfmtneedsdata(basefm): |
|
3007 |
scmutil.prefetchfiles(repo, [ctx.rev() |
|
|
3009 | scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)]) | |
|
3008 | 3010 | |
|
3009 | 3011 | for abs in ctx.walk(matcher): |
|
3010 | 3012 | write(abs) |
@@ -3769,11 +3771,11 b' def revert(ui, repo, ctx, parents, *pats' | |||
|
3769 | 3771 | needdata = (b'revert', b'add', b'undelete') |
|
3770 | 3772 | oplist = [actions[name][0] for name in needdata] |
|
3771 | 3773 | prefetch = scmutil.prefetchfiles |
|
3772 | matchfiles = scmutil.matchfiles | |
|
3774 | matchfiles = scmutil.matchfiles( | |
|
3775 | repo, [f for sublist in oplist for f in sublist] | |
|
3776 | ) | |
|
3773 | 3777 | prefetch( |
|
3774 | repo, | |
|
3775 | [ctx.rev()], | |
|
3776 | matchfiles(repo, [f for sublist in oplist for f in sublist]), | |
|
3778 | repo, [(ctx.rev(), matchfiles)], | |
|
3777 | 3779 | ) |
|
3778 | 3780 | match = scmutil.match(repo[None], pats) |
|
3779 | 3781 | _performrevert( |
@@ -2540,8 +2540,12 b' class overlayworkingctx(committablectx):' | |||
|
2540 | 2540 | # using things like remotefilelog. |
|
2541 | 2541 | scmutil.prefetchfiles( |
|
2542 | 2542 | self.repo(), |
|
2543 |
[ |
|
|
2544 | scmutil.matchfiles(self.repo(), self._cache.keys()), | |
|
2543 | [ | |
|
2544 | ( | |
|
2545 | self.p1().rev(), | |
|
2546 | scmutil.matchfiles(self.repo(), self._cache.keys()), | |
|
2547 | ) | |
|
2548 | ], | |
|
2545 | 2549 | ) |
|
2546 | 2550 | |
|
2547 | 2551 | for path in self._cache.keys(): |
@@ -1121,8 +1121,14 b' def _prefetchfiles(repo, ctx, actions):' | |||
|
1121 | 1121 | matchfiles = scmutil.matchfiles |
|
1122 | 1122 | prefetch( |
|
1123 | 1123 | repo, |
|
1124 |
[ |
|
|
1125 | matchfiles(repo, [f for sublist in oplist for f, args, msg in sublist]), | |
|
1124 | [ | |
|
1125 | ( | |
|
1126 | ctx.rev(), | |
|
1127 | matchfiles( | |
|
1128 | repo, [f for sublist in oplist for f, args, msg in sublist] | |
|
1129 | ), | |
|
1130 | ) | |
|
1131 | ], | |
|
1126 | 1132 | ) |
|
1127 | 1133 | |
|
1128 | 1134 |
@@ -2666,7 +2666,11 b' def diffhunks(' | |||
|
2666 | 2666 | prefetchmatch = scmutil.matchfiles( |
|
2667 | 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 | 2675 | def difffn(opts, losedata): |
|
2672 | 2676 | return trydiff( |
@@ -1880,18 +1880,29 b' class simplekeyvaluefile(object):' | |||
|
1880 | 1880 | ] |
|
1881 | 1881 | |
|
1882 | 1882 | |
|
1883 |
def prefetchfiles(repo, rev |
|
|
1883 | def prefetchfiles(repo, revmatches): | |
|
1884 | 1884 | """Invokes the registered file prefetch functions, allowing extensions to |
|
1885 | 1885 | ensure the corresponding files are available locally, before the command |
|
1886 |
uses them. |
|
|
1887 | if match: | |
|
1888 | # The command itself will complain about files that don't exist, so | |
|
1889 | # don't duplicate the message. | |
|
1890 | match = matchmod.badmatch(match, lambda fn, msg: None) | |
|
1891 | else: | |
|
1892 | match = matchall(repo) | |
|
1886 | uses them. | |
|
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 | 1893 | |
|
1894 | fileprefetchhooks(repo, revs, match) | |
|
1894 | def _matcher(m): | |
|
1895 | if m: | |
|
1896 | assert isinstance(m, matchmod.basematcher) | |
|
1897 | # The command itself will complain about files that don't exist, so | |
|
1898 | # don't duplicate the message. | |
|
1899 | return matchmod.badmatch(m, lambda fn, msg: None) | |
|
1900 | else: | |
|
1901 | return matchall(repo) | |
|
1902 | ||
|
1903 | revbadmatches = [(rev, _matcher(match)) for (rev, match) in revmatches] | |
|
1904 | ||
|
1905 | fileprefetchhooks(repo, revbadmatches) | |
|
1895 | 1906 | |
|
1896 | 1907 | |
|
1897 | 1908 | # a list of (repo, revs, match) prefetch functions |
@@ -639,7 +639,7 b' class hgsubrepo(abstractsubrepo):' | |||
|
639 | 639 | rev = self._state[1] |
|
640 | 640 | ctx = self._repo[rev] |
|
641 | 641 | scmutil.prefetchfiles( |
|
642 |
self._repo, [ctx.rev() |
|
|
642 | self._repo, [(ctx.rev(), scmutil.matchfiles(self._repo, files))] | |
|
643 | 643 | ) |
|
644 | 644 | total = abstractsubrepo.archive(self, archiver, prefix, match) |
|
645 | 645 | for subpath in ctx.substate: |
General Comments 0
You need to be logged in to leave comments.
Login now