changeset 41293:86f6b441adea stable

help: modernize the example for command registration
author Matt Harbison <matt_harbison@yahoo.com>
date Fri, 18 Jan 2019 23:13:04 -0500
parents 74525c3e9476
children b5d7413e4009
files mercurial/help/internals/extensions.txt
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help/internals/extensions.txt	Fri Jan 18 13:32:02 2019 -0500
+++ b/mercurial/help/internals/extensions.txt	Fri Jan 18 23:13:04 2019 -0500
@@ -28,11 +28,16 @@
 
 Example using ``@command`` decorator (requires Mercurial 1.9)::
 
-    from mercurial import cmdutil
     from mercurial.i18n import _
 
     cmdtable = {}
-    command = cmdutil.command(cmdtable)
+    try:
+        from mercurial import registrar
+        command = registrar.command(cmdtable)
+    except (AttributeError, ImportError):
+        # Fallback to hg < 4.3 support
+        from mercurial import cmdutil
+        command = cmdutil.command(cmdtable)
 
     @command('print-parents',
         [('s', 'short', None, _('print short form')),