##// END OF EJS Templates
context: override workingctx.hex() to avoid a crash...
context: override workingctx.hex() to avoid a crash Since node is None for workingctx, it can't use the base class implementation of 'hex(self.node())'. It doesn't appear that there are any current callers of this, but there will be when archive supports 'wdir()'. My first thought was to use "{p1node}+", but that would cause headaches elsewhere [1]. We should probably fix up localrepository.__getitem__ to accept this hash for consistency, as a followup. This works, if the full hash is specified: @@ -480,7 +480,7 @@ return dirstate.dirstate(self.vfs, self.ui, self.root, validate) def __getitem__(self, changeid): - if changeid is None: + if changeid is None or changeid == 'ff' * 20: return context.workingctx(self) if isinstance(changeid, slice): return [context.changectx(self, i) That differs from null, where it will accept any number of 0s, as long as it isn't ambiguous. [1] https://www.selenic.com/pipermail/mercurial-devel/2015-June/071166.html

File last commit:

r25300:678d0bfd default
r25590:183965a0 default
Show More
test-devel-warnings.t
109 lines | 3.3 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
> """A small extension that acquire locks in the wrong order
> """
>
Pierre-Yves David
repair: forbid strip from inside a transaction...
r25300 > from mercurial import cmdutil, repair
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 >
> cmdtable = {}
> command = cmdutil.command(cmdtable)
>
> @command('buggylocking', [], '')
> def buggylocking(ui, repo):
Pierre-Yves David
devel: also warn about transaction started without a lock...
r24388 > tr = repo.transaction('buggy')
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > 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 >
> @command('properlocking', [], '')
> 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 >
> @command('nowaitlocking', [], '')
> 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 >
> @command('stripintr', [], '')
> def stripintr(ui, repo):
> lo = repo.lock()
> tr = repo.transaction('foobar')
> try:
> repair.strip(repo.ui, repo, [repo['.'].node()])
> finally:
> lo.release()
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 > EOF
$ cat << EOF >> $HGRCPATH
> [extensions]
> buggylocking=$TESTTMP/buggylocking.py
> [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
Pierre-Yves David
devel-warn: add a prefix to all messages ("devel-warn: ")...
r24755 devel-warn: transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking)
devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking)
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 $ cat << EOF >> $HGRCPATH
> [devel]
> all=0
> check-locks=1
> EOF
$ hg buggylocking
Pierre-Yves David
devel-warn: add a prefix to all messages ("devel-warn: ")...
r24755 devel-warn: transaction with no lock at: $TESTTMP/buggylocking.py:11 (buggylocking)
devel-warn: "wlock" acquired after "lock" at: $TESTTMP/buggylocking.py:13 (buggylocking)
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: transaction with no lock at:
Matt Mackall
tests: fix py2.4 glob for devel warnings
r24555 */hg:* in * (glob)
Pierre-Yves David
devel: also warn about transaction started without a lock...
r24388 */mercurial/dispatch.py:* in run (glob)
*/mercurial/dispatch.py:* in dispatch (glob)
*/mercurial/dispatch.py:* in _runcatch (glob)
*/mercurial/dispatch.py:* in _dispatch (glob)
*/mercurial/dispatch.py:* in runcommand (glob)
*/mercurial/dispatch.py:* in _runcommand (glob)
*/mercurial/dispatch.py:* in checkargs (glob)
*/mercurial/dispatch.py:* in <lambda> (glob)
*/mercurial/util.py:* in check (glob)
$TESTTMP/buggylocking.py:* in buggylocking (glob)
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)
*/mercurial/dispatch.py:* in _dispatch (glob)
*/mercurial/dispatch.py:* in runcommand (glob)
*/mercurial/dispatch.py:* in _runcommand (glob)
*/mercurial/dispatch.py:* in checkargs (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
$ hg stripintr
saved backup bundle to $TESTTMP/lock-checker/.hg/strip-backup/cb9a9f314b8b-cc5ccb0b-backup.hg (glob)
abort: programming error: cannot strip from inside a transaction
(contact your extension maintainer)
[255]
Pierre-Yves David
devel: move the lock-checking code into core...
r24386 $ cd ..