exthelper: add a cautionary note about adding attributes to containers
authorMatt Harbison <matt_harbison@yahoo.com>
Sun, 23 Dec 2018 14:52:43 -0500
changeset 41057 f7863606d4ff
parent 41056 41cd64a81dd9
child 41058 c61b8dfb07c8
exthelper: add a cautionary note about adding attributes to containers
mercurial/exthelper.py
--- a/mercurial/exthelper.py	Thu Dec 27 00:10:40 2018 -0500
+++ b/mercurial/exthelper.py	Sun Dec 23 14:52:43 2018 -0500
@@ -246,6 +246,15 @@
         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')