Single Watchman subscription to support multiple roots
Summary:
{
D8209048} added multiple root support to Watchman. This is because Flow can be configured to watch directories and files outside of the root directory. The approach I took was to subscribe to each included directory/file. It felt like the cleanest abstraction, but there was a downside. Each subscription would push results separately. So after a rebase, we might get a response from each subscription. So I had to add some debouncing to make sure we wait for all subscriptions. This debouncing made Flow a little less responsive to file system changes when using Watchman.
More recently, there are some cool Watchman extensions I'd like to use. However, these are tricky to use with multiple subscriptions.
So this diff introduces a different approach. Instead of sending multiple subscriptions, we have a single subscription. We use expression terms to specify which files and directories we'd like to watch.
For example, if we want to watch `foo/dirA` and `bar/fileB`, we will add to our expressions:
```
["anyof",["dirname","foo/dirA"],["name","foo/dirA"],["dirname","bar/fileB"],["name","bar/fileB"]]
```
which will match any file named `foo/dirA` or `bar/fileB` and will match any file under the directory `foo/dirA` or `bar/dirB`.
This new approach does require that every watched path is under the same watchman watch root. However, we were already arbitrarily asserting that anyway, so there's no loss of expressivity here.
Reviewed By: samwgoldman
Differential Revision:
D9751231
fbshipit-source-id:
687d39a3f27780787a8b5d1b3c71b725ea8f0ff1