We are now close to getting this test pass on Python 3.
- skip-blame because just b'' prefixes.
hg-reviewers |
We are now close to getting this test pass on Python 3.
Automatic diff as part of commit; lint not applicable. |
Automatic diff as part of commit; unit tests not applicable. |
Test basic extension support | Test basic extension support | ||||
$ cat > foobar.py <<EOF | $ cat > foobar.py <<EOF | ||||
> import os | > import os | ||||
> from mercurial import commands, registrar | > from mercurial import commands, registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> configtable = {} | > configtable = {} | ||||
> configitem = registrar.configitem(configtable) | > configitem = registrar.configitem(configtable) | ||||
> configitem('tests', 'foo', default="Foo") | > configitem(b'tests', b'foo', default=b"Foo") | ||||
> def uisetup(ui): | > def uisetup(ui): | ||||
> ui.write("uisetup called\\n") | > ui.write(b"uisetup called\\n") | ||||
> ui.flush() | > ui.flush() | ||||
> def reposetup(ui, repo): | > def reposetup(ui, repo): | ||||
> ui.write("reposetup called for %s\\n" % os.path.basename(repo.root)) | > ui.write(b"reposetup called for %s\\n" % os.path.basename(repo.root)) | ||||
> ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!")) | > ui.write(b"ui %s= repo.ui\\n" % (ui == repo.ui and b"=" or b"!")) | ||||
> ui.flush() | > ui.flush() | ||||
> @command(b'foo', [], 'hg foo') | > @command(b'foo', [], b'hg foo') | ||||
> def foo(ui, *args, **kwargs): | > def foo(ui, *args, **kwargs): | ||||
> foo = ui.config('tests', 'foo') | > foo = ui.config(b'tests', b'foo') | ||||
> ui.write(foo) | > ui.write(foo) | ||||
> ui.write("\\n") | > ui.write(b"\\n") | ||||
> @command(b'bar', [], 'hg bar', norepo=True) | > @command(b'bar', [], b'hg bar', norepo=True) | ||||
> def bar(ui, *args, **kwargs): | > def bar(ui, *args, **kwargs): | ||||
> ui.write("Bar\\n") | > ui.write(b"Bar\\n") | ||||
> EOF | > EOF | ||||
$ abspath=`pwd`/foobar.py | $ abspath=`pwd`/foobar.py | ||||
$ mkdir barfoo | $ mkdir barfoo | ||||
$ cp foobar.py barfoo/__init__.py | $ cp foobar.py barfoo/__init__.py | ||||
$ barfoopath=`pwd`/barfoo | $ barfoopath=`pwd`/barfoo | ||||
$ hg init a | $ hg init a | ||||
> # "absolute" and "relative" shouldn't be imported before actual | > # "absolute" and "relative" shouldn't be imported before actual | ||||
> # command execution, because (1) they import same modules, and (2) | > # command execution, because (1) they import same modules, and (2) | ||||
> # preceding import (= instantiate "demandmod" object instead of | > # preceding import (= instantiate "demandmod" object instead of | ||||
> # real "module" object) might hide problem of succeeding import. | > # real "module" object) might hide problem of succeeding import. | ||||
> | > | ||||
> @command(b'showabsolute', [], norepo=True) | > @command(b'showabsolute', [], norepo=True) | ||||
> def showabsolute(ui, *args, **opts): | > def showabsolute(ui, *args, **opts): | ||||
> from absextroot import absolute | > from absextroot import absolute | ||||
> ui.write('ABS: %s\n' % '\nABS: '.join(absolute.getresult())) | > ui.write(b'ABS: %s\n' % '\nABS: '.join(absolute.getresult())) | ||||
> | > | ||||
> @command(b'showrelative', [], norepo=True) | > @command(b'showrelative', [], norepo=True) | ||||
> def showrelative(ui, *args, **opts): | > def showrelative(ui, *args, **opts): | ||||
> from . import relative | > from . import relative | ||||
> ui.write('REL: %s\n' % '\nREL: '.join(relative.getresult())) | > ui.write(b'REL: %s\n' % '\nREL: '.join(relative.getresult())) | ||||
> | > | ||||
> # import modules from external library | > # import modules from external library | ||||
> from extlibroot.lsub1.lsub2 import used as lused, unused as lunused | > from extlibroot.lsub1.lsub2 import used as lused, unused as lunused | ||||
> from extlibroot.lsub1.lsub2.called import func as lfunc | > from extlibroot.lsub1.lsub2.called import func as lfunc | ||||
> from extlibroot.recursedown import absdetail, legacydetail | > from extlibroot.recursedown import absdetail, legacydetail | ||||
> from extlibroot.shadowing import proxied | > from extlibroot.shadowing import proxied | ||||
> | > | ||||
> def uisetup(ui): | > def uisetup(ui): | ||||
$ echo 'empty = !' >> $HGRCPATH | $ echo 'empty = !' >> $HGRCPATH | ||||
$ cat > debugextension.py <<EOF | $ cat > debugextension.py <<EOF | ||||
> '''only debugcommands | > '''only debugcommands | ||||
> ''' | > ''' | ||||
> from mercurial import registrar | > from mercurial import registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> @command(b'debugfoobar', [], 'hg debugfoobar') | > @command(b'debugfoobar', [], b'hg debugfoobar') | ||||
> def debugfoobar(ui, repo, *args, **opts): | > def debugfoobar(ui, repo, *args, **opts): | ||||
> "yet another debug command" | > "yet another debug command" | ||||
> pass | > pass | ||||
> @command(b'foo', [], 'hg foo') | > @command(b'foo', [], b'hg foo') | ||||
> def foo(ui, repo, *args, **opts): | > def foo(ui, repo, *args, **opts): | ||||
> """yet another foo command | > """yet another foo command | ||||
> This command has been DEPRECATED since forever. | > This command has been DEPRECATED since forever. | ||||
> """ | > """ | ||||
> pass | > pass | ||||
> EOF | > EOF | ||||
$ debugpath=`pwd`/debugextension.py | $ debugpath=`pwd`/debugextension.py | ||||
$ echo "debugextension = $debugpath" >> $HGRCPATH | $ echo "debugextension = $debugpath" >> $HGRCPATH | ||||
Test help topic with same name as extension | Test help topic with same name as extension | ||||
$ cat > multirevs.py <<EOF | $ cat > multirevs.py <<EOF | ||||
> from mercurial import commands, registrar | > from mercurial import commands, registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> """multirevs extension | > """multirevs extension | ||||
> Big multi-line module docstring.""" | > Big multi-line module docstring.""" | ||||
> @command(b'multirevs', [], 'ARG', norepo=True) | > @command(b'multirevs', [], b'ARG', norepo=True) | ||||
> def multirevs(ui, repo, arg, *args, **opts): | > def multirevs(ui, repo, arg, *args, **opts): | ||||
> """multirevs command""" | > """multirevs command""" | ||||
> pass | > pass | ||||
> EOF | > EOF | ||||
$ echo "multirevs = multirevs.py" >> $HGRCPATH | $ echo "multirevs = multirevs.py" >> $HGRCPATH | ||||
$ hg help multirevs | tail | $ hg help multirevs | tail | ||||
used): | used): | ||||
$ cat > $TESTTMP/d/dodo.py <<EOF | $ cat > $TESTTMP/d/dodo.py <<EOF | ||||
> """ | > """ | ||||
> This is an awesome 'dodo' extension. It does nothing and | > This is an awesome 'dodo' extension. It does nothing and | ||||
> writes 'Foo foo' | > writes 'Foo foo' | ||||
> """ | > """ | ||||
> from mercurial import commands, registrar | > from mercurial import commands, registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> @command(b'dodo', [], 'hg dodo') | > @command(b'dodo', [], b'hg dodo') | ||||
> def dodo(ui, *args, **kwargs): | > def dodo(ui, *args, **kwargs): | ||||
> """Does nothing""" | > """Does nothing""" | ||||
> ui.write("I do nothing. Yay\\n") | > ui.write(b"I do nothing. Yay\\n") | ||||
> @command(b'foofoo', [], 'hg foofoo') | > @command(b'foofoo', [], b'hg foofoo') | ||||
> def foofoo(ui, *args, **kwargs): | > def foofoo(ui, *args, **kwargs): | ||||
> """Writes 'Foo foo'""" | > """Writes 'Foo foo'""" | ||||
> ui.write("Foo foo\\n") | > ui.write(b"Foo foo\\n") | ||||
> EOF | > EOF | ||||
$ dodopath=$TESTTMP/d/dodo.py | $ dodopath=$TESTTMP/d/dodo.py | ||||
$ echo "dodo = $dodopath" >> $HGRCPATH | $ echo "dodo = $dodopath" >> $HGRCPATH | ||||
Make sure that user is asked to enter '-v -e' to get list of built-in aliases | Make sure that user is asked to enter '-v -e' to get list of built-in aliases | ||||
$ hg help -e dodo | $ hg help -e dodo | ||||
dodo extension - | dodo extension - | ||||
$ cat > $TESTTMP/d/dudu.py <<EOF | $ cat > $TESTTMP/d/dudu.py <<EOF | ||||
> """ | > """ | ||||
> This is an awesome 'dudu' extension. It does something and | > This is an awesome 'dudu' extension. It does something and | ||||
> also writes 'Beep beep' | > also writes 'Beep beep' | ||||
> """ | > """ | ||||
> from mercurial import commands, registrar | > from mercurial import commands, registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> @command(b'something', [], 'hg something') | > @command(b'something', [], b'hg something') | ||||
> def something(ui, *args, **kwargs): | > def something(ui, *args, **kwargs): | ||||
> """Does something""" | > """Does something""" | ||||
> ui.write("I do something. Yaaay\\n") | > ui.write(b"I do something. Yaaay\\n") | ||||
> @command(b'beep', [], 'hg beep') | > @command(b'beep', [], b'hg beep') | ||||
> def beep(ui, *args, **kwargs): | > def beep(ui, *args, **kwargs): | ||||
> """Writes 'Beep beep'""" | > """Writes 'Beep beep'""" | ||||
> ui.write("Beep beep\\n") | > ui.write(b"Beep beep\\n") | ||||
> EOF | > EOF | ||||
$ dudupath=$TESTTMP/d/dudu.py | $ dudupath=$TESTTMP/d/dudu.py | ||||
$ echo "dudu = $dudupath" >> $HGRCPATH | $ echo "dudu = $dudupath" >> $HGRCPATH | ||||
$ hg help -e dudu | $ hg help -e dudu | ||||
dudu extension - | dudu extension - | ||||
(try 'hg help --keyword foo') | (try 'hg help --keyword foo') | ||||
[255] | [255] | ||||
$ cat > throw.py <<EOF | $ cat > throw.py <<EOF | ||||
> from mercurial import commands, registrar, util | > from mercurial import commands, registrar, util | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> class Bogon(Exception): pass | > class Bogon(Exception): pass | ||||
> @command(b'throw', [], 'hg throw', norepo=True) | > @command(b'throw', [], b'hg throw', norepo=True) | ||||
> def throw(ui, **opts): | > def throw(ui, **opts): | ||||
> """throws an exception""" | > """throws an exception""" | ||||
> raise Bogon() | > raise Bogon() | ||||
> EOF | > EOF | ||||
No declared supported version, extension complains: | No declared supported version, extension complains: | ||||
$ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | ||||
** Unknown exception encountered with possibly-broken third-party extension throw | ** Unknown exception encountered with possibly-broken third-party extension throw | ||||
** If that fixes the bug please report it to http://example.com/bts | ** If that fixes the bug please report it to http://example.com/bts | ||||
** Python * (glob) | ** Python * (glob) | ||||
** Mercurial Distributed SCM (*) (glob) | ** Mercurial Distributed SCM (*) (glob) | ||||
** Extensions loaded: throw | ** Extensions loaded: throw | ||||
If the extensions declare outdated versions, accuse the older extension first: | If the extensions declare outdated versions, accuse the older extension first: | ||||
$ echo "from mercurial import util" >> older.py | $ echo "from mercurial import util" >> older.py | ||||
$ echo "util.version = lambda:'2.2'" >> older.py | $ echo "util.version = lambda:'2.2'" >> older.py | ||||
$ echo "testedwith = '1.9.3'" >> older.py | $ echo "testedwith = b'1.9.3'" >> older.py | ||||
$ echo "testedwith = '2.1.1'" >> throw.py | $ echo "testedwith = b'2.1.1'" >> throw.py | ||||
$ rm -f throw.pyc throw.pyo | $ rm -f throw.pyc throw.pyo | ||||
$ rm -Rf __pycache__ | $ rm -Rf __pycache__ | ||||
$ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | $ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | ||||
> throw 2>&1 | egrep '^\*\*' | > throw 2>&1 | egrep '^\*\*' | ||||
** Unknown exception encountered with possibly-broken third-party extension older | ** Unknown exception encountered with possibly-broken third-party extension older | ||||
** which supports versions 1.9 of Mercurial. | ** which supports versions 1.9 of Mercurial. | ||||
** Please disable older and try your action again. | ** Please disable older and try your action again. | ||||
** If that fixes the bug please report it to the extension author. | ** If that fixes the bug please report it to the extension author. | ||||
** Python * (glob) | ** Python * (glob) | ||||
** Mercurial Distributed SCM (version 2.2) | ** Mercurial Distributed SCM (version 2.2) | ||||
** Extensions loaded: throw, older | ** Extensions loaded: throw, older | ||||
One extension only tested with older, one only with newer versions: | One extension only tested with older, one only with newer versions: | ||||
$ echo "util.version = lambda:'2.1'" >> older.py | $ echo "util.version = lambda:b'2.1'" >> older.py | ||||
$ rm -f older.pyc older.pyo | $ rm -f older.pyc older.pyo | ||||
$ rm -Rf __pycache__ | $ rm -Rf __pycache__ | ||||
$ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | $ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | ||||
> throw 2>&1 | egrep '^\*\*' | > throw 2>&1 | egrep '^\*\*' | ||||
** Unknown exception encountered with possibly-broken third-party extension older | ** Unknown exception encountered with possibly-broken third-party extension older | ||||
** which supports versions 1.9 of Mercurial. | ** which supports versions 1.9 of Mercurial. | ||||
** Please disable older and try your action again. | ** Please disable older and try your action again. | ||||
** If that fixes the bug please report it to the extension author. | ** If that fixes the bug please report it to the extension author. | ||||
** Python * (glob) | ** Python * (glob) | ||||
** Mercurial Distributed SCM (version 2.1) | ** Mercurial Distributed SCM (version 2.1) | ||||
** Extensions loaded: throw, older | ** Extensions loaded: throw, older | ||||
Older extension is tested with current version, the other only with newer: | Older extension is tested with current version, the other only with newer: | ||||
$ echo "util.version = lambda:'1.9.3'" >> older.py | $ echo "util.version = lambda:b'1.9.3'" >> older.py | ||||
$ rm -f older.pyc older.pyo | $ rm -f older.pyc older.pyo | ||||
$ rm -Rf __pycache__ | $ rm -Rf __pycache__ | ||||
$ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | $ hg --config extensions.throw=throw.py --config extensions.older=older.py \ | ||||
> throw 2>&1 | egrep '^\*\*' | > throw 2>&1 | egrep '^\*\*' | ||||
** Unknown exception encountered with possibly-broken third-party extension throw | ** Unknown exception encountered with possibly-broken third-party extension throw | ||||
** which supports versions 2.1 of Mercurial. | ** which supports versions 2.1 of Mercurial. | ||||
** Please disable throw and try your action again. | ** Please disable throw and try your action again. | ||||
** If that fixes the bug please report it to http://example.com/bts | ** If that fixes the bug please report it to http://example.com/bts | ||||
$ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | ||||
** unknown exception encountered, please report by visiting | ** unknown exception encountered, please report by visiting | ||||
** https://mercurial-scm.org/wiki/BugTracker | ** https://mercurial-scm.org/wiki/BugTracker | ||||
** Python * (glob) | ** Python * (glob) | ||||
** Mercurial Distributed SCM (*) (glob) | ** Mercurial Distributed SCM (*) (glob) | ||||
** Extensions loaded: throw | ** Extensions loaded: throw | ||||
Patch version is ignored during compatibility check | Patch version is ignored during compatibility check | ||||
$ echo "testedwith = '3.2'" >> throw.py | $ echo "testedwith = b'3.2'" >> throw.py | ||||
$ echo "util.version = lambda:'3.2.2'" >> throw.py | $ echo "util.version = lambda:b'3.2.2'" >> throw.py | ||||
$ rm -f throw.pyc throw.pyo | $ rm -f throw.pyc throw.pyo | ||||
$ rm -Rf __pycache__ | $ rm -Rf __pycache__ | ||||
$ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | $ hg --config extensions.throw=throw.py throw 2>&1 | egrep '^\*\*' | ||||
** unknown exception encountered, please report by visiting | ** unknown exception encountered, please report by visiting | ||||
** https://mercurial-scm.org/wiki/BugTracker | ** https://mercurial-scm.org/wiki/BugTracker | ||||
** Python * (glob) | ** Python * (glob) | ||||
** Mercurial Distributed SCM (*) (glob) | ** Mercurial Distributed SCM (*) (glob) | ||||
** Extensions loaded: throw | ** Extensions loaded: throw | ||||
> -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}' | > -T'{extensions % "{name} {pad(ver, 16)} ({if(bundled, "internal", "external")})\n"}' | ||||
throw 1.twentythree (external) | throw 1.twentythree (external) | ||||
strip (internal) | strip (internal) | ||||
Refuse to load extensions with minimum version requirements | Refuse to load extensions with minimum version requirements | ||||
$ cat > minversion1.py << EOF | $ cat > minversion1.py << EOF | ||||
> from mercurial import util | > from mercurial import util | ||||
> util.version = lambda: '3.5.2' | > util.version = lambda: b'3.5.2' | ||||
> minimumhgversion = '3.6' | > minimumhgversion = b'3.6' | ||||
> EOF | > EOF | ||||
$ hg --config extensions.minversion=minversion1.py version | $ hg --config extensions.minversion=minversion1.py version | ||||
(third party extension minversion requires version 3.6 or newer of Mercurial; disabling) | (third party extension minversion requires version 3.6 or newer of Mercurial; disabling) | ||||
Mercurial Distributed SCM (version 3.5.2) | Mercurial Distributed SCM (version 3.5.2) | ||||
(see https://mercurial-scm.org for more information) | (see https://mercurial-scm.org for more information) | ||||
Copyright (C) 2005-* Matt Mackall and others (glob) | Copyright (C) 2005-* Matt Mackall and others (glob) | ||||
This is free software; see the source for copying conditions. There is NO | This is free software; see the source for copying conditions. There is NO | ||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||
$ cat > minversion2.py << EOF | $ cat > minversion2.py << EOF | ||||
> from mercurial import util | > from mercurial import util | ||||
> util.version = lambda: '3.6' | > util.version = lambda: b'3.6' | ||||
> minimumhgversion = '3.7' | > minimumhgversion = b'3.7' | ||||
> EOF | > EOF | ||||
$ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third' | $ hg --config extensions.minversion=minversion2.py version 2>&1 | egrep '\(third' | ||||
(third party extension minversion requires version 3.7 or newer of Mercurial; disabling) | (third party extension minversion requires version 3.7 or newer of Mercurial; disabling) | ||||
Can load version that is only off by point release | Can load version that is only off by point release | ||||
$ cat > minversion2.py << EOF | $ cat > minversion2.py << EOF | ||||
> from mercurial import util | > from mercurial import util | ||||
> util.version = lambda: '3.6.1' | > util.version = lambda: b'3.6.1' | ||||
> minimumhgversion = '3.6' | > minimumhgversion = b'3.6' | ||||
> EOF | > EOF | ||||
$ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' | $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' | ||||
[1] | [1] | ||||
Can load minimum version identical to current | Can load minimum version identical to current | ||||
$ cat > minversion3.py << EOF | $ cat > minversion3.py << EOF | ||||
> from mercurial import util | > from mercurial import util | ||||
> util.version = lambda: '3.5' | > util.version = lambda: b'3.5' | ||||
> minimumhgversion = '3.5' | > minimumhgversion = b'3.5' | ||||
> EOF | > EOF | ||||
$ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' | $ hg --config extensions.minversion=minversion3.py version 2>&1 | egrep '\(third' | ||||
[1] | [1] | ||||
Restore HGRCPATH | Restore HGRCPATH | ||||
$ HGRCPATH=$ORGHGRCPATH | $ HGRCPATH=$ORGHGRCPATH | ||||
$ export HGRCPATH | $ export HGRCPATH | ||||
Commands handling multiple repositories at a time should invoke only | Commands handling multiple repositories at a time should invoke only | ||||
"reposetup()" of extensions enabling in the target repository. | "reposetup()" of extensions enabling in the target repository. | ||||
$ mkdir reposetup-test | $ mkdir reposetup-test | ||||
$ cd reposetup-test | $ cd reposetup-test | ||||
$ cat > $TESTTMP/reposetuptest.py <<EOF | $ cat > $TESTTMP/reposetuptest.py <<EOF | ||||
> from mercurial import extensions | > from mercurial import extensions | ||||
> def reposetup(ui, repo): | > def reposetup(ui, repo): | ||||
> ui.write('reposetup() for %s\n' % (repo.root)) | > ui.write(b'reposetup() for %s\n' % (repo.root)) | ||||
> ui.flush() | > ui.flush() | ||||
> EOF | > EOF | ||||
$ hg init src | $ hg init src | ||||
$ echo a > src/a | $ echo a > src/a | ||||
$ hg -R src commit -Am '#0 at src/a' | $ hg -R src commit -Am '#0 at src/a' | ||||
adding a | adding a | ||||
$ echo '[extensions]' >> src/.hg/hgrc | $ echo '[extensions]' >> src/.hg/hgrc | ||||
$ echo '# enable extension locally' >> src/.hg/hgrc | $ echo '# enable extension locally' >> src/.hg/hgrc | ||||
$ hg init deprecated | $ hg init deprecated | ||||
$ cd deprecated | $ cd deprecated | ||||
$ cat <<EOF > deprecatedcmd.py | $ cat <<EOF > deprecatedcmd.py | ||||
> def deprecatedcmd(repo, ui): | > def deprecatedcmd(repo, ui): | ||||
> pass | > pass | ||||
> cmdtable = { | > cmdtable = { | ||||
> 'deprecatedcmd': (deprecatedcmd, [], ''), | > b'deprecatedcmd': (deprecatedcmd, [], b''), | ||||
> } | > } | ||||
> EOF | > EOF | ||||
$ cat <<EOF > .hg/hgrc | $ cat <<EOF > .hg/hgrc | ||||
> [extensions] | > [extensions] | ||||
> deprecatedcmd = `pwd`/deprecatedcmd.py | > deprecatedcmd = `pwd`/deprecatedcmd.py | ||||
> mq = ! | > mq = ! | ||||
> hgext.mq = ! | > hgext.mq = ! | ||||
> hgext/mq = ! | > hgext/mq = ! | ||||
> from mercurial import commands, extensions | > from mercurial import commands, extensions | ||||
> def exbookmarks(orig, *args, **opts): | > def exbookmarks(orig, *args, **opts): | ||||
> return orig(*args, **opts) | > return orig(*args, **opts) | ||||
> def uisetup(ui): | > def uisetup(ui): | ||||
> synopsis = ' GREPME [--foo] [-x]' | > synopsis = ' GREPME [--foo] [-x]' | ||||
> docstring = ''' | > docstring = ''' | ||||
> GREPME make sure that this is in the help! | > GREPME make sure that this is in the help! | ||||
> ''' | > ''' | ||||
> extensions.wrapcommand(commands.table, 'bookmarks', exbookmarks, | > extensions.wrapcommand(commands.table, b'bookmarks', exbookmarks, | ||||
> synopsis, docstring) | > synopsis, docstring) | ||||
> EOF | > EOF | ||||
$ abspath=`pwd`/exthelp.py | $ abspath=`pwd`/exthelp.py | ||||
$ echo '[extensions]' >> $HGRCPATH | $ echo '[extensions]' >> $HGRCPATH | ||||
$ echo "exthelp = $abspath" >> $HGRCPATH | $ echo "exthelp = $abspath" >> $HGRCPATH | ||||
$ cd exthelp | $ cd exthelp | ||||
$ hg help bookmarks | grep GREPME | $ hg help bookmarks | grep GREPME | ||||
hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x] | hg bookmarks [OPTIONS]... [NAME]... GREPME [--foo] [-x] | ||||
Prohibit the use of unicode strings as the default value of options | Prohibit the use of unicode strings as the default value of options | ||||
$ hg init $TESTTMP/opt-unicode-default | $ hg init $TESTTMP/opt-unicode-default | ||||
$ cat > $TESTTMP/test_unicode_default_value.py << EOF | $ cat > $TESTTMP/test_unicode_default_value.py << EOF | ||||
> from mercurial import registrar | > from mercurial import registrar | ||||
> cmdtable = {} | > cmdtable = {} | ||||
> command = registrar.command(cmdtable) | > command = registrar.command(cmdtable) | ||||
> @command('dummy', [('', 'opt', u'value', u'help')], 'ext [OPTIONS]') | > @command(b'dummy', [('', 'opt', u'value', u'help')], 'ext [OPTIONS]') | ||||
> def ext(*args, **opts): | > def ext(*args, **opts): | ||||
> print(opts['opt']) | > print(opts['opt']) | ||||
> EOF | > EOF | ||||
$ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF | $ cat > $TESTTMP/opt-unicode-default/.hg/hgrc << EOF | ||||
> [extensions] | > [extensions] | ||||
> test_unicode_default_value = $TESTTMP/test_unicode_default_value.py | > test_unicode_default_value = $TESTTMP/test_unicode_default_value.py | ||||
> EOF | > EOF | ||||
$ hg -R $TESTTMP/opt-unicode-default dummy | $ hg -R $TESTTMP/opt-unicode-default dummy | ||||
*** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode u'value' found in cmdtable.dummy | *** failed to import extension test_unicode_default_value from $TESTTMP/test_unicode_default_value.py: unicode u'value' found in cmdtable.dummy | ||||
*** (use b'' to make it byte string) | *** (use b'' to make it byte string) | ||||
hg: unknown command 'dummy' | hg: unknown command 'dummy' | ||||
(did you mean summary?) | (did you mean summary?) | ||||
[255] | [255] |