D8225: rust-cpython: add `debug` module to expose debug information to Python

2020-03-11 Thread Raphaël Gomès
Closed by commit rHGd4f19eb471ca: rust-cpython: add `debug` module to expose 
debug information to Python (authored by Alphare).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs 
Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8225?vs=20503=20724

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

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

AFFECTED FILES
  rust/hg-cpython/src/debug.rs
  rust/hg-cpython/src/lib.rs

CHANGE DETAILS

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
@@ -30,6 +30,7 @@
 #[macro_use]
 pub mod ref_sharing;
 pub mod dagops;
+pub mod debug;
 pub mod dirstate;
 pub mod discovery;
 pub mod exceptions;
@@ -47,6 +48,7 @@
 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
 m.add(py, "ancestor", ancestors::init_module(py, _name)?)?;
 m.add(py, "dagop", dagops::init_module(py, _name)?)?;
+m.add(py, "debug", debug::init_module(py, _name)?)?;
 m.add(py, "discovery", discovery::init_module(py, _name)?)?;
 m.add(py, "dirstate", dirstate::init_module(py, _name)?)?;
 m.add(py, "revlog", revlog::init_module(py, _name)?)?;
diff --git a/rust/hg-cpython/src/debug.rs b/rust/hg-cpython/src/debug.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/debug.rs
@@ -0,0 +1,26 @@
+// debug.rs
+//
+// Copyright 2020 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Module to get debug information about Rust extensions.
+use cpython::{PyDict, PyModule, PyResult, Python};
+
+/// Create the module, with `__package__` given from parent
+pub fn init_module(py: Python, package: ) -> PyResult {
+let dotted_name = !("{}.debug", package);
+let m = PyModule::new(py, dotted_name)?;
+
+m.add(py, "__package__", package)?;
+m.add(py, "__doc__", "Rust debugging information")?;
+
+m.add(py, "re2_installed", cfg!(feature = "with-re2"))?;
+
+let sys = PyModule::import(py, "sys")?;
+let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
+sys_modules.set_item(py, dotted_name, )?;
+
+Ok(m)
+}



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8225: rust-cpython: add `debug` module to expose debug information to Python

2020-03-06 Thread Raphaël Gomès
Alphare added a comment.


  Note to reviewers: I will be rebasing this when D8248 
 is merged and adding a version number to 
this debug module, so don't take it yet.

REPOSITORY
  rHG Mercurial

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

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

To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D8225: rust-cpython: add `debug` module to expose debug information to Python

2020-03-05 Thread Raphaël Gomès
Alphare created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This will be mostly used in `debuginstall`.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  rust/hg-cpython/src/debug.rs
  rust/hg-cpython/src/lib.rs

CHANGE DETAILS

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
@@ -30,6 +30,7 @@
 #[macro_use]
 pub mod ref_sharing;
 pub mod dagops;
+pub mod debug;
 pub mod dirstate;
 pub mod discovery;
 pub mod exceptions;
@@ -47,6 +48,7 @@
 let dotted_name: String = m.get(py, "__name__")?.extract(py)?;
 m.add(py, "ancestor", ancestors::init_module(py, _name)?)?;
 m.add(py, "dagop", dagops::init_module(py, _name)?)?;
+m.add(py, "debug", debug::init_module(py, _name)?)?;
 m.add(py, "discovery", discovery::init_module(py, _name)?)?;
 m.add(py, "dirstate", dirstate::init_module(py, _name)?)?;
 m.add(py, "revlog", revlog::init_module(py, _name)?)?;
diff --git a/rust/hg-cpython/src/debug.rs b/rust/hg-cpython/src/debug.rs
new file mode 100644
--- /dev/null
+++ b/rust/hg-cpython/src/debug.rs
@@ -0,0 +1,26 @@
+// debug.rs
+//
+// Copyright 2020 Raphaël Gomès 
+//
+// This software may be used and distributed according to the terms of the
+// GNU General Public License version 2 or any later version.
+
+//! Module to get debug information about Rust extensions.
+use cpython::{PyDict, PyModule, PyResult, Python};
+
+/// Create the module, with `__package__` given from parent
+pub fn init_module(py: Python, package: ) -> PyResult {
+let dotted_name = !("{}.debug", package);
+let m = PyModule::new(py, dotted_name)?;
+
+m.add(py, "__package__", package)?;
+m.add(py, "__doc__", "Rust debugging information")?;
+
+m.add(py, "re2_installed", cfg!(feature = "with-re2"))?;
+
+let sys = PyModule::import(py, "sys")?;
+let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
+sys_modules.set_item(py, dotted_name, )?;
+
+Ok(m)
+}



To: Alphare, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel