This is an archive of the discontinued Mercurial Phabricator instance.

rust-discovery: cpython bindings for the core logic
ClosedPublic

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

Details

Summary

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

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

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
tests/test-rust-discovery.py
39

This is also exactly the same binary data I'm using in test-rust-ancestors.py. 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 = revknown.next().unwrap()?.extract(py)?;
+ let known: bool = revknown.next().unwrap()?.extract(py)?;

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.