[PATCH 3 of 7 V2] cmdutil: convert _revertprefetch() to a generic stored file hook (API)

Matt Harbison mharbison72 at gmail.com
Tue Feb 6 08:02:30 EST 2018


> On Feb 6, 2018, at 7:20 AM, Yuya Nishihara <yuya at tcha.org> wrote:
> 
>> 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)
>> 
>> +    """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().

Would it be better to keep it in cmdutil, and call it  just before calling applyupdates()?  Calling mergemod.prefetchfiles() from archive, for example, seems weird, doesn’t it?  Or am I misunderstanding?

> - it could be a list of callback functions, instead of carefully wrapping
>   the function itself

Just a raw list that everything can access, or should it have add/remove methods too?  I’ve seen both patterns with hook registration, IIRC.

> - should be a public function as archival.py depends on it for example?

Good idea



More information about the Mercurial-devel mailing list