mercurial/commands.py
changeset 15127 2c80862728cb
parent 15126 d3ad0e9d4be2
child 15128 aaf666bd2942
equal deleted inserted replaced
15126:d3ad0e9d4be2 15127:2c80862728cb
  2745         except error.AmbiguousCommand, inst:
  2745         except error.AmbiguousCommand, inst:
  2746             # py3k fix: except vars can't be used outside the scope of the
  2746             # py3k fix: except vars can't be used outside the scope of the
  2747             # except block, nor can be used inside a lambda. python issue4617
  2747             # except block, nor can be used inside a lambda. python issue4617
  2748             prefix = inst.args[0]
  2748             prefix = inst.args[0]
  2749             select = lambda c: c.lstrip('^').startswith(prefix)
  2749             select = lambda c: c.lstrip('^').startswith(prefix)
  2750             helplist(_('list of commands:\n\n'), select)
  2750             helplist(select)
  2751             return
  2751             return
  2752 
  2752 
  2753         # check if it's an invalid alias and display its error if it is
  2753         # check if it's an invalid alias and display its error if it is
  2754         if getattr(entry[0], 'badalias', False):
  2754         if getattr(entry[0], 'badalias', False):
  2755             if not unknowncmd:
  2755             if not unknowncmd:
  2803                         'the %s extension') % (name, name)
  2803                         'the %s extension') % (name, name)
  2804                 ui.write('\n%s\n' % msg)
  2804                 ui.write('\n%s\n' % msg)
  2805         except KeyError:
  2805         except KeyError:
  2806             pass
  2806             pass
  2807 
  2807 
  2808     def helplist(header, select=None):
  2808     def helplist(select=None):
       
  2809         # list of commands
       
  2810         if name == "shortlist":
       
  2811             header = _('basic commands:\n\n')
       
  2812         else:
       
  2813             header = _('list of commands:\n\n')
       
  2814 
  2809         h = {}
  2815         h = {}
  2810         cmds = {}
  2816         cmds = {}
  2811         for c, e in table.iteritems():
  2817         for c, e in table.iteritems():
  2812             f = c.split("|", 1)[0]
  2818             f = c.split("|", 1)[0]
  2813             if select and not select(f):
  2819             if select and not select(f):
  2906             try:
  2912             try:
  2907                 ct = mod.cmdtable
  2913                 ct = mod.cmdtable
  2908             except AttributeError:
  2914             except AttributeError:
  2909                 ct = {}
  2915                 ct = {}
  2910             modcmds = set([c.split('|', 1)[0] for c in ct])
  2916             modcmds = set([c.split('|', 1)[0] for c in ct])
  2911             helplist(_('list of commands:\n\n'), modcmds.__contains__)
  2917             helplist(modcmds.__contains__)
  2912         else:
  2918         else:
  2913             ui.write(_('use "hg help extensions" for information on enabling '
  2919             ui.write(_('use "hg help extensions" for information on enabling '
  2914                        'extensions\n'))
  2920                        'extensions\n'))
  2915 
  2921 
  2916     def helpextcmd(name):
  2922     def helpextcmd(name):
  2941                 break
  2947                 break
  2942             except error.UnknownCommand, inst:
  2948             except error.UnknownCommand, inst:
  2943                 i = inst
  2949                 i = inst
  2944         if i:
  2950         if i:
  2945             raise i
  2951             raise i
  2946 
       
  2947     else:
  2952     else:
  2948         # program name
  2953         # program name
  2949         ui.status(_("Mercurial Distributed SCM\n"))
  2954         ui.status(_("Mercurial Distributed SCM\n"))
  2950         ui.status('\n')
  2955         ui.status('\n')
  2951 
  2956         helplist()
  2952         # list of commands
       
  2953         if name == "shortlist":
       
  2954             header = _('basic commands:\n\n')
       
  2955         else:
       
  2956             header = _('list of commands:\n\n')
       
  2957 
       
  2958         helplist(header)
       
  2959 
  2957 
  2960     ui.write(opttext(optlist, textwidth))
  2958     ui.write(opttext(optlist, textwidth))
  2961 
  2959 
  2962 @command('identify|id',
  2960 @command('identify|id',
  2963     [('r', 'rev', '',
  2961     [('r', 'rev', '',