mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 01:39:21 +03:00
4c9d79b852
Summary: Add a config option `fsmonitor.detectrace` and environment variable `HGDETECTRACE`. Once set, perform an additional query to check if there are writes to the working copy while `wctx._buildstatus()` is being calculated. Also enable the race detector for all fsmonitor tests. Reviewed By: wez Differential Revision: D8597957 fbshipit-source-id: 5d83d529641325dc8d5e72ad059eed8db27d1f2a
50 lines
1.0 KiB
Perl
50 lines
1.0 KiB
Perl
#require fsmonitor
|
|
|
|
$ setconfig fsmonitor.detectrace=1
|
|
$ newrepo
|
|
|
|
No races for common operations
|
|
|
|
$ touch x
|
|
$ hg status
|
|
? x
|
|
|
|
$ rm x
|
|
$ touch y
|
|
$ hg status
|
|
? y
|
|
|
|
Create a race by write files by writing files if context._dirstatestatus is called
|
|
|
|
$ mkdir c
|
|
$ touch e f g
|
|
$ cat > $TESTTMP/racy.py << EOF
|
|
> from mercurial import context, extensions
|
|
> def _race(orig, *args, **kwargs):
|
|
> open('a', 'w').close()
|
|
> open('f', 'w').close()
|
|
> open('c/d.txt', 'w').close()
|
|
> return orig(*args, **kwargs)
|
|
> def uisetup(ui):
|
|
> extensions.wrapfunction(context.workingctx, "_dirstatestatus", _race)
|
|
> EOF
|
|
|
|
$ hg status --config extensions.racy=$TESTTMP/racy.py
|
|
abort: [race-detector] files changed when scanning changes in working copy:
|
|
a
|
|
c/d.txt
|
|
f
|
|
|
|
(this is an error because HGDETECTRACE or fsmonitor.detectrace is set to true)
|
|
[75]
|
|
|
|
Race detector can be turned off:
|
|
|
|
$ hg status --config extensions.racy=$TESTTMP/racy.py --config fsmonitor.detectrace=0
|
|
? a
|
|
? c/d.txt
|
|
? e
|
|
? f
|
|
? g
|
|
? y
|