changeset 9876:6e8a16dd3e30

alias: improve help text for command aliases Displays the line "alias for: hg ..." with the original command including options, followed by the command's original help text.
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Wed, 11 Nov 2009 17:48:00 +0100
parents d6a95c5f6ff9
children d266aa7606ce
files mercurial/dispatch.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Fri Nov 13 16:38:27 2009 +0200
+++ b/mercurial/dispatch.py	Wed Nov 11 17:48:00 2009 +0100
@@ -200,6 +200,12 @@
             self.args = aliasargs(self.fn) + args
             if cmd not in commands.norepo.split(' '):
                 self.norepo = False
+            if self.help.startswith("hg " + cmd):
+                # drop prefix in old-style help lines so hg shows the alias
+                self.help = self.help[4 + len(cmd):]
+            self.__doc__ = _("alias for: hg %s\n\n%s") \
+                               % (definition, self.fn.__doc__)
+
         except error.UnknownCommand:
             def fn(ui, *args):
                 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \