From 1b504b8c939859571d60d9eea5388fcb2ddc87b6 Mon Sep 17 00:00:00 2001 From: Joseph Friesen Date: Wed, 15 Jan 2020 13:41:47 -0800 Subject: [PATCH] add TCP support to fsmonitor Summary: This is part of proof-of-concept to test Watchman over TCP, a means to accelerate hg workflows for the ASIC teams within Facebook. For more context, refer to master task T55191832 Reviewed By: xavierd Differential Revision: D18482107 fbshipit-source-id: 08ba3641854d81fe2a1cd8739bb4e9abcbc700ed --- eden/scm/edenscm/hgext/extlib/watchmanclient/__init__.py | 7 +++++++ eden/scm/edenscm/hgext/fsmonitor/__init__.py | 3 +++ eden/scm/tests/test-check-config.t | 3 +++ 3 files changed, 13 insertions(+) diff --git a/eden/scm/edenscm/hgext/extlib/watchmanclient/__init__.py b/eden/scm/edenscm/hgext/extlib/watchmanclient/__init__.py index 4627328164..49447b4881 100644 --- a/eden/scm/edenscm/hgext/extlib/watchmanclient/__init__.py +++ b/eden/scm/edenscm/hgext/extlib/watchmanclient/__init__.py @@ -81,6 +81,11 @@ class client(object): self._sockpath = sockpath repo.ui.debug("watchman sockpath is set as %s\n" % sockpath) + self._transport = None + if repo.ui.configbool("fsmonitor", "tcp", False): + self._transport = "tcp" + self._tcp_host = repo.ui.config("fsmonitor", "tcp-host", "::1") + self._tcp_port = repo.ui.configint("fsmonitor", "tcp-port", 12300) self._timeout = timeout self._watchmanclient = None self._root = repo.root @@ -123,6 +128,8 @@ class client(object): self._firsttime = False self._watchmanclient = pywatchman.client( sockpath=self._sockpath, + transport=self._transport, + tcpAddress=(self._tcp_host, self._tcp_port), timeout=self._timeout, recvEncoding="bser-v1", sendEncoding="bser-v1", diff --git a/eden/scm/edenscm/hgext/fsmonitor/__init__.py b/eden/scm/edenscm/hgext/fsmonitor/__init__.py index 36dba14df8..574351f7ab 100644 --- a/eden/scm/edenscm/hgext/fsmonitor/__init__.py +++ b/eden/scm/edenscm/hgext/fsmonitor/__init__.py @@ -215,6 +215,9 @@ configitem("fsmonitor", "walk_on_invalidate", default=False) configitem("fsmonitor", "watchman-changed-file-threshold", default=200) configitem("fsmonitor", "warn-fresh-instance", default=False) configitem("fsmonitor", "fallback-on-watchman-exception", default=True) +configitem("fsmonitor", "tcp", default=False) +configitem("fsmonitor", "tcp-host", default="::1") +configitem("fsmonitor", "tcp-port", default=12300) # This extension is incompatible with the following blacklisted extensions # and will disable itself when encountering one of these: diff --git a/eden/scm/tests/test-check-config.t b/eden/scm/tests/test-check-config.t index 419839f1c8..4b64674979 100644 --- a/eden/scm/tests/test-check-config.t +++ b/eden/scm/tests/test-check-config.t @@ -60,6 +60,9 @@ New errors are not allowed. Warnings are strongly discouraged. undocumented: fbscmquery.gitcallsigns (list) undocumented: fbscmquery.reponame (str) undocumented: format.usehgsql (bool) + undocumented: fsmonitor.tcp (bool) + undocumented: fsmonitor.tcp-host (str) ["::1"] + undocumented: fsmonitor.tcp-port (int) [12300] undocumented: git.public (list) undocumented: grep.biggrepcorpus (str) undocumented: grep.biggreptier (str) ["biggrep.master"]