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

Matt Mackall mpm at selenic.com
Wed Jul 9 15:10:14 CDT 2014


On Tue, 2014-07-08 at 03:03 -0700, Gregory Szorc wrote:

> 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.

That line of reasoning is all very good and I'd be inclined to agree
with you if extensions were first-class citizens. But they're explicitly
not: we intentionally sacrifice maintainability of modules for
maintainability of the core. And the complexity of localrepo in
particular has become a very obvious maintenance problem.

However, if this is a big deal, perhaps the answer is a helper in
extensions.py that calls your replacement function if the repo arg is of
a particular class. This probably makes sense for both function and
command wrappers.

Relatedly, lots of our monkeypatch setup work could probably be replaced
with decorators.


However, we can perhaps add a magic wrapper to extensions that does some
sort of class matching on repo args for you.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list