changeset 248:436b2db75a34

cmdutil.command is deprecated: use registrar.command instead; also need always a repository for the commands: inferrepo=True
author Franz Glasner <hg@dom66.de>
date Thu, 03 Jan 2019 23:17:13 +0100
parents d23d3d97c106
children e97f6f6ed7c5
files extensions/kwarchive.py extensions/revinfo.py
diffstat 2 files changed, 23 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/kwarchive.py	Thu Dec 20 00:01:59 2018 +0100
+++ b/extensions/kwarchive.py	Thu Jan 03 23:17:13 2019 +0100
@@ -89,6 +89,10 @@
 from mercurial.i18n import _
 from mercurial import (archival, config, cmdutil, error, match,
                        pycompat, scmutil, templatefilters, util, node)
+try:
+    from mercurial import registrar
+except ImportError:
+    registrar = None
 
 
 testedwith = "4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1"
@@ -107,7 +111,10 @@
 
 cmdtable = {}
 
-command = cmdutil.command(cmdtable)
+if registrar:
+    command = registrar.command(cmdtable)
+else:
+    command = cmdutil.command(cmdtable)
 
 
 def getversion():
@@ -147,7 +154,8 @@
         ('', "path-filter", "short", _("determine how the path will be printed")),
         ('', "user-filter", "user", _("the part of the user to be printed"), _("USERFILTER"))
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
-    _('[OPTION]... DEST'))
+    _('[OPTION]... DEST'),
+    inferrepo=True)
 def kwarchive(ui, repo, dest, **opts):
     '''create an unversioned archive of a repository revision with some keywords expanded
 
@@ -276,7 +284,8 @@
         ('', "reST", None, _("output in reST substitution definition syntax")),
         ('', "no-file", None, _("don't show file-dependent keywords")),
     ] + cmdutil.subrepoopts + cmdutil.walkopts,
-    _('[OPTION]...'))
+    _('[OPTION]...'),
+    inferrepo=True)
 def kwprint(ui, repo, **opts):
     '''print the file-independent keywords and for an example file-dependent
     keywords
--- a/extensions/revinfo.py	Thu Dec 20 00:01:59 2018 +0100
+++ b/extensions/revinfo.py	Thu Jan 03 23:17:13 2019 +0100
@@ -15,11 +15,19 @@
 
 from mercurial.i18n import _
 from mercurial import cmdutil, scmutil, util, error, archival, pycompat
+try:
+    from mercurial import registrar
+except ImportError:
+    registrar = None
 
 
 cmdtable = {}
 
-command = cmdutil.command(cmdtable)
+if registrar:
+    command = registrar.command(cmdtable)
+else:
+    command = cmdutil.command(cmdtable)
+
 
 testedwith = "3.5 3.5.1 3.5.2 4.3.1 4.3.2 4.4.1 4.4.2 4.5.2 4.6.1"
 
@@ -55,7 +63,8 @@
         ("p", "path", [], _('the configured default path'), _('SOURCE')),
         ("d", "data", [], _("add an extra `KEY: VALUE' pair into the file"), _('KEY=VALUE')),
     ],
-    _("hg revinfo [OPTION]... [DEST]"))
+    _("hg revinfo [OPTION]... [DEST]"),
+    inferrepo=True)
 def revinfo(ui, repo, dest=None, **opts):
     """write a revision summary