mirror of
https://github.com/facebook/sapling.git
synced 2024-12-26 22:47:26 +03:00
beb3d8c692
Summary: This makes it so `hg status A` won't complain about race conditions about file `B`. As we're here, the detector logic was also moved to the filesystem layer. Reviewed By: DurhamG Differential Revision: D20568151 fbshipit-source-id: 713e3775a14674fd170df391977d42d9dee0f718
69 lines
1.6 KiB
Perl
69 lines
1.6 KiB
Perl
#require py2
|
|
#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
|
|
|
|
$ echo 'f' > .gitignore
|
|
$ mkdir c
|
|
$ touch e f g
|
|
$ cat > $TESTTMP/racy.py << EOF
|
|
> from edenscm.hgext import fsmonitor
|
|
> from edenscm.mercurial import 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(fsmonitor, "_walk", _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
|
|
|
|
(this is an error because HGDETECTRACE or fsmonitor.detectrace is set to true)
|
|
[75]
|
|
|
|
The race detector does not check files outside specified patterns:
|
|
|
|
$ hg status --config extensions.racy=$TESTTMP/racy.py y
|
|
? y
|
|
|
|
$ hg status --config extensions.racy=$TESTTMP/racy.py y a
|
|
abort: [race-detector] files changed when scanning changes in working copy:
|
|
a
|
|
|
|
(this is an error because HGDETECTRACE or fsmonitor.detectrace is set to true)
|
|
[75]
|
|
|
|
Ignored files do not use fsmonitor. So race detector does not detect it:
|
|
|
|
$ hg status -i --config extensions.racy=$TESTTMP/racy.py
|
|
I f
|
|
|
|
Race detector can be turned off:
|
|
|
|
$ hg status --config extensions.racy=$TESTTMP/racy.py --config fsmonitor.detectrace=0
|
|
? .gitignore
|
|
? a
|
|
? c/d.txt
|
|
? e
|
|
? g
|
|
? y
|