rust/hg-cpython/src/dirstate.rs
author Simon Sapin <simon.sapin@octobus.net>
Fri, 17 Sep 2021 13:33:45 +0200
changeset 48022 f2a9db29cb2d
parent 48021 627cd8f33db0
child 48025 631f6b445a77
permissions -rw-r--r--
rust: Make the fields of DirstateEntry private This is a first step toward making its internal structure equivalent to Python’s DirstateItem. Differential Revision: https://phab.mercurial-scm.org/D11461
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     1
// dirstate.rs
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     2
//
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     3
// Copyright 2019 Raphaël Gomès <rgomes@octobus.net>
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     4
//
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     5
// This software may be used and distributed according to the terms of the
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     6
// GNU General Public License version 2 or any later version.
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     7
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     8
//! Bindings for the `hg::dirstate` module provided by the
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
     9
//! `hg-core` package.
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    10
//!
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    11
//! From Python, this will be seen as `mercurial.rustext.dirstate`
42754
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents: 42749
diff changeset
    12
mod copymap;
42746
b3518b0baa47 rust-dirstate: create dirstate submodule in hg-cpython
Raphaël Gomès <rgomes@octobus.net>
parents: 42609
diff changeset
    13
mod dirs_multiset;
42754
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents: 42749
diff changeset
    14
mod dirstate_map;
44297
cf1f8660e568 rust-dirstatemap: add `NonNormalEntries` class
Raphaël Gomès <rgomes@octobus.net>
parents: 43916
diff changeset
    15
mod non_normal_entries;
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
    16
mod status;
44529
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    17
use crate::{
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    18
    dirstate::{
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    19
        dirs_multiset::Dirs, dirstate_map::DirstateMap, status::status_wrapper,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    20
    },
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    21
    exceptions,
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
    22
};
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    23
use cpython::{
48021
627cd8f33db0 rust: Remove support for passing a dict to the Rust pathutil.dirs()
Simon Sapin <simon.sapin@octobus.net>
parents: 47954
diff changeset
    24
    PyBytes, PyDict, PyErr, PyList, PyModule, PyObject, PyResult, Python,
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    25
};
47280
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47123
diff changeset
    26
use hg::dirstate_tree::on_disk::V2_FORMAT_MARKER;
48021
627cd8f33db0 rust: Remove support for passing a dict to the Rust pathutil.dirs()
Simon Sapin <simon.sapin@octobus.net>
parents: 47954
diff changeset
    27
use hg::DirstateEntry;
42609
326fdce22fb2 rust: switch hg-core and hg-cpython to rust 2018 edition
Raphaël Gomès <rgomes@octobus.net>
parents: 42558
diff changeset
    28
use libc::{c_char, c_int};
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    29
43211
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    30
// C code uses a custom `dirstate_tuple` type, checks in multiple instances
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    31
// for this type, and raises a Python `Exception` if the check does not pass.
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    32
// Because this type differs only in name from the regular Python tuple, it
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    33
// would be a good idea in the near future to remove it entirely to allow
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    34
// for a pure Python tuple of the same effective structure to be used,
88a9930e92e4 rust-cpython: turn inline comments into non-doc comments
Yuya Nishihara <yuya@tcha.org>
parents: 43210
diff changeset
    35
// rendering this type and the capsule below useless.
43213
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    36
py_capsule_fn!(
47539
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47280
diff changeset
    37
    from mercurial.cext.parsers import make_dirstate_item_CAPI
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47280
diff changeset
    38
        as make_dirstate_item_capi
43213
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    39
        signature (
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    40
            state: c_char,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    41
            mode: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    42
            size: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    43
            mtime: c_int,
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    44
        ) -> *mut RawPyObject
0246bbe1045d rust-cpython: leverage upstreamed py_capsule_fn!() macro
Yuya Nishihara <yuya@tcha.org>
parents: 43211
diff changeset
    45
);
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    46
47539
84391ddf4c78 dirstate-item: rename the class to DirstateItem
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47280
diff changeset
    47
pub fn make_dirstate_item(
43208
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    48
    py: Python,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    49
    entry: &DirstateEntry,
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    50
) -> PyResult<PyObject> {
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    51
    // Explicitly go through u8 first, then cast to platform-specific `c_char`
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    52
    // because Into<u8> has a specific implementation while `as c_char` would
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    53
    // just do a naive enum cast.
48022
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    54
    let state_code: u8 = entry.state().into();
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    55
    make_dirstate_item_raw(
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    56
        py,
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    57
        state_code,
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    58
        entry.mode(),
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    59
        entry.size(),
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    60
        entry.mtime(),
f2a9db29cb2d rust: Make the fields of DirstateEntry private
Simon Sapin <simon.sapin@octobus.net>
parents: 48021
diff changeset
    61
    )
43208
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    62
}
1ca3823aeefd rust-cpython: add wrapper around decapsule_make_dirstate_tuple()
Yuya Nishihara <yuya@tcha.org>
parents: 42957
diff changeset
    63
