diff --git a/remotefilelog/__init__.py b/remotefilelog/__init__.py --- a/remotefilelog/__init__.py +++ b/remotefilelog/__init__.py @@ -77,6 +77,7 @@ localrepo, match, merge, + node as nodemod, patch, registrar, repair, @@ -554,7 +555,14 @@ wrapfunction(hg, 'verify', _verify) if util.safehasattr(cmdutil, '_revertprefetch'): + # This mechanism was removed in f1f8b655da32, but is more focused than + # the _fileprefetchhook mechanism, so we prefer it for now. wrapfunction(cmdutil, '_revertprefetch', _revertprefetch) + elif util.safehasattr(scmutil, 'fileprefetchhooks'): + # This mechanism may overlap some of the other prefetch mechanisms we + # established earlier, performing duplicate or extraneous work, but it + # works after f1f8b655da32. + scmutil.fileprefetchhooks.add('remotefilelog', _fileprefetchhook) else: wrapfunction(cmdutil, 'revert', revert) @@ -922,7 +930,7 @@ def _revertprefetch(orig, repo, ctx, *files): # prefetch data that needs to be reverted - # used for new mercurial version + # used for new mercurial version up until f1f8b655da32 if shallowrepo.requirement in repo.requirements: allfiles = [] mf = ctx.manifest() @@ -934,6 +942,20 @@ repo.fileservice.prefetch(allfiles) return orig(repo, ctx, *files) +def _fileprefetchhook(repo, revs, match): + if shallowrepo.requirement in repo.requirements: + allfiles = [] + for rev in revs: + if rev == nodemod.wdirrev or rev is None: + continue + ctx = repo[rev] + mf = ctx.manifest() + sparsematch = repo.maybesparsematch(ctx.rev()) + for path in ctx.walk(match): + if (not sparsematch or sparsematch(path)) and path in mf: + allfiles.append((path, hex(mf[path]))) + repo.fileservice.prefetch(allfiles) + @command('debugremotefilelog', [ ('d', 'decompress', None, _('decompress the filelog first')), ], _('hg debugremotefilelog '), norepo=True)