Skip to content

Commit

Permalink
enable hg fsmonitor race detection during hg status
Browse files Browse the repository at this point in the history
Summary:
This diff enables the new fsmonitor config option that
requests strict race detection during `hg status` operations.
When this config is enabled, mercurial will raise an error
if at the end of a status call it detects that the working
copy has been changed in a way that will produce misleading
or bad results rather than being oblivious to them.

This config option is safe to enable even if the mercurial
install doesn't have support for this functionality; it will
be silently ignored.

When the flag is enabled and an issue is detected, the status
call will error out and bubble up an error to the watchman
query executor.  For `query` commands this will yield an `error`
PDU.

For subscriptions it will cause the current batch to error
out, but because mutation happened or is happening, the subscription
result processing is likely to trigger again almomst instantaneously
and emit the correct current results.

We had talked about potentially making the `query` path retry the
call in the error case, but it's not clear that the complexity in
handling the retry is warranted, so let's try this to start.

Reviewed By: quark-zju

Differential Revision: D8848628

fbshipit-source-id: 699646200d299e91c1f558dba861ed0d2bfc4f5a
  • Loading branch information
wez authored and facebook-github-bot committed Jul 14, 2018
1 parent 2e7472b commit ef5a8ff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions scm/Mercurial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ ChildProcess::Options Mercurial::makeHgOptions(w_string requestId) const {
if (requestId && !requestId.empty()) {
opt.environment().set("HGREQUESTID", requestId);
}

// Default to strict hg status. HGDETECTRACE is used by some deployments
// of mercurial to cause `hg status` to error out if it detects mutation
// of the working copy that is happening currently with the status call.
// This has to be opt-in behavior as it changes the semantics of the status
// CLI invocation. Watchman is ready to handle this case in a reasonably
// defined manner, so we are safe to enable it.
if (cfg_get_bool("fsmonitor.detectrace", true)) {
opt.environment().set("HGDETECTRACE", w_string("1"));
}

opt.nullStdin();
opt.pipeStdout();
opt.pipeStderr();
Expand Down

0 comments on commit ef5a8ff

Please sign in to comment.