Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 37762:7269b87f817c
scmutil: teach the file prefetch hook to handle multiple commits
The remainder of the commands that need prefetch deal with multiple revisions.
I initially coded this as a separate hook, but then it needed a list of files
to handle `diff` and `grep`, so it didn't seem worth keeping them separate.
Not every matcher will emit bad file messages (some are built from a list of
files that are known to exist). But it seems better to filter this in one place
than to push this on either each caller or each hook implementation.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 14 Apr 2018 18:50:45 -0400 |
parents | e7bf5a73e4e1 |
children | b54404d66f7e |
comparison
equal
deleted
inserted
replaced
37761:ff6b0a20849d | 37762:7269b87f817c |
---|---|
2290 file = matcher.files()[0] | 2290 file = matcher.files()[0] |
2291 mfl = repo.manifestlog | 2291 mfl = repo.manifestlog |
2292 mfnode = ctx.manifestnode() | 2292 mfnode = ctx.manifestnode() |
2293 try: | 2293 try: |
2294 if mfnode and mfl[mfnode].find(file)[0]: | 2294 if mfnode and mfl[mfnode].find(file)[0]: |
2295 scmutil.fileprefetchhooks(repo, ctx, [file]) | 2295 scmutil.prefetchfiles(repo, [ctx.rev()], matcher) |
2296 write(file) | 2296 write(file) |
2297 return 0 | 2297 return 0 |
2298 except KeyError: | 2298 except KeyError: |
2299 pass | 2299 pass |
2300 | 2300 |
2301 files = [f for f in ctx.walk(matcher)] | 2301 scmutil.prefetchfiles(repo, [ctx.rev()], matcher) |
2302 scmutil.fileprefetchhooks(repo, ctx, files) | 2302 |
2303 | 2303 for abs in ctx.walk(matcher): |
2304 for abs in files: | |
2305 write(abs) | 2304 write(abs) |
2306 err = 0 | 2305 err = 0 |
2307 | 2306 |
2308 for subpath in sorted(ctx.substate): | 2307 for subpath in sorted(ctx.substate): |
2309 sub = ctx.sub(subpath) | 2308 sub = ctx.sub(subpath) |
2977 "add a callback to 'scmutil.fileprefetchhooks'", | 2976 "add a callback to 'scmutil.fileprefetchhooks'", |
2978 '4.6', stacklevel=1) | 2977 '4.6', stacklevel=1) |
2979 _revertprefetch(repo, ctx, | 2978 _revertprefetch(repo, ctx, |
2980 *[actions[name][0] for name in needdata]) | 2979 *[actions[name][0] for name in needdata]) |
2981 oplist = [actions[name][0] for name in needdata] | 2980 oplist = [actions[name][0] for name in needdata] |
2982 prefetch = scmutil.fileprefetchhooks | 2981 prefetch = scmutil.prefetchfiles |
2983 prefetch(repo, ctx, [f for sublist in oplist for f in sublist]) | 2982 matchfiles = scmutil.matchfiles |
2983 prefetch(repo, [ctx.rev()], | |
2984 matchfiles(repo, | |
2985 [f for sublist in oplist for f in sublist])) | |
2984 _performrevert(repo, parents, ctx, actions, interactive, tobackup) | 2986 _performrevert(repo, parents, ctx, actions, interactive, tobackup) |
2985 | 2987 |
2986 if targetsubs: | 2988 if targetsubs: |
2987 # Revert the subrepos on the revert list | 2989 # Revert the subrepos on the revert list |
2988 for sub in targetsubs: | 2990 for sub in targetsubs: |