10 > ui.flush() |
10 > ui.flush() |
11 > def reposetup(ui, repo): |
11 > def reposetup(ui, repo): |
12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) |
12 > ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) |
13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) |
13 > ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) |
14 > ui.flush() |
14 > ui.flush() |
15 > @command('foo', [], 'hg foo') |
15 > @command(b'foo', [], 'hg foo') |
16 > def foo(ui, *args, **kwargs): |
16 > def foo(ui, *args, **kwargs): |
17 > ui.write("Foo\\n") |
17 > ui.write("Foo\\n") |
18 > @command('bar', [], 'hg bar', norepo=True) |
18 > @command(b'bar', [], 'hg bar', norepo=True) |
19 > def bar(ui, *args, **kwargs): |
19 > def bar(ui, *args, **kwargs): |
20 > ui.write("Bar\\n") |
20 > ui.write("Bar\\n") |
21 > EOF |
21 > EOF |
22 $ abspath=`pwd`/foobar.py |
22 $ abspath=`pwd`/foobar.py |
23 |
23 |
406 > # "absolute" and "relative" shouldn't be imported before actual |
406 > # "absolute" and "relative" shouldn't be imported before actual |
407 > # command execution, because (1) they import same modules, and (2) |
407 > # command execution, because (1) they import same modules, and (2) |
408 > # preceding import (= instantiate "demandmod" object instead of |
408 > # preceding import (= instantiate "demandmod" object instead of |
409 > # real "module" object) might hide problem of succeeding import. |
409 > # real "module" object) might hide problem of succeeding import. |
410 > |
410 > |
411 > @command('showabsolute', [], norepo=True) |
411 > @command(b'showabsolute', [], norepo=True) |
412 > def showabsolute(ui, *args, **opts): |
412 > def showabsolute(ui, *args, **opts): |
413 > from absextroot import absolute |
413 > from absextroot import absolute |
414 > ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult())) |
414 > ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult())) |
415 > |
415 > |
416 > @command('showrelative', [], norepo=True) |
416 > @command(b'showrelative', [], norepo=True) |
417 > def showrelative(ui, *args, **opts): |
417 > def showrelative(ui, *args, **opts): |
418 > from . import relative |
418 > from . import relative |
419 > ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult())) |
419 > ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult())) |
420 > |
420 > |
421 > # import modules from external library |
421 > # import modules from external library |
468 > command = registrar.command(cmdtable) |
468 > command = registrar.command(cmdtable) |
469 > |
469 > |
470 > # demand import avoids failure of importing notexist here |
470 > # demand import avoids failure of importing notexist here |
471 > import extlibroot.lsub1.lsub2.notexist |
471 > import extlibroot.lsub1.lsub2.notexist |
472 > |
472 > |
473 > @command('checkrelativity', [], norepo=True) |
473 > @command(b'checkrelativity', [], norepo=True) |
474 > def checkrelativity(ui, *args, **opts): |
474 > def checkrelativity(ui, *args, **opts): |
475 > try: |
475 > try: |
476 > ui.write(extlibroot.lsub1.lsub2.notexist.text) |
476 > ui.write(extlibroot.lsub1.lsub2.notexist.text) |
477 > return 1 # unintentional success |
477 > return 1 # unintentional success |
478 > except ImportError: |
478 > except ImportError: |
507 > '''only debugcommands |
507 > '''only debugcommands |
508 > ''' |
508 > ''' |
509 > from mercurial import registrar |
509 > from mercurial import registrar |
510 > cmdtable = {} |
510 > cmdtable = {} |
511 > command = registrar.command(cmdtable) |
511 > command = registrar.command(cmdtable) |
512 > @command('debugfoobar', [], 'hg debugfoobar') |
512 > @command(b'debugfoobar', [], 'hg debugfoobar') |
513 > def debugfoobar(ui, repo, *args, **opts): |
513 > def debugfoobar(ui, repo, *args, **opts): |
514 > "yet another debug command" |
514 > "yet another debug command" |
515 > pass |
515 > pass |
516 > @command('foo', [], 'hg foo') |
516 > @command(b'foo', [], 'hg foo') |
517 > def foo(ui, repo, *args, **opts): |
517 > def foo(ui, repo, *args, **opts): |
518 > """yet another foo command |
518 > """yet another foo command |
519 > This command has been DEPRECATED since forever. |
519 > This command has been DEPRECATED since forever. |
520 > """ |
520 > """ |
521 > pass |
521 > pass |
748 > from mercurial import commands, registrar |
748 > from mercurial import commands, registrar |
749 > cmdtable = {} |
749 > cmdtable = {} |
750 > command = registrar.command(cmdtable) |
750 > command = registrar.command(cmdtable) |
751 > """multirevs extension |
751 > """multirevs extension |
752 > Big multi-line module docstring.""" |
752 > Big multi-line module docstring.""" |
753 > @command('multirevs', [], 'ARG', norepo=True) |
753 > @command(b'multirevs', [], 'ARG', norepo=True) |
754 > def multirevs(ui, repo, arg, *args, **opts): |
754 > def multirevs(ui, repo, arg, *args, **opts): |
755 > """multirevs command""" |
755 > """multirevs command""" |
756 > pass |
756 > pass |
757 > EOF |
757 > EOF |
758 $ echo "multirevs = multirevs.py" >> $HGRCPATH |
758 $ echo "multirevs = multirevs.py" >> $HGRCPATH |
823 > writes 'Foo foo' |
823 > writes 'Foo foo' |
824 > """ |
824 > """ |
825 > from mercurial import commands, registrar |
825 > from mercurial import commands, registrar |
826 > cmdtable = {} |
826 > cmdtable = {} |
827 > command = registrar.command(cmdtable) |
827 > command = registrar.command(cmdtable) |
828 > @command('dodo', [], 'hg dodo') |
828 > @command(b'dodo', [], 'hg dodo') |
829 > def dodo(ui, *args, **kwargs): |
829 > def dodo(ui, *args, **kwargs): |
830 > """Does nothing""" |
830 > """Does nothing""" |
831 > ui.write("I do nothing. Yay\\n") |
831 > ui.write("I do nothing. Yay\\n") |
832 > @command('foofoo', [], 'hg foofoo') |
832 > @command(b'foofoo', [], 'hg foofoo') |
833 > def foofoo(ui, *args, **kwargs): |
833 > def foofoo(ui, *args, **kwargs): |
834 > """Writes 'Foo foo'""" |
834 > """Writes 'Foo foo'""" |
835 > ui.write("Foo foo\\n") |
835 > ui.write("Foo foo\\n") |
836 > EOF |
836 > EOF |
837 $ dodopath=$TESTTMP/d/dodo.py |
837 $ dodopath=$TESTTMP/d/dodo.py |
934 > also writes 'Beep beep' |
934 > also writes 'Beep beep' |
935 > """ |
935 > """ |
936 > from mercurial import commands, registrar |
936 > from mercurial import commands, registrar |
937 > cmdtable = {} |
937 > cmdtable = {} |
938 > command = registrar.command(cmdtable) |
938 > command = registrar.command(cmdtable) |
939 > @command('something', [], 'hg something') |
939 > @command(b'something', [], 'hg something') |
940 > def something(ui, *args, **kwargs): |
940 > def something(ui, *args, **kwargs): |
941 > """Does something""" |
941 > """Does something""" |
942 > ui.write("I do something. Yaaay\\n") |
942 > ui.write("I do something. Yaaay\\n") |
943 > @command('beep', [], 'hg beep') |
943 > @command(b'beep', [], 'hg beep') |
944 > def beep(ui, *args, **kwargs): |
944 > def beep(ui, *args, **kwargs): |
945 > """Writes 'Beep beep'""" |
945 > """Writes 'Beep beep'""" |
946 > ui.write("Beep beep\\n") |
946 > ui.write("Beep beep\\n") |
947 > EOF |
947 > EOF |
948 $ dudupath=$TESTTMP/d/dudu.py |
948 $ dudupath=$TESTTMP/d/dudu.py |
1178 $ cat > throw.py <<EOF |
1178 $ cat > throw.py <<EOF |
1179 > from mercurial import commands, registrar, util |
1179 > from mercurial import commands, registrar, util |
1180 > cmdtable = {} |
1180 > cmdtable = {} |
1181 > command = registrar.command(cmdtable) |
1181 > command = registrar.command(cmdtable) |
1182 > class Bogon(Exception): pass |
1182 > class Bogon(Exception): pass |
1183 > @command('throw', [], 'hg throw', norepo=True) |
1183 > @command(b'throw', [], 'hg throw', norepo=True) |
1184 > def throw(ui, **opts): |
1184 > def throw(ui, **opts): |
1185 > """throws an exception""" |
1185 > """throws an exception""" |
1186 > raise Bogon() |
1186 > raise Bogon() |
1187 > EOF |
1187 > EOF |
1188 |
1188 |
1615 |
1615 |
1616 $ cat > nonregistrar.py <<EOF |
1616 $ cat > nonregistrar.py <<EOF |
1617 > from mercurial import cmdutil |
1617 > from mercurial import cmdutil |
1618 > cmdtable = {} |
1618 > cmdtable = {} |
1619 > command = cmdutil.command(cmdtable) |
1619 > command = cmdutil.command(cmdtable) |
1620 > @command('foo', [], norepo=True) |
1620 > @command(b'foo', [], norepo=True) |
1621 > def foo(ui): |
1621 > def foo(ui): |
1622 > pass |
1622 > pass |
1623 > EOF |
1623 > EOF |
1624 |
1624 |
1625 $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null |
1625 $ hg --config extensions.nonregistrar=`pwd`/nonregistrar.py version > /dev/null |