testing: add autorefresh/watchman support for --refresh-reviewboard (
bug 1264203) r?gps
Adds a wrapper around |mozreview refresh| which is triggered by watchman.
The wrapper calls refresh with the --refresh-reviewboard parameter if any files
within reviewboard-fork/ are changed.
MozReview-Commit-ID: 62xK8lelyz4
new file mode 100755
--- /dev/null
+++ b/scripts/watchman-refresh-wrapper
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# This script is called by watchman (when using |mozreview autorefresh|).
+# It wraps around |mozreview refresh|, adding --refresh-reviewboard if
+# any files inside the reviewboard-fork/ directory were modified.
+
+import os
+import sys
+
+root = sys.argv[1]
+path = sys.argv[2]
+command = '%s/mozreview' % root
+args = [command, 'refresh', path]
+if os.getenv('WATCHMAN_FILES_OVERFLOW') or any(
+ file.startswith('reviewboard-fork/') for file in sys.argv[3:]):
+ args.append('--refresh-reviewboard')
+os.execv(command, args)
--- a/testing/vcttesting/docker.py
+++ b/testing/vcttesting/docker.py
@@ -1030,17 +1030,18 @@ class Docker(object):
labels=['hgrb'])
if start_hgweb:
f_hgweb_create = e.submit(
self.client.create_container,
hgweb_image,
ports=[80],
entrypoint=['/entrypoint-solo'],
- command=['/usr/bin/supervisord', '-n'])
+ command=['/usr/bin/supervisord', '-n'],
+ labels=['hgweb'])
if start_autoland:
f_autolanddb_create = e.submit(
self.client.create_container,
autolanddb_image,
labels=['autolanddb'])
f_autoland_create = e.submit(
--- a/testing/vcttesting/mozreview.py
+++ b/testing/vcttesting/mozreview.py
@@ -396,26 +396,33 @@ class MozReview(object):
When enabled, this removes overhead from developers having to manually
refresh state during development.
"""
if not WATCHMAN:
raise Exception('watchman binary not found')
subprocess.check_call([WATCHMAN, 'watch-project', ROOT])
name = 'mozreview-%s' % os.path.basename(self._path)
+ expression = [
+ 'anyof',
+ ['dirname', 'hgext/reviewboard'],
+ ['dirname', 'pylib/mozreview'],
+ ['dirname', 'pylib/rbbz'],
+ ['dirname', 'pylib/reviewboardmods'],
+ ['dirname', 'reviewboard-fork/djblets'],
+ ['dirname', 'reviewboard-fork/reviewboard'],
+ ]
+ command = ['%s/scripts/watchman-refresh-wrapper' % ROOT, ROOT,
+ self._path]
data = json.dumps(['trigger', ROOT, {
'name': name,
'chdir': ROOT,
- 'expression': ['anyof',
- ['dirname', 'hgext/reviewboard'],
- ['dirname', 'pylib/mozreview'],
- ['dirname', 'pylib/rbbz'],
- ['dirname', 'reviewboardmods'],
- ],
- 'command': ['%s/mozreview' % ROOT, 'refresh', self._path],
+ 'expression': expression,
+ 'command': command,
+ 'append_files': True,
}])
p = subprocess.Popen([WATCHMAN, '-j'], stdin=subprocess.PIPE)
p.communicate(data)
res = p.wait()
if res != 0:
raise Exception('error creating watchman trigger')
def repo_urls(self, name):