e90cf5cad060

Use @cmdutil.command decorator to define command table.

It's been available for 5 years (since Mercurial 1.9), and Mercurial 3.8
deprecates the use of hand-built command tables as of 38dc3f28f478.
[view raw] [browse files]
author Kevin Bullock <kbullock@ringworld.org>
date Wed, 20 Apr 2016 10:15:36 -0500
parents 5dc059aeb5f4
children ca659a3b3b97 30832b77a931 a410d2232772
branches/tags (none)
files prompt.py

Changes

--- a/prompt.py	Fri Jul 31 14:32:34 2015 -0500
+++ b/prompt.py	Wed Apr 20 10:15:36 2016 -0500
@@ -18,6 +18,9 @@
 from mercurial import extensions, commands, cmdutil, help
 from mercurial.node import hex, short
 
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
 # `revrange' has been moved into module `scmutil' since v1.9.
 try :
     from mercurial import scmutil
@@ -72,6 +75,11 @@
     else:
         return None
 
+@command('prompt',
+         [('', 'angle-brackets', None, 'use angle brackets (<>) for keywords'),
+          ('', 'cache-incoming', None, 'used internally by hg-prompt'),
+          ('', 'cache-outgoing', None, 'used internally by hg-prompt')],
+         'hg prompt STRING')
 def prompt(ui, repo, fs='', **opts):
     '''get repository information for use in a shell prompt
 
@@ -457,15 +465,6 @@
     except KeyError:
         pass
 
-cmdtable = {
-    "prompt":
-    (prompt, [
-        ('', 'angle-brackets', None, 'use angle brackets (<>) for keywords'),
-        ('', 'cache-incoming', None, 'used internally by hg-prompt'),
-        ('', 'cache-outgoing', None, 'used internally by hg-prompt'),
-    ],
-    'hg prompt STRING')
-}
 help.helptable += (
     (['prompt-keywords', 'prompt-keywords'], ('Keywords supported by hg-prompt'),
      (r'''hg-prompt currently supports a number of keywords.