##// END OF EJS Templates
identify: add template support...
identify: add template support This is based on a patch proposed last year by Mathias De Maré[1], with a few changes. - Tags and bookmarks are now formatted lists, for more flexible queries. - The templater is populated whether or not [-nibtB] is specified. (Plain output is unchanged.) This seems more consistent with other templated commands. - The 'id' property is a string, instead of a list. - The parents of 'wdir()' have their own list of attributes. I left 'id' as a string because it seems very useful for generating version info. It's also a bit strange because the value and meaning changes depending on whether or not --debug is passed (short vs full hash), whether the revision is a merge or not (one hash or two, separated by a '+'), the working directory or not (node vs p1node), and local or not (remote defaults to tip, and never has '+'). The equivalent string built with {rev} seems much less useful, and I couldn't think of a reasonable name, so I left it out. The discussion seemed to be pointing towards having a list of nodes, with more than one entry for a merge. It seems simpler to give the nodes a name, and use {node} for the actual commit probed, especially now that there is a virtual node for 'wdir()'. Yuya mentioned using fm.nested() in that thread, so I did for the parent nodes. I'm not sure if the plan is to fill in all of the context attributes in these items, or if these nested items should simply be made {p1node} and {p1rev}. I used ':' as the tag separator for consistency with {tags} in the log templater. Likewise, bookmarks are separated by a space for consistency with the corresponding log template. [1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-August/087039.html

File last commit:

