comparison mercurial/cmdutil.py @ 36137:f52a9336ac5f

cmdutil: convert the prefetchfiles() hook to a callback mechanism (API) Yuya suggested a list of callbacks instead of function wrapping. This means that one extension can't block another from processing the list. .. api:: File prefetching is now handled by registering a callback with scmutil.fileprefetchhooks.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 11 Feb 2018 00:23:57 -0500
parents 46a54de96a54
children 3a90159c2c2e
comparison
equal deleted inserted replaced
36136:6767e7ce2c31 36137:f52a9336ac5f
2863 break 2863 break
2864 2864
2865 if not opts.get('dry_run'): 2865 if not opts.get('dry_run'):
2866 needdata = ('revert', 'add', 'undelete') 2866 needdata = ('revert', 'add', 'undelete')
2867 if _revertprefetch is not _revertprefetchstub: 2867 if _revertprefetch is not _revertprefetchstub:
2868 ui.deprecwarn("'cmdutil._revertprefetch' is deprecated, use " 2868 ui.deprecwarn("'cmdutil._revertprefetch' is deprecated, "
2869 "'cmdutil._prefetchfiles'", '4.6', stacklevel=1) 2869 "add a callback to 'scmutil.fileprefetchhooks'",
2870 '4.6', stacklevel=1)
2870 _revertprefetch(repo, ctx, 2871 _revertprefetch(repo, ctx,
2871 *[actions[name][0] for name in needdata]) 2872 *[actions[name][0] for name in needdata])
2872 oplist = [actions[name][0] for name in needdata] 2873 oplist = [actions[name][0] for name in needdata]
2873 _prefetchfiles(repo, ctx, 2874 _prefetchfiles(repo, ctx,
2874 [f for sublist in oplist for f in sublist]) 2875 [f for sublist in oplist for f in sublist])
2891 _revertprefetch = _revertprefetchstub 2892 _revertprefetch = _revertprefetchstub
2892 2893
2893 def _prefetchfiles(repo, ctx, files): 2894 def _prefetchfiles(repo, ctx, files):
2894 """Let extensions changing the storage layer prefetch content for any non 2895 """Let extensions changing the storage layer prefetch content for any non
2895 merge based command.""" 2896 merge based command."""
2897 scmutil.fileprefetchhooks(repo, ctx, files)
2896 2898
2897 def _performrevert(repo, parents, ctx, actions, interactive=False, 2899 def _performrevert(repo, parents, ctx, actions, interactive=False,
2898 tobackup=None): 2900 tobackup=None):
2899 """function that actually perform all the actions computed for revert 2901 """function that actually perform all the actions computed for revert
2900 2902