Patchwork D6682: fsmonitor: add support for extra `hg debuginstall` data

login
register
mail settings
Submitter phabricator
Date July 23, 2019, 7:40 p.m.
Message ID <differential-rev-PHID-DREV-f5muxpavd6t7wbdqfojx-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41027/
State Superseded
Headers show

Comments

phabricator - July 23, 2019, 7:40 p.m.
durin42 created this revision.
Herald added subscribers: mercurial-devel, mjpieters.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This might make some things easier to debug, and for default bug
  report templates it'll help collect more data from users all at
  once. I don't actually need fsmonitor in our bug reports (we don't use
  it), but this demonstrates the utility of the preceding patches
  without having to add new things to core.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6682

AFFECTED FILES
  hgext/fsmonitor/__init__.py
  tests/test-install.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mjpieters, mercurial-devel
phabricator - July 24, 2019, 9:22 a.m.
This revision is now accepted and ready to land.
pulkit added inline comments.
pulkit accepted this revision.

INLINE COMMENTS

> __init__.py:182
> +               ui.configpath("fsmonitor", "watchman_exe"))
> +    import tempfile
> +    root = tempfile.mkdtemp()

Moved this import to top level in flight.

> __init__.py:191
> +    except watchmanclient.Unavailable as e:
> +        err = str(e)
> +    fm.condwrite(err, "fsmonitor-watchman-error",

This might make py3 unhappy.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6682/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D6682

To: durin42, #hg-reviewers, pulkit
Cc: pulkit, mjpieters, mercurial-devel

Patch

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
@@ -175,6 +175,24 @@ 
 # 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"))
+    import tempfile
+    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):