r32987:149b6822 default
r33051:15a79ac8 default
Show More
test-devel-warnings.t
215 lines | 8.1 KiB | text/troff | Tads3Lexer
/ tests / test-devel-warnings.t
Pierre-Yves David
devel: move the lock-checking code into core...
r24386
$ cat << EOF > buggylocking.py
Pierre-Yves David
test: update the docstring of 'test-devel-warnings.t' extension...
r27270 > """A small extension that tests our developer warnings
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > """
>
Yuya Nishihara
error: add hint to ProgrammingError...
r32340 > from mercurial import error, registrar, repair, util
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 >
> cmdtable = {}
Yuya Nishihara
registrar: move cmdutil.command to registrar module (API)...
r32337 > command = registrar.command(cmdtable)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 >
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'buggylocking', [], '')
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > def buggylocking(ui, repo):
> lo = repo.lock()
> wl = repo.wlock()
Matt Mackall
tests: avoid deprecation warning
r24392 > wl.release()
> lo.release()
Pierre-Yves David
wlock: only issue devel warning when actually acquiring the lock...
r24744 >
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'buggytransaction', [], '')
Pierre-Yves David
test: extract develwarn transaction testing in its own command...
r29185 > def buggylocking(ui, repo):
> tr = repo.transaction('buggy')
> # make sure we rollback the transaction as we don't want to rely on the__del__
> tr.release()
>
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'properlocking', [], '')
Pierre-Yves David
wlock: only issue devel warning when actually acquiring the lock...
r24744 > def properlocking(ui, repo):
> """check that reentrance is fine"""
> wl = repo.wlock()
> lo = repo.lock()
> tr = repo.transaction('proper')
> tr2 = repo.transaction('proper')
> lo2 = repo.lock()
> wl2 = repo.wlock()
> wl2.release()
> lo2.release()
> tr2.close()
> tr.close()
> lo.release()
> wl.release()
Pierre-Yves David
wlock: do not warn for non-wait locking...
r24750 >
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'nowaitlocking', [], '')
Pierre-Yves David
wlock: do not warn for non-wait locking...
r24750 > def nowaitlocking(ui, repo):
> lo = repo.lock()
> wl = repo.wlock(wait=False)
> wl.release()
> lo.release()
Pierre-Yves David
repair: forbid strip from inside a transaction...
r25300 >
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'stripintr', [], '')
Pierre-Yves David
repair: forbid strip from inside a transaction...
r25300 > def stripintr(ui, repo):
> lo = repo.lock()
> tr = repo.transaction('foobar')
> try:
> repair.strip(repo.ui, repo, [repo['.'].node()])
> finally:
> lo.release()
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'oldanddeprecated', [], '')
Pierre-Yves David
ui: add a 'deprecwarn' helper to issue deprecation warnings...
r27275 > def oldanddeprecated(ui, repo):
> """test deprecation warning API"""
> def foobar(ui):
> ui.deprecwarn('foorbar is deprecated, go shopping', '42.1337')
> foobar(ui)
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'nouiwarning', [], '')
Pierre-Yves David
util: add a way to issue deprecation warning without a UI object...
r31950 > def nouiwarning(ui, repo):
> util.nouideprecwarn('this is a test', '13.37')
Pulkit Goyal
py3: make sure the commands name are bytes in test-devel-warnings.t
r32971 > @command(b'programmingerror', [], '')
Yuya Nishihara
error: add hint to ProgrammingError...
r32340 > def programmingerror(ui, repo):
> raise error.ProgrammingError('something went wrong', hint='try again')
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > EOF
$ cat << EOF >> $HGRCPATH
> [extensions]
> buggylocking=$TESTTMP/buggylocking.py
timeless
ui: log devel warnings
r28498 > mock=$TESTDIR/mockblackbox.py
> blackbox=
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > [devel]
Pierre-Yves David
devel: rename 'all' to 'all-warnings' (BC)...
r25290 > all-warnings=1
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > EOF
$ hg init lock-checker
$ cd lock-checker
$ hg buggylocking
timeless
tests: relax test-devel-warnings to reduce false positives...
r28016 devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:* (buggylocking) (glob)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 $ cat << EOF >> $HGRCPATH
> [devel]
> all=0
> check-locks=1
> EOF
$ hg buggylocking
timeless
tests: relax test-devel-warnings to reduce false positives...
r28016 devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:* (buggylocking) (glob)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 $ hg buggylocking --traceback
Pierre-Yves David
devel-warn: add a prefix to all messages ("devel-warn: ")...
r24755 devel-warn: "wlock" acquired after "lock" at:
Matt Mackall
tests: fix py2.4 glob for devel warnings
r24555 */hg:* in * (glob)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 */mercurial/dispatch.py:* in run (glob)
*/mercurial/dispatch.py:* in dispatch (glob)
*/mercurial/dispatch.py:* in _runcatch (glob)
Yuya Nishihara
dispatch: mark callcatch() as a private function
r32040 */mercurial/dispatch.py:* in _callcatch (glob)
Jun Wu
dispatch: move part of callcatch to scmutil...
r30520 */mercurial/scmutil.py* in callcatch (glob)
Jun Wu
dispatch: split global error handling out so it can be reused...
r29761 */mercurial/dispatch.py:* in _runcatchfunc (glob)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 */mercurial/dispatch.py:* in _dispatch (glob)
*/mercurial/dispatch.py:* in runcommand (glob)
*/mercurial/dispatch.py:* in _runcommand (glob)
*/mercurial/dispatch.py:* in <lambda> (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in buggylocking (glob)
Pierre-Yves David
wlock: only issue devel warning when actually acquiring the lock...
r24744 $ hg properlocking
Pierre-Yves David
wlock: do not warn for non-wait locking...
r24750 $ hg nowaitlocking
Pierre-Yves David
repair: forbid strip from inside a transaction...
r25300
$ echo a > a
$ hg add a
$ hg commit -m a
Jun Wu
repair: use ProgrammingError
r31645 $ hg stripintr 2>&1 | egrep -v '^(\*\*| )'
Traceback (most recent call last):
mercurial.error.ProgrammingError: cannot strip from inside a transaction
Pierre-Yves David
repair: forbid strip from inside a transaction...
r25300
Pierre-Yves David
ui: add a 'deprecwarn' helper to issue deprecation warnings...
r27275 $ hg oldanddeprecated
devel-warn: foorbar is deprecated, go shopping
timeless
tests: relax test-devel-warnings to reduce false positives...
r28016 (compatibility will be dropped after Mercurial-42.1337, update your code.) at: $TESTTMP/buggylocking.py:* (oldanddeprecated) (glob)
Pierre-Yves David
devel-warn: issue a warning for old style revsets...
r25630
Pierre-Yves David
ui: add a 'deprecwarn' helper to issue deprecation warnings...
r27275 $ hg oldanddeprecated --traceback
devel-warn: foorbar is deprecated, go shopping
(compatibility will be dropped after Mercurial-42.1337, update your code.) at:
*/hg:* in <module> (glob)
*/mercurial/dispatch.py:* in run (glob)
*/mercurial/dispatch.py:* in dispatch (glob)
*/mercurial/dispatch.py:* in _runcatch (glob)
Yuya Nishihara
dispatch: mark callcatch() as a private function
r32040 */mercurial/dispatch.py:* in _callcatch (glob)
Jun Wu
dispatch: move part of callcatch to scmutil...
r30520 */mercurial/scmutil.py* in callcatch (glob)
Jun Wu
dispatch: split global error handling out so it can be reused...
r29761 */mercurial/dispatch.py:* in _runcatchfunc (glob)
Pierre-Yves David
ui: add a 'deprecwarn' helper to issue deprecation warnings...
r27275 */mercurial/dispatch.py:* in _dispatch (glob)
*/mercurial/dispatch.py:* in runcommand (glob)
*/mercurial/dispatch.py:* in _runcommand (glob)
*/mercurial/dispatch.py:* in <lambda> (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in oldanddeprecated (glob)
Yuya Nishihara
revset: stop supporting predicate that returns plain list (API)...
r31809 $ hg blackbox -l 7
timeless
ui: log devel warnings
r28498 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated
1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: foorbar is deprecated, go shopping
(compatibility will be dropped after Mercurial-42.1337, update your code.) at: $TESTTMP/buggylocking.py:* (oldanddeprecated) (glob)
1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated exited 0 after * seconds (glob)
1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated --traceback
1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> devel-warn: foorbar is deprecated, go shopping
(compatibility will be dropped after Mercurial-42.1337, update your code.) at:
*/hg:* in <module> (glob)
*/mercurial/dispatch.py:* in run (glob)
*/mercurial/dispatch.py:* in dispatch (glob)
*/mercurial/dispatch.py:* in _runcatch (glob)
Yuya Nishihara
dispatch: mark callcatch() as a private function
r32040 */mercurial/dispatch.py:* in _callcatch (glob)
Jun Wu
dispatch: move part of callcatch to scmutil...
r30520 */mercurial/scmutil.py* in callcatch (glob)
Jun Wu
dispatch: split global error handling out so it can be reused...
r29761 */mercurial/dispatch.py:* in _runcatchfunc (glob)
timeless
ui: log devel warnings
r28498 */mercurial/dispatch.py:* in _dispatch (glob)
*/mercurial/dispatch.py:* in runcommand (glob)
*/mercurial/dispatch.py:* in _runcommand (glob)
*/mercurial/dispatch.py:* in <lambda> (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in oldanddeprecated (glob)
1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> oldanddeprecated --traceback exited 0 after * seconds (glob)
Yuya Nishihara
revset: stop supporting predicate that returns plain list (API)...
r31809 1970/01/01 00:00:00 bob @cb9a9f314b8b07ba71012fcdbc544b5a4d82ff5b (5000)> blackbox -l 7
Pierre-Yves David
test: extract develwarn transaction testing in its own command...
r29185
Test programming error failure:
Pierre-Yves David
transaction: turn lack of locking into a hard failure (API)...
r29186 $ hg buggytransaction 2>&1 | egrep -v '^ '
** Unknown exception encountered with possibly-broken third-party extension buggylocking
** which supports versions unknown of Mercurial.
** Please disable buggylocking and try your action again.
** If that fixes the bug please report it to the extension author.
** Python * (glob)
** Mercurial Distributed SCM (*) (glob)
** Extensions loaded: * (glob)
Yuya Nishihara
error: add hint to ProgrammingError...
r32340 ** ProgrammingError: transaction requires locking
Pierre-Yves David
transaction: turn lack of locking into a hard failure (API)...
r29186 Traceback (most recent call last):
Jun Wu
localrepo: use ProgrammingError...
r30574 mercurial.error.ProgrammingError: transaction requires locking
Pierre-Yves David
test: extract develwarn transaction testing in its own command...
r29185
Yuya Nishihara
error: add hint to ProgrammingError...
r32340 $ hg programmingerror 2>&1 | egrep -v '^ '
** Unknown exception encountered with possibly-broken third-party extension buggylocking
** which supports versions unknown of Mercurial.
** Please disable buggylocking and try your action again.
** If that fixes the bug please report it to the extension author.
** Python * (glob)
** Mercurial Distributed SCM (*) (glob)
** Extensions loaded: * (glob)
** ProgrammingError: something went wrong
** (try again)
Traceback (most recent call last):
mercurial.error.ProgrammingError: something went wrong
Pierre-Yves David
util: add a way to issue deprecation warning without a UI object...
r31950 Old style deprecation warning
$ hg nouiwarning
$TESTTMP/buggylocking.py:61: DeprecationWarning: this is a test
(compatibility will be dropped after Mercurial-13.37, update your code.)
util.nouideprecwarn('this is a test', '13.37')
(disabled outside of test run)
$ HGEMITWARNINGS= hg nouiwarning
configitems: issue a devel warning when overriding default config...
r32987 Test warning on config option access and registration
$ cat << EOF > ${TESTTMP}/buggyconfig.py
> """A small extension that tests our developer warnings for config"""
>
> from mercurial import registrar
>
> cmdtable = {}
> command = registrar.command(cmdtable)
>
> @command('buggyconfig')
> def cmdbuggyconfig(ui, repo):
> repo.ui.config('ui', 'quiet', False)
> repo.ui.config('ui', 'interactive', None)
> EOF
$ hg --config "extensions.buggyconfig=${TESTTMP}/buggyconfig.py" buggyconfig
devel-warn: specifying a default value for a registered config item: 'ui.quiet' 'False' at: $TESTTMP/buggyconfig.py:* (cmdbuggyconfig) (glob)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 $ cd ..