help: modernize the example for command registration stable
authorMatt Harbison <matt_harbison@yahoo.com>
Fri, 18 Jan 2019 23:13:04 -0500
branchstable
changeset 41293 86f6b441adea
parent 41292 74525c3e9476
child 41294 b5d7413e4009
help: modernize the example for command registration
mercurial/help/internals/extensions.txt
--- 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')),