[PATCH 1 of 2] localrepo: add afterpush()

Gregory Szorc gregory.szorc at gmail.com
Tue Jul 8 05:03:03 CDT 2014


On Jul 8, 2014, at 2:31, Pierre-Yves David <pierre-yves.david at ens-lyon.org> wrote:
> 
> 
> 
>> On 07/08/2014 05:43 AM, Gregory Szorc wrote:
>> # HG changeset patch
>> # User Gregory Szorc <gregory.szorc at gmail.com>
>> # Date 1404785357 25200
>> #      Mon Jul 07 19:09:17 2014 -0700
>> # Node ID 30333e516874716b8d9b41450282d1f22b87eba1
>> # Parent  7537e57f5dbd0805aad3c9e5e4f7dd8bbf6bbde1
>> localrepo: add afterpush()
> 
> The trend is to remove method from localrepo, not adding new ones.
> 
> (`localrepo.push(…)` was not thrown in fire as a courtesy to all the extension that may rely on it.)
> 
> The hook in itself is a good idea, but please add it in the `mercurial.exchange` module.

An issue with moving things out of localrepo is that changes to module level symbols are global and apply to all repos. With localrepo, the pattern is to dynamically declare a new repo class during reposetup and only hack up the repo instances you want. I find this approach far more maintainable than peppering isinstance/hasattribute checks in monkeypatched module functions.

FWIW, this reasoning is why I'm a fan of grouping related functions in classes over the traditional Mercurial "style" of module level functions. With classes, I can go in with a scalpel and adjust __class__ on a per instance basis. When that instance is destroyed, the hacks die with it. Adjusting module symbols is juggling chainsaws by comparison. There's too many considerations, especially in persistent processes, such as hgweb and the command server. I'd prefer we limit the surface area for bugs by encouraging instance specific hacking over global/module hacking.


More information about the Mercurial-devel mailing list