mercurial/commands.py
changeset 3658 6389205291c6
parent 3657 731e739b8659
child 3659 f4dece0f7016
equal deleted inserted replaced
3657:731e739b8659 3658:6389205291c6
   106     if opts.get('ssh'):
   106     if opts.get('ssh'):
   107         ui.setconfig("ui", "ssh", opts['ssh'])
   107         ui.setconfig("ui", "ssh", opts['ssh'])
   108     if opts.get('remotecmd'):
   108     if opts.get('remotecmd'):
   109         ui.setconfig("ui", "remotecmd", opts['remotecmd'])
   109         ui.setconfig("ui", "remotecmd", opts['remotecmd'])
   110 
   110 
   111 def show_version(ui):
       
   112     """output version and copyright information"""
       
   113     ui.write(_("Mercurial Distributed SCM (version %s)\n")
       
   114              % version.get_version())
       
   115     ui.status(_(
       
   116         "\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n"
       
   117         "This is free software; see the source for copying conditions. "
       
   118         "There is NO\nwarranty; "
       
   119         "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
       
   120     ))
       
   121 
       
   122 def help_(ui, name=None, with_version=False):
   111 def help_(ui, name=None, with_version=False):
   123     """show help for a command, extension, or list of commands
   112     """show help for a command, extension, or list of commands
   124 
   113 
   125     With no arguments, print a list of commands and short help.
   114     With no arguments, print a list of commands and short help.
   126 
   115 
   130     commands it provides."""
   119     commands it provides."""
   131     option_lists = []
   120     option_lists = []
   132 
   121 
   133     def helpcmd(name):
   122     def helpcmd(name):
   134         if with_version:
   123         if with_version:
   135             show_version(ui)
   124             version_(ui)
   136             ui.write('\n')
   125             ui.write('\n')
   137         aliases, i = findcmd(ui, name)
   126         aliases, i = findcmd(ui, name)
   138         # synopsis
   127         # synopsis
   139         ui.write("%s\n\n" % i[2])
   128         ui.write("%s\n\n" % i[2])
   140 
   129 
   211             helpext(name)
   200             helpext(name)
   212 
   201 
   213     else:
   202     else:
   214         # program name
   203         # program name
   215         if ui.verbose or with_version:
   204         if ui.verbose or with_version:
   216             show_version(ui)
   205             version_(ui)
   217         else:
   206         else:
   218             ui.status(_("Mercurial Distributed SCM\n"))
   207             ui.status(_("Mercurial Distributed SCM\n"))
   219         ui.status('\n')
   208         ui.status('\n')
   220 
   209 
   221         # list of commands
   210         # list of commands
  2377     integrity, validating the hashes and checksums of each entry in
  2366     integrity, validating the hashes and checksums of each entry in
  2378     the changelog, manifest, and tracked files, as well as the
  2367     the changelog, manifest, and tracked files, as well as the
  2379     integrity of their crosslinks and indices.
  2368     integrity of their crosslinks and indices.
  2380     """
  2369     """
  2381     return hg.verify(repo)
  2370     return hg.verify(repo)
       
  2371 
       
  2372 def version_(ui):
       
  2373     """output version and copyright information"""
       
  2374     ui.write(_("Mercurial Distributed SCM (version %s)\n")
       
  2375              % version.get_version())
       
  2376     ui.status(_(
       
  2377         "\nCopyright (C) 2005, 2006 Matt Mackall <mpm@selenic.com>\n"
       
  2378         "This is free software; see the source for copying conditions. "
       
  2379         "There is NO\nwarranty; "
       
  2380         "not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
       
  2381     ))
  2382 
  2382 
  2383 # Command options and aliases are listed here, alphabetically
  2383 # Command options and aliases are listed here, alphabetically
  2384 
  2384 
  2385 globalopts = [
  2385 globalopts = [
  2386     ('R', 'repository', '',
  2386     ('R', 'repository', '',
  2757           ('m', 'merge', None, _('allow merging of branches (DEPRECATED)')),
  2757           ('m', 'merge', None, _('allow merging of branches (DEPRECATED)')),
  2758           ('C', 'clean', None, _('overwrite locally modified files')),
  2758           ('C', 'clean', None, _('overwrite locally modified files')),
  2759           ('f', 'force', None, _('force a merge with outstanding changes'))],
  2759           ('f', 'force', None, _('force a merge with outstanding changes'))],
  2760          _('hg update [-C] [-f] [REV]')),
  2760          _('hg update [-C] [-f] [REV]')),
  2761     "verify": (verify, [], _('hg verify')),
  2761     "verify": (verify, [], _('hg verify')),
  2762     "version": (show_version, [], _('hg version')),
  2762     "version": (version_, [], _('hg version')),
  2763 }
  2763 }
  2764 
  2764 
  2765 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  2765 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  2766           " debugindex debugindexdot")
  2766           " debugindex debugindexdot")
  2767 optionalrepo = ("paths serve showconfig")
  2767 optionalrepo = ("paths serve showconfig")
  2979                 raise util.Abort(_("repository '%s' is not local") % path)
  2979                 raise util.Abort(_("repository '%s' is not local") % path)
  2980 
  2980 
  2981             if options['help']:
  2981             if options['help']:
  2982                 return help_(u, cmd, options['version'])
  2982                 return help_(u, cmd, options['version'])
  2983             elif options['version']:
  2983             elif options['version']:
  2984                 return show_version(u)
  2984                 return version_(u)
  2985             elif not cmd:
  2985             elif not cmd:
  2986                 return help_(u, 'shortlist')
  2986                 return help_(u, 'shortlist')
  2987 
  2987 
  2988             if cmd not in norepo.split():
  2988             if cmd not in norepo.split():
  2989                 try:
  2989                 try: