# HG changeset patch # User Matt Harbison <matt_harbi...@yahoo.com> # Date 1545594763 18000 # Sun Dec 23 14:52:43 2018 -0500 # Node ID 900b0af134505b6e5d227888212a17d8dd68342a # Parent 0214962773921f15333f11d97212b307422aaaf5 exthelper: add a cautionary note about adding attributes to containers
diff --git a/mercurial/exthelper.py b/mercurial/exthelper.py --- a/mercurial/exthelper.py +++ b/mercurial/exthelper.py @@ -255,6 +255,15 @@ class exthelper(object): This function takes two arguments, the container and the name of the function to wrap. The wrapping is performed during `uisetup`. + Adding attributes to a container like this is discouraged, because the + container modification is visible even in repositories that do not + have the extension loaded. Therefore, care must be taken that the + function doesn't make assumptions that the extension was loaded for the + current repository. For `ui` and `repo` instances, a better option is + to subclass the instance in `uipopulate` and `reposetup` respectively. + + https://www.mercurial-scm.org/wiki/WritingExtensions + example:: @eh.addattr(context.changectx, 'babar') _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel