Patchwork D8248: debuginstall: print if Rust extensions are installed

login
register
mail settings
Submitter phabricator
Date March 6, 2020, 1:46 p.m.
Message ID <differential-rev-PHID-DREV-fb7e2dop5l75hsohdx6z-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/45549/
State Superseded
Headers show

Comments

phabricator - March 6, 2020, 1:46 p.m.
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This should make it easier to use the Rust extensions.
  
  Another patch on will be exposing a version and more useful information, but
  it can only be done on top of this very patch, since it is targeting the stable
  branch and the API has already changed on the default branch.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/debugcommands.py
  rust/hg-cpython/src/lib.rs

CHANGE DETAILS




To: Alphare, #hg-reviewers
Cc: mercurial-devel
phabricator - March 9, 2020, 9:46 a.m.
pulkit added a comment.


  Amended the following to make `test-check-module-imports.t` happy.
  
    diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
    --- a/mercurial/debugcommands.py
    +++ b/mercurial/debugcommands.py
    @@ -1509,7 +1509,7 @@ def debuginstall(ui, **opts):
         )
     
         try:
    -        from mercurial import rustext
    +        from . import rustext
             rustext.__doc__  # trigger lazy import
         except ImportError:
             rustext = None

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

To: Alphare, #hg-reviewers, pulkit
Cc: mercurial-devel
phabricator - March 9, 2020, 9:54 a.m.
pulkit added a comment.


  and the following too to make `test-check-format.t` happy.
  
    diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
    --- a/mercurial/debugcommands.py
    +++ b/mercurial/debugcommands.py
    @@ -1510,6 +1510,7 @@ def debuginstall(ui, **opts):
     
         try:
             from . import rustext
    +
             rustext.__doc__  # trigger lazy import
         except ImportError:
             rustext = None
    @@ -1542,8 +1543,10 @@ def debuginstall(ui, **opts):
             )
     
         fm.plain(
    -        _(b"checking Rust extensions (%s)\n" % (b'missing'
    -          if rustext is None else b'installed')),
    +        _(
    +            b"checking Rust extensions (%s)\n"
    +            % (b'missing' if rustext is None else b'installed')
    +        ),
         )
     
         # TODO print CA cert info

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

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

To: Alphare, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/rust/hg-cpython/src/lib.rs b/rust/hg-cpython/src/lib.rs
--- a/rust/hg-cpython/src/lib.rs
+++ b/rust/hg-cpython/src/lib.rs
@@ -72,6 +72,12 @@ 
         "PatternError",
         py.get_type::<exceptions::PatternError>(),
     )?;
+    /// Change this version whenever the API is changed
+    m.add(
+        py,
+        "version",
+        0,
+    )?;
     Ok(())
 });
 
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1497,6 +1497,18 @@ 
         pythonlib or _(b"unknown"),
     )
 
+    try:
+        from mercurial import rustext
+        rustext.__doc__  # trigger lazy import
+    except ImportError:
+        rustext = None
+
+    fm.write(
+        b'',
+        _(b"checking Rust extensions (%s)\n"),
+        b'missing' if rustext is None else 'installed',
+    )
+
     security = set(sslutil.supportedprotocols)
     if sslutil.hassni:
         security.add(b'sni')