Skip to content

Commit

Permalink
watchman-make: avoid dispatching for state-enter changes
Browse files Browse the repository at this point in the history
Summary:
state-enter and state-leave will wake up subscriptions and
deliver a response that has no files listed.   These events are
triggered in the FB source control deployment when mercurial
transactions are initiated and completed, so these occur around
eg: `commit` and `amend`, and then shortly afterwards when our
background `commit cloud` sync process kicks in.

`watchman-make` was blindly assuming that any wakeup from the
subscription channel was worth running the associated command,
which wasn't true in this situation.

In addition to state enter/leave, watch cancellations can also
deliver a response with an empty file list.  Rather than trying
to continue, let's terminate the process if that happens.

Reviewed By: xixixao

Differential Revision: D19222234

fbshipit-source-id: 06d7ddd9d061f7a21b93b8e4d1d79d3636e9998d
  • Loading branch information
wez authored and facebook-github-bot committed Dec 26, 2019
1 parent f4a4d7a commit 79f4b32
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion python/bin/watchman-make
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ class Target(object):
data = client.getSubscription(self.name)
if data is None:
return
self.triggered = True
for item in data:
# We only want to trigger if files matched;
# updates without a files list are metadata
# such as state-enter/leave notices so we skip them
if "files" in item:
self.triggered = True
if "canceled" in item:
raise RuntimeError("Watch was cancelled")

def execute(self):
if not self.triggered:
Expand Down

0 comments on commit 79f4b32

Please sign in to comment.