[PATCH 3 of 7 V2] cmdutil: convert _revertprefetch() to a generic stored file hook (API)
Yuya Nishihara
yuya at tcha.org
Tue Feb 6 12:20:42 UTC 2018
On Tue, 06 Feb 2018 00:29:06 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison at yahoo.com>
> # Date 1517771668 18000
> # Sun Feb 04 14:14:28 2018 -0500
> # Node ID ab23d9644edaf62b2c3927b735d2170fc76ca711
> # Parent 94d427f881cfca5cae792c5eac4bf00e942106ec
> cmdutil: convert _revertprefetch() to a generic stored file hook (API)
> --- a/mercurial/cmdutil.py
> +++ b/mercurial/cmdutil.py
> @@ -2862,7 +2862,14 @@
>
> if not opts.get('dry_run'):
> needdata = ('revert', 'add', 'undelete')
> - _revertprefetch(repo, ctx, *[actions[name][0] for name in needdata])
> + if _revertprefetch is not _revertprefetchstub:
> + ui.deprecwarn("'cmdutil._revertprefetch' is deprecated, use "
> + "'cmdutil._prefetchfiles'", '4.6', stacklevel=1)
> + _revertprefetch(repo, ctx,
> + *[actions[name][0] for name in needdata])
> + oplist = [actions[name][0] for name in needdata]
> + _prefetchfiles(repo, ctx,
> + [f for sublist in oplist for f in sublist])
> _performrevert(repo, parents, ctx, actions, interactive, tobackup)
>
> if targetsubs:
> @@ -2875,8 +2882,15 @@
> raise error.Abort("subrepository '%s' does not exist in %s!"
> % (sub, short(ctx.node())))
>
> -def _revertprefetch(repo, ctx, *files):
> - """Let extension changing the storage layer prefetch content"""
> +def _revertprefetchstub():
Restored the original arguments in case it's called by wrapper.
> + """Stub method for detecting extension wrapping of _revertprefetch(), to
> + issue a deprecation warning."""
> +
> +_revertprefetch = _revertprefetchstub
> +
> +def _prefetchfiles(repo, ctx, files):
> + """Let extensions changing the storage layer prefetch content for any non
> + merge based command."""
Random ideas:
- prefetchfiles() could be hosted by mergemod so lfs won't need to wrap
applyupdates().
- it could be a list of callback functions, instead of carefully wrapping
the function itself
- should be a public function as archival.py depends on it for example?
More information about the Mercurial-devel
mailing list