Mercurial > public > mercurial-scm > hg-stable
diff tests/test-clone.t @ 34885:df2ff314e36f
fsmonitor: warn when fsmonitor could be used
fsmonitor can significantly speed up operations on large working
directories. But fsmonitor isn't enabled by default, so naive users
may not realize there is a potential to make Mercurial faster.
This commit introduces a warning to working directory updates when
fsmonitor could be used.
The following conditions must be met:
* Working directory is previously empty
* New working directory adds >= N files (currently 50,000)
* Running on Linux or MacOS
* fsmonitor not enabled
* Warning not disabled via config override
Because of the empty working directory restriction, most users will
only see this warning during `hg clone` (assuming very few users
actually do an `hg up null`).
The addition of a warning may be considered a BC change. However, clone
has printed warnings before. Until recently, Mercurial printed a warning
with the server's certificate fingerprint when it wasn't explicitly
trusted for example. The warning goes to stderr. So it shouldn't
interfere with scripts parsing meaningful output.
The OS restriction was on the advice of Facebook engineers, who only
feel confident with watchman's stability on the supported platforms.
.. feature::
Print warning when fsmonitor isn't being used on a large repository
Differential Revision: https://phab.mercurial-scm.org/D894
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 18 Oct 2017 22:57:15 +0200 |
parents | 1644623ab096 |
children | 4441705b7111 |
line wrap: on
line diff
--- a/tests/test-clone.t Fri Oct 06 06:48:43 2017 -0700 +++ b/tests/test-clone.t Wed Oct 18 22:57:15 2017 +0200 @@ -1177,3 +1177,80 @@ We should not have created a file named owned - if it exists, the attack succeeded. $ if test -f owned; then echo 'you got owned'; fi + +Cloning without fsmonitor enabled does not print a warning for small repos + + $ hg clone a fsmonitor-default + updating to bookmark @ on branch stable + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Lower the warning threshold to simulate a large repo + + $ cat >> $HGRCPATH << EOF + > [fsmonitor] + > warn_update_file_count = 2 + > EOF + +We should see a warning about no fsmonitor on supported platforms + +#if linuxormacos no-fsmonitor + $ hg clone a nofsmonitor + updating to bookmark @ on branch stable + (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved +#else + $ hg clone a nofsmonitor + updating to bookmark @ on branch stable + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif + +We should not see warning about fsmonitor when it is enabled + +#if fsmonitor + $ hg clone a fsmonitor-enabled + updating to bookmark @ on branch stable + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif + +We can disable the fsmonitor warning + + $ hg --config fsmonitor.warn_when_unused=false clone a fsmonitor-disable-warning + updating to bookmark @ on branch stable + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Loaded fsmonitor but disabled in config should still print warning + +#if linuxormacos fsmonitor + $ hg --config fsmonitor.mode=off clone a fsmonitor-mode-off + updating to bookmark @ on branch stable + (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") (fsmonitor !) + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif + +Warning not printed if working directory isn't empty + + $ hg -q clone a fsmonitor-update + (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") (?) + $ cd fsmonitor-update + $ hg up acb14030fe0a + 1 files updated, 0 files merged, 2 files removed, 0 files unresolved + (leaving bookmark @) + $ hg up cf0fe1914066 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + +`hg update` from null revision also prints + + $ hg up null + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + +#if linuxormacos no-fsmonitor + $ hg up cf0fe1914066 + (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved +#else + $ hg up cf0fe1914066 + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved +#endif + + $ cd .. +