[PATCH 1 of 2 STABLE] help: modernize the example for command registration
Matt Harbison
mharbison72 at gmail.com
Sat Jan 19 05:29:29 UTC 2019
# HG changeset patch
# User Matt Harbison <matt_harbison at 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
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')),
More information about the Mercurial-devel
mailing list