47683
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    64
pub fn make_dirstate_item_raw(
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    65
    py: Python,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    66
    state: u8,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    67
    mode: i32,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    68
    size: i32,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    69
    mtime: i32,
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    70
) -> PyResult<PyObject> {
47567
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    71
    let make = make_dirstate_item_capi::retrieve(py)?;
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    72
    let maybe_obj = unsafe {
47683
284a20269a97 dirstate-v2: Separate iterators for dirfoldmap and debugdirstate
Simon Sapin <simon.sapin@octobus.net>
parents: 47567
diff changeset
    73
        let ptr = make(state as c_char, mode, size, mtime);
47567
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    74
        PyObject::from_owned_ptr_opt(py, ptr)
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    75
    };
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    76
    maybe_obj.ok_or_else(|| PyErr::fetch(py))
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    77
}
7a15dea6d303 dirstate-item: also build DistateItem in dirstate.directories()
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 47539
diff changeset
    78
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    79
/// Create the module, with `__package__` given from parent
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    80
pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> {
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    81
    let dotted_name = &format!("{}.dirstate", package);
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    82
    let m = PyModule::new(py, dotted_name)?;
42537
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents: 42408
diff changeset
    83
45517
2a68a5ec8dd0 rust-cpython: switch logging facade from `simple_logger` to `env_logger`
Raphaël Gomès <rgomes@octobus.net>
parents: 44839
diff changeset
    84
    env_logger::init();
44540
82f51ab7a2dd rust: add logging utils
Raphaël Gomès <rgomes@octobus.net>
parents: 44529
diff changeset
    85
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    86
    m.add(py, "__package__", package)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    87
    m.add(py, "__doc__", "Dirstate - Rust implementation")?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
    88
44529
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    89
    m.add(
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    90
        py,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    91
        "FallbackError",
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    92
        py.get_type::<exceptions::FallbackError>(),
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
    93
    )?;
42537
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents: 42408
diff changeset
    94
    m.add_class::<Dirs>(py)?;
42754
4e8f504424f3 rust-dirstate: rust-cpython bridge for dirstatemap
Raphaël Gomès <rgomes@octobus.net>
parents: 42749
diff changeset
    95
    m.add_class::<DirstateMap>(py)?;
47280
1766130fe9ba dirstate-v2: Change the on-disk format when the requirement is enabled
Simon Sapin <simon.sapin@octobus.net>
parents: 47123
diff changeset
    96
    m.add(py, "V2_FORMAT_MARKER", PyBytes::new(py, V2_FORMAT_MARKER))?;
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
    97
    m.add(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
    98
        py,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
    99
        "status",
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   100
        py_fn!(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   101
            py,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   102
            status_wrapper(
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   103
                dmap: DirstateMap,
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   104
                root_dir: PyObject,
43916
6a88ced33c40 rust-dirstate-status: update bridge for new rust version of `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43456
diff changeset
   105
                matcher: PyObject,
44529
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
   106
                ignorefiles: PyList,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
   107
                check_exec: bool,
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   108
                last_normal_time: i64,
44529
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
   109
                list_clean: bool,
f96b28aa4b79 rust-status: update rust-cpython bridge to account for the changes in core
Raphaël Gomès <rgomes@octobus.net>
parents: 44297
diff changeset
   110
                list_ignored: bool,
44839
01afda7e7d6c rust-hg-cpython: update status bridge with the new `traversedir` support
Raphaël Gomès <rgomes@octobus.net>
parents: 44540
diff changeset
   111
                list_unknown: bool,
01afda7e7d6c rust-hg-cpython: update status bridge with the new `traversedir` support
Raphaël Gomès <rgomes@octobus.net>
parents: 44540
diff changeset
   112
                collect_traversed_dirs: bool
43273
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   113
            )
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   114
        ),
478d0b1bf0c5 rust-dirstate-status: rust-cpython bindings for `dirstate.status`
Raphaël Gomès <rgomes@octobus.net>
parents: 43213
diff changeset
   115
    )?;
42537
ce94f9622acd rust-dirstate: add "dirs" rust-cpython binding
Raphaël Gomès <rgomes@octobus.net>
parents: 42408
diff changeset
   116
42303
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   117
    let sys = PyModule::import(py, "sys")?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   118
    let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   119
    sys_modules.set_item(py, dotted_name, &m)?;
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   120
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   121
    Ok(m)
e240bec26626 rust-dirstate: add rust-cpython bindings to the new parse/pack functions
Raphaël Gomès <rgomes@octobus.net>
parents:
diff changeset
   122
}