mercurial/help.py
changeset 43106 d783f945a701
parent 43089 c59eb1560c44
child 43117 8ff1ecfadcd1
equal deleted inserted replaced
43105:649d3ac37a12 43106:d783f945a701
   122 
   122 
   123 def listexts(header, exts, indent=1, showdeprecated=False):
   123 def listexts(header, exts, indent=1, showdeprecated=False):
   124     '''return a text listing of the given extensions'''
   124     '''return a text listing of the given extensions'''
   125     rst = []
   125     rst = []
   126     if exts:
   126     if exts:
   127         for name, desc in sorted(exts.iteritems()):
   127         for name, desc in sorted(pycompat.iteritems(exts)):
   128             if not showdeprecated and any(w in desc for w in _exclkeywords):
   128             if not showdeprecated and any(w in desc for w in _exclkeywords):
   129                 continue
   129                 continue
   130             rst.append(b'%s:%s: %s\n' % (b' ' * indent, name, desc))
   130             rst.append(b'%s:%s: %s\n' % (b' ' * indent, name, desc))
   131     if rst:
   131     if rst:
   132         rst.insert(0, b'\n%s\n\n' % header)
   132         rst.insert(0, b'\n%s\n\n' % header)
   259             or (callable(doc) and lowercontains(doc(ui)))
   259             or (callable(doc) and lowercontains(doc(ui)))
   260         ):
   260         ):
   261             name = names[0]
   261             name = names[0]
   262             if not filtertopic(ui, name):
   262             if not filtertopic(ui, name):
   263                 results[b'topics'].append((names[0], header))
   263                 results[b'topics'].append((names[0], header))
   264     for cmd, entry in commands.table.iteritems():
   264     for cmd, entry in pycompat.iteritems(commands.table):
   265         if len(entry) == 3:
   265         if len(entry) == 3:
   266             summary = entry[2]
   266             summary = entry[2]
   267         else:
   267         else:
   268             summary = b''
   268             summary = b''
   269         # translate docs *before* searching there
   269         # translate docs *before* searching there
   276             cmdname = cmdutil.parsealiases(cmd)[0]
   276             cmdname = cmdutil.parsealiases(cmd)[0]
   277             if filtercmd(ui, cmdname, func, kw, docs):
   277             if filtercmd(ui, cmdname, func, kw, docs):
   278                 continue
   278                 continue
   279             results[b'commands'].append((cmdname, summary))
   279             results[b'commands'].append((cmdname, summary))
   280     for name, docs in itertools.chain(
   280     for name, docs in itertools.chain(
   281         extensions.enabled(False).iteritems(), extensions.disabled().iteritems()
   281         pycompat.iteritems(extensions.enabled(False)),
       
   282         pycompat.iteritems(extensions.disabled()),
   282     ):
   283     ):
   283         if not docs:
   284         if not docs:
   284             continue
   285             continue
   285         name = name.rpartition(b'.')[-1]
   286         name = name.rpartition(b'.')[-1]
   286         if lowercontains(name) or lowercontains(docs):
   287         if lowercontains(name) or lowercontains(docs):
   289         try:
   290         try:
   290             mod = extensions.load(ui, name, b'')
   291             mod = extensions.load(ui, name, b'')
   291         except ImportError:
   292         except ImportError:
   292             # debug message would be printed in extensions.load()
   293             # debug message would be printed in extensions.load()
   293             continue
   294             continue
   294         for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
   295         for cmd, entry in pycompat.iteritems(getattr(mod, 'cmdtable', {})):
   295             if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
   296             if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
   296                 cmdname = cmdutil.parsealiases(cmd)[0]
   297                 cmdname = cmdutil.parsealiases(cmd)[0]
   297                 func = entry[0]
   298                 func = entry[0]
   298                 cmddoc = pycompat.getdoc(func)
   299                 cmddoc = pycompat.getdoc(func)
   299                 if cmddoc:
   300                 if cmddoc:
   736         cats = {}
   737         cats = {}
   737         # Command -> short description
   738         # Command -> short description
   738         h = {}
   739         h = {}
   739         # Command -> string showing synonyms
   740         # Command -> string showing synonyms
   740         syns = {}
   741         syns = {}
   741         for c, e in commands.table.iteritems():
   742         for c, e in pycompat.iteritems(commands.table):
   742             fs = cmdutil.parsealiases(c)
   743             fs = cmdutil.parsealiases(c)
   743             f = fs[0]
   744             f = fs[0]
   744             syns[f] = b', '.join(fs)
   745             syns[f] = b', '.join(fs)
   745             func = e[0]
   746             func = e[0]
   746             if select and not select(f):
   747             if select and not select(f):