Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 45072:a56ba57c837d
scmutil: allowing different files to be prefetched per revision
The old API takes a list of revision separate from the file matcher, and thus
provides no way to fetch different sets of files from each revision. In
preparation for adding one such usage, I'm changing the API to take a list of
(revision, file matcher) tuples instead.
Differential Revision: https://phab.mercurial-scm.org/D8721
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Thu, 09 Jul 2020 18:48:55 -0700 |
parents | 0c40d2d151cb |
children | 8cce9f77ca73 |
comparison
equal
deleted
inserted
replaced
45071:196ba4d4eb86 | 45072:a56ba57c837d |
---|---|
2136 allfiles = set() | 2136 allfiles = set() |
2137 for rev in revs: | 2137 for rev in revs: |
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 scmutil.prefetchfiles(repo, revs, scmutil.matchfiles(repo, allfiles)) | 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( |
2145 repo, | 2147 repo, |
2146 revs, | 2148 revs, |
2995 mfl = repo.manifestlog | 2997 mfl = repo.manifestlog |
2996 mfnode = ctx.manifestnode() | 2998 mfnode = ctx.manifestnode() |
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()], matcher) | 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()], matcher) | 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) |
3011 err = 0 | 3013 err = 0 |
3012 | 3014 |
3767 | 3769 |
3768 if not opts.get(b'dry_run'): | 3770 if not opts.get(b'dry_run'): |
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] | |
3776 ) | |
3773 prefetch( | 3777 prefetch( |
3774 repo, | 3778 repo, [(ctx.rev(), matchfiles)], |
3775 [ctx.rev()], | |
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( |
3780 repo, | 3782 repo, |
3781 parents, | 3783 parents, |