Page MenuHomePhabricator

rust-discovery: cpython bindings for the core logic

Authored by gracinet on Apr 12 2019, 2:33 PM.



As previously done with the ancestors submodule, testing for
the bindings is provided from Python on a trivial case.

Diff Detail

rHG Mercurial
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

gracinet created this revision.Apr 12 2019, 2:33 PM
kevincox accepted this revision.Apr 14 2019, 4:11 PM
gracinet added inline comments.Apr 15 2019, 12:06 PM

This is also exactly the same binary data I'm using in I'd prefer to mutualize them, but I'm not sure what the preferred pattern would be:

  • binary file sitting next to the test module:
with open(os.path.join(os.path.dirname(__file__), 'index_data.bin', 'rb')) as indexf):
  • helper module next to the test module:
from .index_data import non_inlined
  • or even

    ` from .index_data import parseindex `

what would be the more inline with common practices within the Mercurial project ?

yuja added a subscriber: yuja.Apr 18 2019, 7:22 PM

+ def addinfo(&self, sample: PyObject) -> PyResult<PyObject> {
+ let mut missing: Vec<Revision> = Vec::new();
+ let mut common: Vec<Revision> = Vec::new();
+ for info in sample.iter(py)? { // info is a pair (Revision, bool)
+ let mut revknown = info?.iter(py)?;
+ let rev: Revision =;
+ let known: bool =;

Just to confirm. Can we be sure that this unwrap() never fails? I mean if
we passed in an empty tuple for example, what would happen?

This revision was automatically updated to reflect the committed changes.