Show More
@@ -3,6 +3,7 b' name = "hg-core"' | |||
|
3 | 3 | version = "0.1.0" |
|
4 | 4 | authors = ["Georges Racinet <gracinet@anybox.fr>"] |
|
5 | 5 | description = "Mercurial pure Rust core library, with no assumption on Python bindings (FFI)" |
|
6 | edition = "2018" | |
|
6 | 7 | |
|
7 | 8 | [lib] |
|
8 | 9 | name = "hg" |
|
1 | NO CONTENT: file renamed from rust/hg-core/src/dirstate/mod.rs to rust/hg-core/src/dirstate.rs |
@@ -8,10 +8,9 b'' | |||
|
8 | 8 | //! A multiset of directory names. |
|
9 | 9 | //! |
|
10 | 10 | //! Used to counts the references to directories in a manifest or dirstate. |
|
11 | use crate::{utils::files, DirsIterable, DirstateEntry, DirstateMapError}; | |
|
11 | 12 | use std::collections::hash_map::{Entry, Iter}; |
|
12 | 13 | use std::collections::HashMap; |
|
13 | use {DirsIterable, DirstateEntry, DirstateMapError}; | |
|
14 | use utils::files; | |
|
15 | 14 | |
|
16 | 15 | #[derive(PartialEq, Debug)] |
|
17 | 16 | pub struct DirsMultiset { |
@@ -3,13 +3,13 b'' | |||
|
3 | 3 | // This software may be used and distributed according to the terms of the |
|
4 | 4 | // GNU General Public License version 2 or any later version. |
|
5 | 5 | |
|
6 | use crate::{ | |
|
7 | CopyVec, CopyVecEntry, DirstateEntry, DirstatePackError, DirstateParents, | |
|
8 | DirstateParseError, DirstateVec, | |
|
9 | }; | |
|
6 | 10 | use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; |
|
7 | 11 | use std::collections::HashMap; |
|
8 | 12 | use std::io::Cursor; |
|
9 | use { | |
|
10 | CopyVec, CopyVecEntry, DirstateEntry, DirstatePackError, DirstateParents, | |
|
11 | DirstateParseError, DirstateVec, | |
|
12 | }; | |
|
13 | 13 | |
|
14 | 14 | /// Parents are stored in the dirstate as byte hashes. |
|
15 | 15 | const PARENT_SIZE: usize = 20; |
@@ -1,11 +1,13 b'' | |||
|
1 | use crate::{LineNumber, PatternError, PatternFileError}; | |
|
1 | use crate::{ | |
|
2 | utils::{files::get_path_from_bytes, replace_slice, SliceExt}, | |
|
3 | LineNumber, PatternError, PatternFileError, | |
|
4 | }; | |
|
5 | use lazy_static::lazy_static; | |
|
2 | 6 | use regex::bytes::Regex; |
|
3 | 7 | use std::collections::HashMap; |
|
4 | 8 | use std::fs::File; |
|
5 | 9 | use std::io::Read; |
|
6 | 10 | use std::vec::Vec; |
|
7 | use utils::files::get_path_from_bytes; | |
|
8 | use utils::{replace_slice, SliceExt}; | |
|
9 | 11 | |
|
10 | 12 | lazy_static! { |
|
11 | 13 | static ref RE_ESCAPE: Vec<Vec<u8>> = { |
@@ -2,12 +2,6 b'' | |||
|
2 | 2 | // |
|
3 | 3 | // This software may be used and distributed according to the terms of the |
|
4 | 4 | // GNU General Public License version 2 or any later version. |
|
5 | extern crate byteorder; | |
|
6 | extern crate memchr; | |
|
7 | #[macro_use] | |
|
8 | extern crate lazy_static; | |
|
9 | extern crate regex; | |
|
10 | ||
|
11 | 5 | mod ancestors; |
|
12 | 6 | pub mod dagops; |
|
13 | 7 | pub use ancestors::{AncestorsIterator, LazyAncestors, MissingAncestors}; |
@@ -50,7 +44,7 b' pub trait Graph {' | |||
|
50 | 44 | /// Return the two parents of the given `Revision`. |
|
51 | 45 | /// |
|
52 | 46 | /// Each of the parents can be independently `NULL_REVISION` |
|
53 | fn parents(&self, Revision) -> Result<[Revision; 2], GraphError>; | |
|
47 | fn parents(&self, rev: Revision) -> Result<[Revision; 2], GraphError>; | |
|
54 | 48 | } |
|
55 | 49 | |
|
56 | 50 | pub type LineNumber = usize; |
|
1 | NO CONTENT: file renamed from rust/hg-core/src/utils/mod.rs to rust/hg-core/src/utils.rs |
@@ -1,7 +1,3 b'' | |||
|
1 | extern crate hg; | |
|
2 | extern crate rand; | |
|
3 | extern crate rand_pcg; | |
|
4 | ||
|
5 | 1 |
|
|
6 | 2 | use hg::Revision; |
|
7 | 3 | use hg::*; |
@@ -2,6 +2,7 b'' | |||
|
2 | 2 | name = "hg-cpython" |
|
3 | 3 | version = "0.1.0" |
|
4 | 4 | authors = ["Georges Racinet <gracinet@anybox.fr>"] |
|
5 | edition = "2018" | |
|
5 | 6 | |
|
6 | 7 | [lib] |
|
7 | 8 | name='rusthg' |
@@ -34,13 +34,15 b'' | |||
|
34 | 34 | //! [`LazyAncestors`]: struct.LazyAncestors.html |
|
35 | 35 | //! [`MissingAncestors`]: struct.MissingAncestors.html |
|
36 | 36 | //! [`AncestorsIterator`]: struct.AncestorsIterator.html |
|
37 | use crate::conversion::{py_set, rev_pyiter_collect}; | |
|
38 |
|
|
|
37 | use crate::{ | |
|
38 | cindex::Index, | |
|
39 | conversion::{py_set, rev_pyiter_collect}, | |
|
40 | exceptions::GraphError, | |
|
41 | }; | |
|
39 | 42 | use cpython::{ |
|
40 | 43 | ObjectProtocol, PyClone, PyDict, PyList, PyModule, PyObject, PyResult, |
|
41 | 44 | Python, PythonObject, ToPyObject, |
|
42 | 45 | }; |
|
43 | use exceptions::GraphError; | |
|
44 | 46 | use hg::Revision; |
|
45 | 47 | use hg::{ |
|
46 | 48 | AncestorsIterator as CoreIterator, LazyAncestors as CoreLazy, |
@@ -10,14 +10,14 b'' | |||
|
10 | 10 | //! Ideally, we should use an Index entirely implemented in Rust, |
|
11 | 11 | //! but this will take some time to get there. |
|
12 | 12 | #[cfg(feature = "python27")] |
|
13 |
|
|
|
13 | use python27_sys as python_sys; | |
|
14 | 14 | #[cfg(feature = "python3")] |
|
15 |
|
|
|
15 | use python3_sys as python_sys; | |
|
16 | 16 | |
|
17 | use self::python_sys::PyCapsule_Import; | |
|
18 | 17 | use cpython::{PyClone, PyErr, PyObject, PyResult, Python}; |
|
19 | 18 | use hg::{Graph, GraphError, Revision, WORKING_DIRECTORY_REVISION}; |
|
20 | 19 | use libc::c_int; |
|
20 | use python_sys::PyCapsule_Import; | |
|
21 | 21 | use std::ffi::CStr; |
|
22 | 22 | use std::mem::transmute; |
|
23 | 23 |
@@ -9,10 +9,12 b'' | |||
|
9 | 9 | //! `hg-core` package. |
|
10 | 10 | //! |
|
11 | 11 | //! From Python, this will be seen as `mercurial.rustext.dagop` |
|
12 | use crate::conversion::{py_set, rev_pyiter_collect}; | |
|
13 |
|
|
|
12 | use crate::{ | |
|
13 | cindex::Index, | |
|
14 | conversion::{py_set, rev_pyiter_collect}, | |
|
15 | exceptions::GraphError, | |
|
16 | }; | |
|
14 | 17 | use cpython::{PyDict, PyModule, PyObject, PyResult, Python}; |
|
15 | use exceptions::GraphError; | |
|
16 | 18 | use hg::dagops; |
|
17 | 19 | use hg::Revision; |
|
18 | 20 | use std::collections::HashSet; |
@@ -19,17 +19,14 b' use hg::{' | |||
|
19 | 19 | DirstateEntry, DirstateMapError, DirstatePackError, DirstateParents, |
|
20 | 20 | DirstateParseError, DirstateVec, |
|
21 | 21 | }; |
|
22 | use libc::{c_char, c_int}; | |
|
23 | #[cfg(feature = "python27")] | |
|
24 | use python27_sys::PyCapsule_Import; | |
|
25 | #[cfg(feature = "python3")] | |
|
26 | use python3_sys::PyCapsule_Import; | |
|
27 | use std::cell::RefCell; | |
|
22 | 28 | use std::collections::HashMap; |
|
23 | 29 | use std::ffi::CStr; |
|
24 | ||
|
25 | #[cfg(feature = "python27")] | |
|
26 | extern crate python27_sys as python_sys; | |
|
27 | #[cfg(feature = "python3")] | |
|
28 | extern crate python3_sys as python_sys; | |
|
29 | ||
|
30 | use self::python_sys::PyCapsule_Import; | |
|
31 | use libc::{c_char, c_int}; | |
|
32 | use std::cell::RefCell; | |
|
33 | 30 | use std::mem::transmute; |
|
34 | 31 | |
|
35 | 32 | /// C code uses a custom `dirstate_tuple` type, checks in multiple instances |
@@ -12,13 +12,15 b'' | |||
|
12 | 12 | //! - [`PartialDiscover`] is the Rust implementation of |
|
13 | 13 | //! `mercurial.setdiscovery.partialdiscovery`. |
|
14 | 14 | |
|
15 | use crate::conversion::{py_set, rev_pyiter_collect}; | |
|
16 |
|
|
|
15 | use crate::{ | |
|
16 | cindex::Index, | |
|
17 | conversion::{py_set, rev_pyiter_collect}, | |
|
18 | exceptions::GraphError, | |
|
19 | }; | |
|
17 | 20 | use cpython::{ |
|
18 | 21 | ObjectProtocol, PyDict, PyModule, PyObject, PyResult, Python, |
|
19 | 22 | PythonObject, ToPyObject, |
|
20 | 23 | }; |
|
21 | use exceptions::GraphError; | |
|
22 | 24 | use hg::discovery::PartialDiscovery as CorePartialDiscovery; |
|
23 | 25 | use hg::Revision; |
|
24 | 26 |
@@ -12,8 +12,10 b'' | |||
|
12 | 12 | //! existing Python exceptions if appropriate. |
|
13 | 13 | //! |
|
14 | 14 | //! [`GraphError`]: struct.GraphError.html |
|
15 | use cpython::exc::{RuntimeError, ValueError}; | |
|
16 | use cpython::{exc, PyErr, Python}; | |
|
15 | use cpython::{ | |
|
16 | exc::{IOError, RuntimeError, ValueError}, | |
|
17 | py_exception, PyErr, Python, | |
|
18 | }; | |
|
17 | 19 | use hg; |
|
18 | 20 | |
|
19 | 21 | py_exception!(rustext, GraphError, ValueError); |
@@ -55,7 +57,7 b' impl PatternFileError {' | |||
|
55 | 57 | match inner { |
|
56 | 58 | hg::PatternFileError::IO(e) => { |
|
57 | 59 | let value = (e.raw_os_error().unwrap_or(2), e.to_string()); |
|
58 |
PyErr::new::< |
|
|
60 | PyErr::new::<IOError, _>(py, value) | |
|
59 | 61 | } |
|
60 | 62 | hg::PatternFileError::Pattern(e, l) => match e { |
|
61 | 63 | hg::PatternError::UnsupportedSyntax(m) => { |
@@ -10,10 +10,10 b'' | |||
|
10 | 10 | //! `hg-core` crate. From Python, this will be seen as `rustext.filepatterns` |
|
11 | 11 | //! and can be used as replacement for the the pure `filepatterns` Python module. |
|
12 | 12 | //! |
|
13 | use crate::exceptions::{PatternError, PatternFileError}; | |
|
13 | 14 | use cpython::{ |
|
14 | 15 | PyBytes, PyDict, PyModule, PyObject, PyResult, PyTuple, Python, ToPyObject, |
|
15 | 16 | }; |
|
16 | use exceptions::{PatternError, PatternFileError}; | |
|
17 | 17 | use hg::{build_single_regex, read_pattern_file, LineNumber, PatternTuple}; |
|
18 | 18 | |
|
19 | 19 | /// Rust does not like functions with different return signatures. |
@@ -19,10 +19,10 b'' | |||
|
19 | 19 | //! 'Generic DAG ancestor algorithms - Rust implementation' |
|
20 | 20 | //! ``` |
|
21 | 21 | |
|
22 | /// This crate uses nested private macros, `extern crate` is still needed in | |
|
23 | /// 2018 edition. | |
|
22 | 24 | #[macro_use] |
|
23 | 25 | extern crate cpython; |
|
24 | extern crate hg; | |
|
25 | extern crate libc; | |
|
26 | 26 | |
|
27 | 27 | pub mod ancestors; |
|
28 | 28 | mod cindex; |
General Comments 0
You need to be logged in to leave comments.
Login now