This is an archive of the discontinued Mercurial Phabricator instance.

help: displaying documented aliases by default
ClosedPublic

Authored by rdamazio on Oct 13 2018, 10:26 AM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rdamazio created this revision.Oct 13 2018, 10:26 AM
rdamazio updated this revision to Diff 12127.Oct 14 2018, 6:32 AM
yuja added a subscriber: yuja.Oct 14 2018, 11:30 AM

@@ -507,16 +522,11 @@

f = fs[0]
syns[f] = ', '.join(fs)
func = e[0]

+ alias = getattr(func, 'alias', False)

if select and not select(f):
    continue
  • if (not select and name != 'shortlist' and
  • func.module != commands.name):
  • continue
  • if name == "shortlist":
  • if not getattr(func, 'helpbasic', False):
  • continue doc = pycompat.getdoc(func)
  • if filtercmd(ui, f, name, doc):

+ if filtercmd(ui, f, func, name, doc):

This makes extension commands get listed in "hg help". I think that's fine,
but can you split patches so we can backout if that causes problem?

In D5087#76401, @yuja wrote:

@@ -507,16 +522,11 @@

f = fs[0]
syns[f] = ', '.join(fs)
func = e[0]

+ alias = getattr(func, 'alias', False)

if select and not select(f):
    continue
  • if (not select and name != 'shortlist' and
  • func.module != commands.name):
  • continue
  • if name == "shortlist":
  • if not getattr(func, 'helpbasic', False):
  • continue doc = pycompat.getdoc(func)
  • if filtercmd(ui, f, name, doc):

+ if filtercmd(ui, f, func, name, doc):

This makes extension commands get listed in "hg help". I think that's fine,
but can you split patches so we can backout if that causes problem?

Done. Sending another review for the extensions part.

yuja added a comment.Oct 23 2018, 7:35 AM

Queued the series for 4.9, many thanks.

@@ -523,16 +538,20 @@

f = fs[0]
syns[f] = ', '.join(fs)
func = e[0]

+ alias = getattr(func, 'alias', False)

Removed unused variable alias.

@@ -554,11 +557,14 @@

  1. 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)

Maybe the default can be derived from the aliased command?

This revision was automatically updated to reflect the committed changes.