From patchwork Wed Jul 24 09:33:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D6682: fsmonitor: add support for extra `hg debuginstall` data From: phabricator X-Patchwork-Id: 41038 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 24 Jul 2019 09:33:09 +0000 Closed by commit rHG3358dc6e7c04: fsmonitor: add support for extra `hg debuginstall` data (authored by durin42). This revision was automatically updated to reflect the committed changes. CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D6682?vs=16024&id=16035#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D6682?vs=16024&id=16035 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D6682/new/ REVISION DETAIL https://phab.mercurial-scm.org/D6682 AFFECTED FILES hgext/fsmonitor/__init__.py tests/test-install.t CHANGE DETAILS To: durin42, #hg-reviewers, pulkit Cc: pulkit, mjpieters, mercurial-devel diff --git a/tests/test-install.t b/tests/test-install.t --- a/tests/test-install.t +++ b/tests/test-install.t @@ -153,6 +153,16 @@ 1 problems detected, please check your install! [1] +debuginstall extension support + $ hg debuginstall --config extensions.fsmonitor= --config fsmonitor.watchman_exe=false | grep atchman + fsmonitor checking for watchman binary... (false) + watchman binary missing or broken: warning: Watchman unavailable: watchman exited with code 1 +Verify the json works too: + $ hg debuginstall --config extensions.fsmonitor= --config fsmonitor.watchman_exe=false -Tjson | grep atchman + "fsmonitor-watchman": "false", + "fsmonitor-watchman-error": "warning: Watchman unavailable: watchman exited with code 1", + + #if test-repo $ . "$TESTDIR/helpers-testrepo.sh" diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -112,6 +112,7 @@ import os import stat import sys +import tempfile import weakref from mercurial.i18n import _ @@ -175,6 +176,23 @@ # and will disable itself when encountering one of these: _blacklist = ['largefiles', 'eol'] +def debuginstall(ui, fm): + fm.write("fsmonitor-watchman", + _("fsmonitor checking for watchman binary... (%s)\n"), + ui.configpath("fsmonitor", "watchman_exe")) + root = tempfile.mkdtemp() + c = watchmanclient.client(ui, root) + err = None + try: + v = c.command("version") + fm.write("fsmonitor-watchman-version", + _(" watchman binary version %s\n"), v["version"]) + except watchmanclient.Unavailable as e: + err = str(e) + fm.condwrite(err, "fsmonitor-watchman-error", + _(" watchman binary missing or broken: %s\n"), err) + return 1 if err else 0 + def _handleunavailable(ui, state, ex): """Exception handler for Watchman interaction exceptions""" if isinstance(ex, watchmanclient.Unavailable):