tests/test-extension.t
changeset 21773 26d2fb899637
parent 21289 c3784e3c3e8d
child 21849 a3306b8cdc0f
equal deleted inserted replaced
21772:5a4d1a6c605f 21773:26d2fb899637
    16   > 
    16   > 
    17   > @command('foo', [], 'hg foo')
    17   > @command('foo', [], 'hg foo')
    18   > def foo(ui, *args, **kwargs):
    18   > def foo(ui, *args, **kwargs):
    19   >     ui.write("Foo\\n")
    19   >     ui.write("Foo\\n")
    20   > 
    20   > 
    21   > @command('bar', [], 'hg bar')
    21   > @command('bar', [], 'hg bar', norepo=True)
    22   > def bar(ui, *args, **kwargs):
    22   > def bar(ui, *args, **kwargs):
    23   >     ui.write("Bar\\n")
    23   >     ui.write("Bar\\n")
    24   > 
    24   > 
    25   > commands.norepo += ' bar'
       
    26   > EOF
    25   > EOF
    27   $ abspath=`pwd`/foobar.py
    26   $ abspath=`pwd`/foobar.py
    28 
    27 
    29   $ mkdir barfoo
    28   $ mkdir barfoo
    30   $ cp foobar.py barfoo/__init__.py
    29   $ cp foobar.py barfoo/__init__.py
   479   > from mercurial import cmdutil, commands
   478   > from mercurial import cmdutil, commands
   480   > cmdtable = {}
   479   > cmdtable = {}
   481   > command = cmdutil.command(cmdtable)
   480   > command = cmdutil.command(cmdtable)
   482   > """multirevs extension
   481   > """multirevs extension
   483   > Big multi-line module docstring."""
   482   > Big multi-line module docstring."""
   484   > @command('multirevs', [], 'ARG')
   483   > @command('multirevs', [], 'ARG', norepo=True)
   485   > def multirevs(ui, repo, arg, *args, **opts):
   484   > def multirevs(ui, repo, arg, *args, **opts):
   486   >     """multirevs command"""
   485   >     """multirevs command"""
   487   >     pass
   486   >     pass
   488   > commands.norepo += ' multirevs'
       
   489   > EOF
   487   > EOF
   490   $ echo "multirevs = multirevs.py" >> $HGRCPATH
   488   $ echo "multirevs = multirevs.py" >> $HGRCPATH
   491 
   489 
   492   $ hg help multirevs
   490   $ hg help multirevs
   493   Specifying Multiple Revisions
   491   Specifying Multiple Revisions
   535   > '''
   533   > '''
   536   > from mercurial import cmdutil, commands, extensions
   534   > from mercurial import cmdutil, commands, extensions
   537   > cmdtable = {}
   535   > cmdtable = {}
   538   > command = cmdutil.command(cmdtable)
   536   > command = cmdutil.command(cmdtable)
   539   > 
   537   > 
   540   > @command('debugextensions', [], 'hg debugextensions')
   538   > @command('debugextensions', [], 'hg debugextensions', norepo=True)
   541   > def debugextensions(ui):
   539   > def debugextensions(ui):
   542   >     "yet another debug command"
   540   >     "yet another debug command"
   543   >     ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
   541   >     ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
   544   > 
   542   > 
   545   > commands.norepo += " debugextensions"
       
   546   > EOF
   543   > EOF
   547   $ echo "debugissue811 = $debugpath" >> $HGRCPATH
   544   $ echo "debugissue811 = $debugpath" >> $HGRCPATH
   548   $ echo "mq=" >> $HGRCPATH
   545   $ echo "mq=" >> $HGRCPATH
   549   $ echo "strip=" >> $HGRCPATH
   546   $ echo "strip=" >> $HGRCPATH
   550   $ echo "hgext.mq=" >> $HGRCPATH
   547   $ echo "hgext.mq=" >> $HGRCPATH
   629   > from mercurial import cmdutil, commands
   626   > from mercurial import cmdutil, commands
   630   > cmdtable = {}
   627   > cmdtable = {}
   631   > command = cmdutil.command(cmdtable)
   628   > command = cmdutil.command(cmdtable)
   632   > class Bogon(Exception): pass
   629   > class Bogon(Exception): pass
   633   > 
   630   > 
   634   > @command('throw', [], 'hg throw')
   631   > @command('throw', [], 'hg throw', norepo=True)
   635   > def throw(ui, **opts):
   632   > def throw(ui, **opts):
   636   >     """throws an exception"""
   633   >     """throws an exception"""
   637   >     raise Bogon()
   634   >     raise Bogon()
   638   > commands.norepo += " throw"
       
   639   > EOF
   635   > EOF
   640 No declared supported version, extension complains:
   636 No declared supported version, extension complains:
   641   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
   637   $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*'
   642   ** Unknown exception encountered with possibly-broken third-party extension throw
   638   ** Unknown exception encountered with possibly-broken third-party extension throw
   643   ** which supports versions unknown of Mercurial.
   639   ** which supports versions unknown of Mercurial.