Mercurial > public > mercurial-scm > hg-stable
diff mercurial/dispatch.py @ 40490:444861dc1e55
help: displaying documented aliases by default
This makes aliases be displayed in "hg help" when they have a :doc config
entry, and also allows them to be assigned to a category with :category.
Differential Revision: https://phab.mercurial-scm.org/D5087
author | rdamazio@google.com |
---|---|
date | Thu, 18 Oct 2018 19:57:05 -0700 |
parents | 106adc261492 |
children | 5542bc9125c9 |
line wrap: on
line diff
--- a/mercurial/dispatch.py Sat Oct 13 05:43:39 2018 -0700 +++ b/mercurial/dispatch.py Thu Oct 18 19:57:05 2018 -0700 @@ -37,6 +37,7 @@ hook, profiling, pycompat, + registrar, scmutil, ui as uimod, util, @@ -503,6 +504,7 @@ return ui.system(cmd, environ=env, blockedtag='alias_%s' % self.name) self.fn = fn + self.alias = True self._populatehelp(ui, name, shdef, self.fn) return @@ -530,6 +532,7 @@ self.fn, self.opts = tableentry cmdhelp = None + self.alias = True self._populatehelp(ui, name, cmd, self.fn, cmdhelp) except error.UnknownCommand: @@ -543,7 +546,7 @@ def _populatehelp(self, ui, name, cmd, fn, defaulthelp=None): # confine strings to be passed to i18n.gettext() cfg = {} - for k in ('doc', 'help'): + for k in ('doc', 'help', 'category'): v = ui.config('alias', '%s:%s' % (name, k), None) if v is None: continue @@ -558,11 +561,14 @@ # drop prefix in old-style help lines so hg shows the alias self.help = self.help[4 + len(cmd):] + self.owndoc = 'doc' in cfg doc = cfg.get('doc', pycompat.getdoc(fn)) if doc is not None: doc = pycompat.sysstr(doc) self.__doc__ = doc + self.helpcategory = cfg.get('category', registrar.command.CATEGORY_NONE) + @property def args(self): args = pycompat.maplist(util.expandpath, self.givenargs) @@ -613,6 +619,7 @@ self.definition = definition self.cmdtable = cmdtable.copy() self.source = source + self.alias = True @util.propertycache def _aliasdef(self):