mercurial/commands.py
changeset 4950 93b7e2fa7ee3
parent 4942 b8076522e889
child 4954 90be978c9d3d
child 4966 8d982aef0be1
equal deleted inserted replaced
4942:b8076522e889 4950:93b7e2fa7ee3
  1338             if i[1]:
  1338             if i[1]:
  1339                 option_lists.append((_("options:\n"), i[1]))
  1339                 option_lists.append((_("options:\n"), i[1]))
  1340 
  1340 
  1341             addglobalopts(False)
  1341             addglobalopts(False)
  1342 
  1342 
  1343     def helplist(select=None):
  1343     def helplist(header, select=None):
  1344         h = {}
  1344         h = {}
  1345         cmds = {}
  1345         cmds = {}
  1346         for c, e in table.items():
  1346         for c, e in table.items():
  1347             f = c.split("|", 1)[0]
  1347             f = c.split("|", 1)[0]
  1348             if select and not select(f):
  1348             if select and not select(f):
  1356             if not doc:
  1356             if not doc:
  1357                 doc = _("(No help text available)")
  1357                 doc = _("(No help text available)")
  1358             h[f] = doc.splitlines(0)[0].rstrip()
  1358             h[f] = doc.splitlines(0)[0].rstrip()
  1359             cmds[f] = c.lstrip("^")
  1359             cmds[f] = c.lstrip("^")
  1360 
  1360 
       
  1361         if not h:
       
  1362             ui.status(_('no commands defined\n'))
       
  1363             return
       
  1364 
       
  1365         ui.status(header)
  1361         fns = h.keys()
  1366         fns = h.keys()
  1362         fns.sort()
  1367         fns.sort()
  1363         m = max(map(len, fns))
  1368         m = max(map(len, fns))
  1364         for f in fns:
  1369         for f in fns:
  1365             if ui.verbose:
  1370             if ui.verbose:
  1405         ui.status('\n')
  1410         ui.status('\n')
  1406 
  1411 
  1407         try:
  1412         try:
  1408             ct = mod.cmdtable
  1413             ct = mod.cmdtable
  1409         except AttributeError:
  1414         except AttributeError:
  1410             ct = None
  1415             ct = {}
  1411         if not ct:
  1416 
  1412             ui.status(_('no commands defined\n'))
       
  1413             return
       
  1414 
       
  1415         ui.status(_('list of commands:\n\n'))
       
  1416         modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
  1417         modcmds = dict.fromkeys([c.split('|', 1)[0] for c in ct])
  1417         helplist(modcmds.has_key)
  1418         helplist(_('list of commands:\n\n'), modcmds.has_key)
  1418 
  1419 
  1419     if name and name != 'shortlist':
  1420     if name and name != 'shortlist':
  1420         i = None
  1421         i = None
  1421         for f in (helpcmd, helptopic, helpext):
  1422         for f in (helpcmd, helptopic, helpext):
  1422             try:
  1423             try:
  1436             ui.status(_("Mercurial Distributed SCM\n"))
  1437             ui.status(_("Mercurial Distributed SCM\n"))
  1437         ui.status('\n')
  1438         ui.status('\n')
  1438 
  1439 
  1439         # list of commands
  1440         # list of commands
  1440         if name == "shortlist":
  1441         if name == "shortlist":
  1441             ui.status(_('basic commands:\n\n'))
  1442             header = _('basic commands:\n\n')
  1442         else:
  1443         else:
  1443             ui.status(_('list of commands:\n\n'))
  1444             header = _('list of commands:\n\n')
  1444 
  1445 
  1445         helplist()
  1446         helplist(header)
  1446 
  1447 
  1447     # list all option lists
  1448     # list all option lists
  1448     opt_output = []
  1449     opt_output = []
  1449     for title, options in option_lists:
  1450     for title, options in option_lists:
  1450         opt_output.append(("\n%s" % title, None))
  1451         opt_output.append(("\n%s" % title, None))