mercurial/commands.py
changeset 21775 5403245edb3a
parent 21768 16aeb28caaa6
child 21778 f6a6d07b66b3
equal deleted inserted replaced
21774:b280d0b60bc3 21775:5403245edb3a
    27 command = cmdutil.command(table)
    27 command = cmdutil.command(table)
    28 
    28 
    29 # Space delimited list of commands that don't require local repositories.
    29 # Space delimited list of commands that don't require local repositories.
    30 # This should be populated by passing norepo=True into the @command decorator.
    30 # This should be populated by passing norepo=True into the @command decorator.
    31 norepo = ''
    31 norepo = ''
    32 optionalrepo = ("identify paths serve config showconfig debugancestor debugdag"
    32 # Space delimited list of commands that optionally require local repositories.
    33                 " debugdata debugindex debugindexdot debugrevlog")
    33 # This should be populated by passing optionalrepo=True into the @command
       
    34 # decorator.
       
    35 optionalrepo = ''
    34 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
    36 inferrepo = ("add addremove annotate cat commit diff grep forget log parents"
    35              " remove resolve status debugwalk")
    37              " remove resolve status debugwalk")
    36 # common command options
    38 # common command options
    37 
    39 
    38 globalopts = [
    40 globalopts = [
  1464 @command('config|showconfig|debugconfig',
  1466 @command('config|showconfig|debugconfig',
  1465     [('u', 'untrusted', None, _('show untrusted configuration options')),
  1467     [('u', 'untrusted', None, _('show untrusted configuration options')),
  1466      ('e', 'edit', None, _('edit user config')),
  1468      ('e', 'edit', None, _('edit user config')),
  1467      ('l', 'local', None, _('edit repository config')),
  1469      ('l', 'local', None, _('edit repository config')),
  1468      ('g', 'global', None, _('edit global config'))],
  1470      ('g', 'global', None, _('edit global config'))],
  1469       _('[-u] [NAME]...'))
  1471     _('[-u] [NAME]...'),
       
  1472     optionalrepo=True)
  1470 def config(ui, repo, *values, **opts):
  1473 def config(ui, repo, *values, **opts):
  1471     """show combined config settings from all hgrc files
  1474     """show combined config settings from all hgrc files
  1472 
  1475 
  1473     With no arguments, print names and values of all config items.
  1476     With no arguments, print names and values of all config items.
  1474 
  1477 
  1583     try:
  1586     try:
  1584         return cmdutil.copy(ui, repo, pats, opts)
  1587         return cmdutil.copy(ui, repo, pats, opts)
  1585     finally:
  1588     finally:
  1586         wlock.release()
  1589         wlock.release()
  1587 
  1590 
  1588 @command('debugancestor', [], _('[INDEX] REV1 REV2'))
  1591 @command('debugancestor', [], _('[INDEX] REV1 REV2'), optionalrepo=True)
  1589 def debugancestor(ui, repo, *args):
  1592 def debugancestor(ui, repo, *args):
  1590     """find the ancestor revision of two revisions in a given index"""
  1593     """find the ancestor revision of two revisions in a given index"""
  1591     if len(args) == 3:
  1594     if len(args) == 3:
  1592         index, rev1, rev2 = args
  1595         index, rev1, rev2 = args
  1593         r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
  1596         r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False), index)
  1875 @command('debugdag',
  1878 @command('debugdag',
  1876     [('t', 'tags', None, _('use tags as labels')),
  1879     [('t', 'tags', None, _('use tags as labels')),
  1877     ('b', 'branches', None, _('annotate with branch names')),
  1880     ('b', 'branches', None, _('annotate with branch names')),
  1878     ('', 'dots', None, _('use dots for runs')),
  1881     ('', 'dots', None, _('use dots for runs')),
  1879     ('s', 'spaces', None, _('separate elements by spaces'))],
  1882     ('s', 'spaces', None, _('separate elements by spaces'))],
  1880     _('[OPTION]... [FILE [REV]...]'))
  1883     _('[OPTION]... [FILE [REV]...]'),
       
  1884     optionalrepo=True)
  1881 def debugdag(ui, repo, file_=None, *revs, **opts):
  1885 def debugdag(ui, repo, file_=None, *revs, **opts):
  1882     """format the changelog or an index DAG as a concise textual description
  1886     """format the changelog or an index DAG as a concise textual description
  1883 
  1887 
  1884     If you pass a revlog index, the revlog's DAG is emitted. If you list
  1888     If you pass a revlog index, the revlog's DAG is emitted. If you list
  1885     revision numbers, they get labeled in the output as rN.
  1889     revision numbers, they get labeled in the output as rN.
  1950         raise util.Abort(_('invalid revision identifier %s') % rev)
  1954         raise util.Abort(_('invalid revision identifier %s') % rev)
  1951 
  1955 
  1952 @command('debugdate',
  1956 @command('debugdate',
  1953     [('e', 'extended', None, _('try extended date formats'))],
  1957     [('e', 'extended', None, _('try extended date formats'))],
  1954     _('[-e] DATE [RANGE]'),
  1958     _('[-e] DATE [RANGE]'),
  1955     norepo=True)
  1959     norepo=True, optionalrepo=True)
  1956 def debugdate(ui, date, range=None, **opts):
  1960 def debugdate(ui, date, range=None, **opts):
  1957     """parse and display a date"""
  1961     """parse and display a date"""
  1958     if opts["extended"]:
  1962     if opts["extended"]:
  1959         d = util.parsedate(date, util.extendeddateformats)
  1963         d = util.parsedate(date, util.extendeddateformats)
  1960     else:
  1964     else:
  2102 
  2106 
  2103 @command('debugindex',
  2107 @command('debugindex',
  2104     [('c', 'changelog', False, _('open changelog')),
  2108     [('c', 'changelog', False, _('open changelog')),
  2105      ('m', 'manifest', False, _('open manifest')),
  2109      ('m', 'manifest', False, _('open manifest')),
  2106      ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
  2110      ('f', 'format', 0, _('revlog format'), _('FORMAT'))],
  2107     _('[-f FORMAT] -c|-m|FILE'))
  2111     _('[-f FORMAT] -c|-m|FILE'),
       
  2112     optionalrepo=True)
  2108 def debugindex(ui, repo, file_=None, **opts):
  2113 def debugindex(ui, repo, file_=None, **opts):
  2109     """dump the contents of an index file"""
  2114     """dump the contents of an index file"""
  2110     r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
  2115     r = cmdutil.openrevlog(repo, 'debugindex', file_, opts)
  2111     format = opts.get('format', 0)
  2116     format = opts.get('format', 0)
  2112     if format not in (0, 1):
  2117     if format not in (0, 1):
  2144             pr = r.parentrevs(i)
  2149             pr = r.parentrevs(i)
  2145             ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
  2150             ui.write("% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n" % (
  2146                     i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
  2151                     i, r.flags(i), r.start(i), r.length(i), r.rawsize(i),
  2147                     base, r.linkrev(i), pr[0], pr[1], short(node)))
  2152                     base, r.linkrev(i), pr[0], pr[1], short(node)))
  2148 
  2153 
  2149 @command('debugindexdot', [], _('FILE'))
  2154 @command('debugindexdot', [], _('FILE'), optionalrepo=True)
  2150 def debugindexdot(ui, repo, file_):
  2155 def debugindexdot(ui, repo, file_):
  2151     """dump an index DAG as a graphviz dot file"""
  2156     """dump an index DAG as a graphviz dot file"""
  2152     r = None
  2157     r = None
  2153     if repo:
  2158     if repo:
  2154         filelog = repo.file(file_)
  2159         filelog = repo.file(file_)
  2483 
  2488 
  2484 @command('debugrevlog',
  2489 @command('debugrevlog',
  2485     [('c', 'changelog', False, _('open changelog')),
  2490     [('c', 'changelog', False, _('open changelog')),
  2486      ('m', 'manifest', False, _('open manifest')),
  2491      ('m', 'manifest', False, _('open manifest')),
  2487      ('d', 'dump', False, _('dump index data'))],
  2492      ('d', 'dump', False, _('dump index data'))],
  2488      _('-c|-m|FILE'))
  2493     _('-c|-m|FILE'),
       
  2494     optionalrepo=True)
  2489 def debugrevlog(ui, repo, file_=None, **opts):
  2495 def debugrevlog(ui, repo, file_=None, **opts):
  2490     """show data and statistics about a revlog"""
  2496     """show data and statistics about a revlog"""
  2491     r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
  2497     r = cmdutil.openrevlog(repo, 'debugrevlog', file_, opts)
  2492 
  2498 
  2493     if opts.get("dump"):
  2499     if opts.get("dump"):
  3575     ('i', 'id', None, _('show global revision id')),
  3581     ('i', 'id', None, _('show global revision id')),
  3576     ('b', 'branch', None, _('show branch')),
  3582     ('b', 'branch', None, _('show branch')),
  3577     ('t', 'tags', None, _('show tags')),
  3583     ('t', 'tags', None, _('show tags')),
  3578     ('B', 'bookmarks', None, _('show bookmarks')),
  3584     ('B', 'bookmarks', None, _('show bookmarks')),
  3579     ] + remoteopts,
  3585     ] + remoteopts,
  3580     _('[-nibtB] [-r REV] [SOURCE]'))
  3586     _('[-nibtB] [-r REV] [SOURCE]'),
       
  3587     optionalrepo=True)
  3581 def identify(ui, repo, source=None, rev=None,
  3588 def identify(ui, repo, source=None, rev=None,
  3582              num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
  3589              num=None, id=None, branch=None, tags=None, bookmarks=None, **opts):
  3583     """identify the working copy or specified revision
  3590     """identify the working copy or specified revision
  3584 
  3591 
  3585     Print a summary identifying the repository state at REV using one or
  3592     Print a summary identifying the repository state at REV using one or
  4439     for n in p:
  4446     for n in p:
  4440         if n != nullid:
  4447         if n != nullid:
  4441             displayer.show(repo[n])
  4448             displayer.show(repo[n])
  4442     displayer.close()
  4449     displayer.close()
  4443 
  4450 
  4444 @command('paths', [], _('[NAME]'))
  4451 @command('paths', [], _('[NAME]'), optionalrepo=True)
  4445 def paths(ui, repo, search=None):
  4452 def paths(ui, repo, search=None):
  4446     """show aliases for remote repositories
  4453     """show aliases for remote repositories
  4447 
  4454 
  4448     Show definition of symbolic path name NAME. If no name is given,
  4455     Show definition of symbolic path name NAME. If no name is given,
  4449     show definition of all available names.
  4456     show definition of all available names.
  5191     ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
  5198     ('', 'cmdserver', '', _('for remote clients'), _('MODE')),
  5192     ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
  5199     ('t', 'templates', '', _('web templates to use'), _('TEMPLATE')),
  5193     ('', 'style', '', _('template style to use'), _('STYLE')),
  5200     ('', 'style', '', _('template style to use'), _('STYLE')),
  5194     ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
  5201     ('6', 'ipv6', None, _('use IPv6 in addition to IPv4')),
  5195     ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
  5202     ('', 'certificate', '', _('SSL certificate file'), _('FILE'))],
  5196     _('[OPTION]...'))
  5203     _('[OPTION]...'),
       
  5204     optionalrepo=True)
  5197 def serve(ui, repo, **opts):
  5205 def serve(ui, repo, **opts):
  5198     """start stand-alone webserver
  5206     """start stand-alone webserver
  5199 
  5207 
  5200     Start a local HTTP repository browser and pull server. You can use
  5208     Start a local HTTP repository browser and pull server. You can use
  5201     this for ad-hoc sharing and browsing of repositories. It is
  5209     this for ad-hoc sharing and browsing of repositories. It is