[Updated] D8721: scmutil: allowing different files to be prefetched per revision
rdamazio (Rodrigo Damazio Bovendorp)
phabricator at mercurial-scm.org
Sat Jul 11 02:11:08 UTC 2020
rdamazio marked an inline comment as done.
rdamazio updated this revision to Diff 21847.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D8721?vs=21844&id=21847
BRANCH
default
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D8721/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D8721
AFFECTED FILES
hgext/lfs/wrapper.py
hgext/remotefilelog/__init__.py
mercurial/archival.py
mercurial/cmdutil.py
mercurial/context.py
mercurial/merge.py
mercurial/patch.py
mercurial/scmutil.py
mercurial/subrepo.py
CHANGE DETAILS
diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -639,7 +639,7 @@
rev = self._state[1]
ctx = self._repo[rev]
scmutil.prefetchfiles(
- self._repo, [ctx.rev()], scmutil.matchfiles(self._repo, files)
+ self._repo, [(ctx.rev(), scmutil.matchfiles(self._repo, files))]
)
total = abstractsubrepo.archive(self, archiver, prefix, match)
for subpath in ctx.substate:
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1880,18 +1880,29 @@
]
-def prefetchfiles(repo, revs, match):
+def prefetchfiles(repo, revmatches):
"""Invokes the registered file prefetch functions, allowing extensions to
ensure the corresponding files are available locally, before the command
- uses them."""
- if match:
- # The command itself will complain about files that don't exist, so
- # don't duplicate the message.
- match = matchmod.badmatch(match, lambda fn, msg: None)
- else:
- match = matchall(repo)
+ uses them.
+
+ Args:
+ revmatches: a list of (revision, match) tuples to indicate the files to
+ fetch at each revision. If any of the match elements is None, it matches
+ all files.
+ """
- fileprefetchhooks(repo, revs, match)
+ def _matcher(m):
+ if m:
+ assert isinstance(m, matchmod.basematcher)
+ # The command itself will complain about files that don't exist, so
+ # don't duplicate the message.
+ return matchmod.badmatch(m, lambda fn, msg: None)
+ else:
+ return matchall(repo)
+
+ revbadmatches = [(rev, _matcher(match)) for (rev, match) in revmatches]
+
+ fileprefetchhooks(repo, revbadmatches)
# a list of (repo, revs, match) prefetch functions
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2666,7 +2666,11 @@
prefetchmatch = scmutil.matchfiles(
repo, list(modifiedset | addedset | removedset)
)
- scmutil.prefetchfiles(repo, [ctx1.rev(), ctx2.rev()], prefetchmatch)
+ revmatches = [
+ (ctx1.rev(), prefetchmatch),
+ (ctx2.rev(), prefetchmatch),
+ ]
+ scmutil.prefetchfiles(repo, revmatches)
def difffn(opts, losedata):
return trydiff(
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -1121,8 +1121,14 @@
matchfiles = scmutil.matchfiles
prefetch(
repo,
- [ctx.rev()],
- matchfiles(repo, [f for sublist in oplist for f, args, msg in sublist]),
+ [
+ (
+ ctx.rev(),
+ matchfiles(
+ repo, [f for sublist in oplist for f, args, msg in sublist]
+ ),
+ )
+ ],
)
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -2540,8 +2540,12 @@
# using things like remotefilelog.
scmutil.prefetchfiles(
self.repo(),
- [self.p1().rev()],
- scmutil.matchfiles(self.repo(), self._cache.keys()),
+ [
+ (
+ self.p1().rev(),
+ scmutil.matchfiles(self.repo(), self._cache.keys()),
+ )
+ ],
)
for path in self._cache.keys():
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2138,7 +2138,9 @@
for file in repo[rev].files():
if not match or match(file):
allfiles.add(file)
- scmutil.prefetchfiles(repo, revs, scmutil.matchfiles(repo, allfiles))
+ match = scmutil.matchfiles(repo, allfiles)
+ revmatches = [(rev, match) for rev in revs]
+ scmutil.prefetchfiles(repo, revmatches)
def export(
@@ -2997,14 +2999,14 @@
try:
if mfnode and mfl[mfnode].find(file)[0]:
if _catfmtneedsdata(basefm):
- scmutil.prefetchfiles(repo, [ctx.rev()], matcher)
+ scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)])
write(file)
return 0
except KeyError:
pass
if _catfmtneedsdata(basefm):
- scmutil.prefetchfiles(repo, [ctx.rev()], matcher)
+ scmutil.prefetchfiles(repo, [(ctx.rev(), matcher)])
for abs in ctx.walk(matcher):
write(abs)
@@ -3769,11 +3771,11 @@
needdata = (b'revert', b'add', b'undelete')
oplist = [actions[name][0] for name in needdata]
prefetch = scmutil.prefetchfiles
- matchfiles = scmutil.matchfiles
+ matchfiles = scmutil.matchfiles(
+ repo, [f for sublist in oplist for f in sublist]
+ )
prefetch(
- repo,
- [ctx.rev()],
- matchfiles(repo, [f for sublist in oplist for f in sublist]),
+ repo, [(ctx.rev(), matchfiles)],
)
match = scmutil.match(repo[None], pats)
_performrevert(
diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -364,7 +364,7 @@
if total:
files.sort()
scmutil.prefetchfiles(
- repo, [ctx.rev()], scmutil.matchfiles(repo, files)
+ repo, [(ctx.rev(), scmutil.matchfiles(repo, files))]
)
progress = repo.ui.makeprogress(
_(b'archiving'), unit=_(b'files'), total=total
diff --git a/hgext/remotefilelog/__init__.py b/hgext/remotefilelog/__init__.py
--- a/hgext/remotefilelog/__init__.py
+++ b/hgext/remotefilelog/__init__.py
@@ -148,7 +148,7 @@
extensions,
hg,
localrepo,
- match,
+ match as matchmod,
merge,
node as nodemod,
patch,
@@ -824,12 +824,12 @@
# i18n: "filelog" is a keyword
pat = revset.getstring(x, _(b"filelog requires a pattern"))
- m = match.match(
+ m = matchmod.match(
repo.root, repo.getcwd(), [pat], default=b'relpath', ctx=repo[None]
)
s = set()
- if not match.patkind(pat):
+ if not matchmod.patkind(pat):
# slow
for r in subset:
ctx = repo[r]
@@ -1118,10 +1118,10 @@
return orig(repo, remote, *args, **kwargs)
-def _fileprefetchhook(repo, revs, match):
+def _fileprefetchhook(repo, revmatches):
if isenabled(repo):
allfiles = []
- for rev in revs:
+ for rev, match in revmatches:
if rev == nodemod.wdirrev or rev is None:
continue
ctx = repo[rev]
diff --git a/hgext/lfs/wrapper.py b/hgext/lfs/wrapper.py
--- a/hgext/lfs/wrapper.py
+++ b/hgext/lfs/wrapper.py
@@ -337,7 +337,7 @@
setattr(self, name, getattr(othervfs, name))
-def _prefetchfiles(repo, revs, match):
+def _prefetchfiles(repo, revmatches):
"""Ensure that required LFS blobs are present, fetching them as a group if
needed."""
if not util.safehasattr(repo.svfs, b'lfslocalblobstore'):
@@ -347,7 +347,7 @@
oids = set()
localstore = repo.svfs.lfslocalblobstore
- for rev in revs:
+ for rev, match in revmatches:
ctx = repo[rev]
for f in ctx.walk(match):
p = pointerfromctx(ctx, f)
To: rdamazio, #hg-reviewers, pulkit
Cc: mjacob, martinvonz, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200711/96cbe3f0/attachment-0002.html>
More information about the Mercurial-patches
mailing list