mercurial/commands.py
changeset 5178 18a9fbb5cd78
parent 5177 92236732d5a1
child 5192 60acf1432ee0
equal deleted inserted replaced
5177:92236732d5a1 5178:18a9fbb5cd78
     7 
     7 
     8 import demandimport; demandimport.enable()
     8 import demandimport; demandimport.enable()
     9 from node import *
     9 from node import *
    10 from i18n import _
    10 from i18n import _
    11 import os, re, sys, urllib
    11 import os, re, sys, urllib
    12 import ui, hg, util, revlog, bundlerepo, extensions
    12 import hg, util, revlog, bundlerepo, extensions
    13 import difflib, patch, time, help, mdiff, tempfile
    13 import difflib, patch, time, help, mdiff, tempfile
    14 import errno, version, socket
    14 import errno, version, socket
    15 import archival, changegroup, cmdutil, hgweb.server, sshserver
    15 import archival, changegroup, cmdutil, hgweb.server, sshserver
    16 
    16 
    17 # Commands start here, listed alphabetically
    17 # Commands start here, listed alphabetically
   660 
   660 
   661     if opts['options']:
   661     if opts['options']:
   662         options = []
   662         options = []
   663         otables = [globalopts]
   663         otables = [globalopts]
   664         if cmd:
   664         if cmd:
   665             aliases, entry = cmdutil.findcmd(ui, cmd)
   665             aliases, entry = cmdutil.findcmd(ui, cmd, table)
   666             otables.append(entry[1])
   666             otables.append(entry[1])
   667         for t in otables:
   667         for t in otables:
   668             for o in t:
   668             for o in t:
   669                 if o[0]:
   669                 if o[0]:
   670                     options.append('-%s' % o[0])
   670                     options.append('-%s' % o[0])
   671                 options.append('--%s' % o[1])
   671                 options.append('--%s' % o[1])
   672         ui.write("%s\n" % "\n".join(options))
   672         ui.write("%s\n" % "\n".join(options))
   673         return
   673         return
   674 
   674 
   675     clist = cmdutil.findpossible(ui, cmd).keys()
   675     clist = cmdutil.findpossible(ui, cmd, table).keys()
   676     clist.sort()
   676     clist.sort()
   677     ui.write("%s\n" % "\n".join(clist))
   677     ui.write("%s\n" % "\n".join(clist))
   678 
   678 
   679 def debugrebuildstate(ui, repo, rev=""):
   679 def debugrebuildstate(ui, repo, rev=""):
   680     """rebuild the dirstate as it would look like for the given revision"""
   680     """rebuild the dirstate as it would look like for the given revision"""
  1305 
  1305 
  1306     def helpcmd(name):
  1306     def helpcmd(name):
  1307         if with_version:
  1307         if with_version:
  1308             version_(ui)
  1308             version_(ui)
  1309             ui.write('\n')
  1309             ui.write('\n')
  1310         aliases, i = cmdutil.findcmd(ui, name)
  1310         aliases, i = cmdutil.findcmd(ui, name, table)
  1311         # synopsis
  1311         # synopsis
  1312         ui.write("%s\n\n" % i[2])
  1312         ui.write("%s\n\n" % i[2])
  1313 
  1313 
  1314         # description
  1314         # description
  1315         doc = i[0].__doc__
  1315         doc = i[0].__doc__
  3132 extensions.commandtable = table
  3132 extensions.commandtable = table
  3133 
  3133 
  3134 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  3134 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  3135           " debugindex debugindexdot debugdate debuginstall")
  3135           " debugindex debugindexdot debugdate debuginstall")
  3136 optionalrepo = ("paths serve showconfig")
  3136 optionalrepo = ("paths serve showconfig")
  3137 
       
  3138 def dispatch(args):
       
  3139     try:
       
  3140         u = ui.ui(traceback='--traceback' in args)
       
  3141     except util.Abort, inst:
       
  3142         sys.stderr.write(_("abort: %s\n") % inst)
       
  3143         return -1
       
  3144     return cmdutil.runcatch(u, args)
       
  3145 
       
  3146 def run():
       
  3147     sys.exit(dispatch(sys.argv[1:]))