Patchwork [1,of,2,STABLE] help: modernize the example for command registration

login
register
mail settings
Submitter Matt Harbison
Date Jan. 19, 2019, 5:29 a.m.
Message ID <9b57d98e8fe910d03357.1547875769@Envy>
Download mbox | patch
Permalink /patch/37883/
State Accepted
Headers show

Comments

Matt Harbison - Jan. 19, 2019, 5:29 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1547871184 18000
#      Fri Jan 18 23:13:04 2019 -0500
# Branch stable
# Node ID 9b57d98e8fe910d033575fadeac91be1eae59f6f
# Parent  74525c3e9476db425024f1a8573e66f0473f7a81
help: modernize the example for command registration
Yuya Nishihara - Jan. 19, 2019, 11:11 a.m.
On Sat, 19 Jan 2019 00:29:29 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1547871184 18000
> #      Fri Jan 18 23:13:04 2019 -0500
> # Branch stable
> # Node ID 9b57d98e8fe910d033575fadeac91be1eae59f6f
> # Parent  74525c3e9476db425024f1a8573e66f0473f7a81
> help: modernize the example for command registration

Queued for stable, thanks.

Patch

diff --git a/mercurial/help/internals/extensions.txt b/mercurial/help/internals/extensions.txt
--- a/mercurial/help/internals/extensions.txt
+++ b/mercurial/help/internals/extensions.txt
@@ -28,11 +28,16 @@  registered to the ``cmdtable`` by ``@com
 
 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')),