rs-parsepatch 0.4.4__tar.gz → 0.4.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/Cargo.lock +16 -54
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/Cargo.toml +2 -2
- rs_parsepatch-0.4.5/PKG-INFO +4 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/pyproject.toml +2 -1
- rs_parsepatch-0.4.5/requirements-dev.txt +3 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/common.rs +16 -16
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/counts.rs +6 -6
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/diffs.rs +20 -18
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/init.rs +6 -6
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/lines.rs +6 -6
- rs_parsepatch-0.4.4/PKG-INFO +0 -39
- rs_parsepatch-0.4.4/requirements-dev.txt +0 -3
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/README.md +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/src/lib.rs +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/__init__.py +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/77ec8a41ee73.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/7dabae5e261a.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/7e60ad275b73.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/81d3e4a2f3f3.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/b184c87f7606.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/c4c0ad8b3eaa.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/c58e9e70f971.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/c6f9187b0b2e.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/d4f80c4ba719.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/d7a700707ddb.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/f045ac9f76cf.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/patches/no_git_header.patch +0 -0
- {rs_parsepatch-0.4.4 → rs_parsepatch-0.4.5}/tests/test_parsepatch.py +0 -0
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
# This file is automatically @generated by Cargo.
|
|
2
2
|
# It is not intended for manual editing.
|
|
3
|
-
version =
|
|
4
|
-
|
|
5
|
-
[[package]]
|
|
6
|
-
name = "autocfg"
|
|
7
|
-
version = "1.4.0"
|
|
8
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
-
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
|
10
|
-
|
|
11
|
-
[[package]]
|
|
12
|
-
name = "cfg-if"
|
|
13
|
-
version = "1.0.0"
|
|
14
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
-
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
3
|
+
version = 4
|
|
16
4
|
|
|
17
5
|
[[package]]
|
|
18
6
|
name = "heck"
|
|
@@ -20,12 +8,6 @@ version = "0.5.0"
|
|
|
20
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
9
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
|
22
10
|
|
|
23
|
-
[[package]]
|
|
24
|
-
name = "indoc"
|
|
25
|
-
version = "2.0.5"
|
|
26
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
-
checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
|
|
28
|
-
|
|
29
11
|
[[package]]
|
|
30
12
|
name = "libc"
|
|
31
13
|
version = "0.2.159"
|
|
@@ -38,20 +20,11 @@ version = "0.4.22"
|
|
|
38
20
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
39
21
|
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
|
40
22
|
|
|
41
|
-
[[package]]
|
|
42
|
-
name = "memoffset"
|
|
43
|
-
version = "0.9.1"
|
|
44
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
45
|
-
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
46
|
-
dependencies = [
|
|
47
|
-
"autocfg",
|
|
48
|
-
]
|
|
49
|
-
|
|
50
23
|
[[package]]
|
|
51
24
|
name = "once_cell"
|
|
52
|
-
version = "1.
|
|
25
|
+
version = "1.21.3"
|
|
53
26
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
54
|
-
checksum = "
|
|
27
|
+
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|
55
28
|
|
|
56
29
|
[[package]]
|
|
57
30
|
name = "parsepatch"
|
|
@@ -79,37 +52,32 @@ dependencies = [
|
|
|
79
52
|
|
|
80
53
|
[[package]]
|
|
81
54
|
name = "pyo3"
|
|
82
|
-
version = "0.
|
|
55
|
+
version = "0.28.1"
|
|
83
56
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
84
|
-
checksum = "
|
|
57
|
+
checksum = "14c738662e2181be11cb82487628404254902bb3225d8e9e99c31f3ef82a405c"
|
|
85
58
|
dependencies = [
|
|
86
|
-
"cfg-if",
|
|
87
|
-
"indoc",
|
|
88
59
|
"libc",
|
|
89
|
-
"memoffset",
|
|
90
60
|
"once_cell",
|
|
91
61
|
"portable-atomic",
|
|
92
62
|
"pyo3-build-config",
|
|
93
63
|
"pyo3-ffi",
|
|
94
64
|
"pyo3-macros",
|
|
95
|
-
"unindent",
|
|
96
65
|
]
|
|
97
66
|
|
|
98
67
|
[[package]]
|
|
99
68
|
name = "pyo3-build-config"
|
|
100
|
-
version = "0.
|
|
69
|
+
version = "0.28.1"
|
|
101
70
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
-
checksum = "
|
|
71
|
+
checksum = "f9ca0864a7dd3c133a7f3f020cbff2e12e88420da854c35540fd20ce2d60e435"
|
|
103
72
|
dependencies = [
|
|
104
|
-
"once_cell",
|
|
105
73
|
"target-lexicon",
|
|
106
74
|
]
|
|
107
75
|
|
|
108
76
|
[[package]]
|
|
109
77
|
name = "pyo3-ffi"
|
|
110
|
-
version = "0.
|
|
78
|
+
version = "0.28.1"
|
|
111
79
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
112
|
-
checksum = "
|
|
80
|
+
checksum = "9dfc1956b709823164763a34cc42bbfd26b8730afa77809a3df8b94a3ae3b059"
|
|
113
81
|
dependencies = [
|
|
114
82
|
"libc",
|
|
115
83
|
"pyo3-build-config",
|
|
@@ -117,9 +85,9 @@ dependencies = [
|
|
|
117
85
|
|
|
118
86
|
[[package]]
|
|
119
87
|
name = "pyo3-macros"
|
|
120
|
-
version = "0.
|
|
88
|
+
version = "0.28.1"
|
|
121
89
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
-
checksum = "
|
|
90
|
+
checksum = "29dc660ad948bae134d579661d08033fbb1918f4529c3bbe3257a68f2009ddf2"
|
|
123
91
|
dependencies = [
|
|
124
92
|
"proc-macro2",
|
|
125
93
|
"pyo3-macros-backend",
|
|
@@ -129,9 +97,9 @@ dependencies = [
|
|
|
129
97
|
|
|
130
98
|
[[package]]
|
|
131
99
|
name = "pyo3-macros-backend"
|
|
132
|
-
version = "0.
|
|
100
|
+
version = "0.28.1"
|
|
133
101
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
-
checksum = "
|
|
102
|
+
checksum = "e78cd6c6d718acfcedf26c3d21fe0f053624368b0d44298c55d7138fde9331f7"
|
|
135
103
|
dependencies = [
|
|
136
104
|
"heck",
|
|
137
105
|
"proc-macro2",
|
|
@@ -151,7 +119,7 @@ dependencies = [
|
|
|
151
119
|
|
|
152
120
|
[[package]]
|
|
153
121
|
name = "rs_parsepatch"
|
|
154
|
-
version = "0.4.
|
|
122
|
+
version = "0.4.5"
|
|
155
123
|
dependencies = [
|
|
156
124
|
"parsepatch",
|
|
157
125
|
"pyo3",
|
|
@@ -170,18 +138,12 @@ dependencies = [
|
|
|
170
138
|
|
|
171
139
|
[[package]]
|
|
172
140
|
name = "target-lexicon"
|
|
173
|
-
version = "0.
|
|
141
|
+
version = "0.13.5"
|
|
174
142
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
175
|
-
checksum = "
|
|
143
|
+
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
176
144
|
|
|
177
145
|
[[package]]
|
|
178
146
|
name = "unicode-ident"
|
|
179
147
|
version = "1.0.13"
|
|
180
148
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
181
149
|
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
|
182
|
-
|
|
183
|
-
[[package]]
|
|
184
|
-
name = "unindent"
|
|
185
|
-
version = "0.2.3"
|
|
186
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
187
|
-
checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "rs_parsepatch"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.5"
|
|
4
4
|
authors = ["calixteman <cdenizet@mozilla.com>"]
|
|
5
5
|
edition = "2018"
|
|
6
6
|
license = "MPL-2.0"
|
|
@@ -17,5 +17,5 @@ crate-type = ["cdylib"]
|
|
|
17
17
|
parsepatch = "0.3"
|
|
18
18
|
|
|
19
19
|
[dependencies.pyo3]
|
|
20
|
-
version = "0.
|
|
20
|
+
version = "0.28"
|
|
21
21
|
features = ["extension-module"]
|
|
@@ -4,14 +4,15 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rs_parsepatch"
|
|
7
|
+
version = "0.4.5"
|
|
7
8
|
classifier = [
|
|
8
9
|
"License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
|
|
9
10
|
"Programming Language :: Python :: 3",
|
|
10
|
-
"Programming Language :: Python :: 3.9",
|
|
11
11
|
"Programming Language :: Python :: 3.10",
|
|
12
12
|
"Programming Language :: Python :: 3.11",
|
|
13
13
|
"Programming Language :: Python :: 3.12",
|
|
14
14
|
"Programming Language :: Python :: 3.13",
|
|
15
|
+
"Programming Language :: Python :: 3.14",
|
|
15
16
|
"Programming Language :: Python",
|
|
16
17
|
"Programming Language :: Rust",
|
|
17
18
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use parsepatch::{BinaryHunk, FileMode, FileOp};
|
|
2
2
|
use pyo3::prelude::*;
|
|
3
3
|
use pyo3::types::PyDict;
|
|
4
|
-
use pyo3::types::{PyByteArray, PyBytes, PyString
|
|
4
|
+
use pyo3::types::{PyByteArray, PyBytes, PyString};
|
|
5
5
|
use pyo3::Python;
|
|
6
6
|
|
|
7
7
|
pub(crate) enum Bytes<'a> {
|
|
@@ -10,34 +10,34 @@ pub(crate) enum Bytes<'a> {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
#[inline(always)]
|
|
13
|
-
pub fn create_mode(old: Option<u32>, new: Option<u32>, py: &Python) ->
|
|
14
|
-
let dict = PyDict::
|
|
13
|
+
pub fn create_mode(old: Option<u32>, new: Option<u32>, py: &Python) -> Py<PyAny> {
|
|
14
|
+
let dict = PyDict::new(*py);
|
|
15
15
|
if let Some(old) = old {
|
|
16
16
|
dict.set_item("old", old).unwrap();
|
|
17
17
|
}
|
|
18
18
|
if let Some(new) = new {
|
|
19
19
|
dict.set_item("new", new).unwrap();
|
|
20
20
|
}
|
|
21
|
-
dict.
|
|
21
|
+
dict.into_any().unbind()
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
#[inline(always)]
|
|
25
|
-
pub fn create_file_mode(modes: Option<FileMode>, py: &Python) ->
|
|
26
|
-
let dict = PyDict::
|
|
25
|
+
pub fn create_file_mode(modes: Option<FileMode>, py: &Python) -> Py<PyAny> {
|
|
26
|
+
let dict = PyDict::new(*py);
|
|
27
27
|
if let Some(modes) = modes {
|
|
28
28
|
dict.set_item("old", modes.old).unwrap();
|
|
29
29
|
dict.set_item("new", modes.new).unwrap();
|
|
30
30
|
}
|
|
31
|
-
dict.
|
|
31
|
+
dict.into_any().unbind()
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
#[inline(always)]
|
|
35
|
-
pub fn create_bin_size(h: BinaryHunk, py: &Python) ->
|
|
35
|
+
pub fn create_bin_size(h: BinaryHunk, py: &Python) -> Py<PyAny> {
|
|
36
36
|
let x = match h {
|
|
37
37
|
BinaryHunk::Literal(s) => ("literal", s),
|
|
38
38
|
BinaryHunk::Delta(s) => ("delta", s),
|
|
39
39
|
};
|
|
40
|
-
|
|
40
|
+
(x.0, x.1).into_pyobject(*py).unwrap().into_any().unbind()
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
#[inline(always)]
|
|
@@ -100,24 +100,24 @@ pub fn set_info(
|
|
|
100
100
|
|
|
101
101
|
if let Some(mut binary_sizes) = binary_sizes {
|
|
102
102
|
diff.set_item("binary", true).unwrap();
|
|
103
|
-
let sizes: Vec<
|
|
103
|
+
let sizes: Vec<Py<PyAny>> = binary_sizes
|
|
104
104
|
.drain(..)
|
|
105
105
|
.map(move |x| create_bin_size(x, py))
|
|
106
106
|
.collect();
|
|
107
|
-
diff.set_item("binary_hunk_size", sizes.
|
|
108
|
-
.unwrap();
|
|
107
|
+
diff.set_item("binary_hunk_size", sizes).unwrap();
|
|
109
108
|
} else {
|
|
110
109
|
diff.set_item("binary", false).unwrap();
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
|
|
114
113
|
#[inline(always)]
|
|
115
|
-
pub(crate) fn get_bytes<'a>(py: Python<'a>, bytes: &'a
|
|
116
|
-
|
|
114
|
+
pub(crate) fn get_bytes<'a>(py: Python<'a>, bytes: &'a Py<PyAny>) -> Option<Bytes<'a>> {
|
|
115
|
+
let bytes = bytes.bind(py);
|
|
116
|
+
if let Ok(bytes) = bytes.cast::<PyBytes>() {
|
|
117
117
|
Some(Bytes::Slice(bytes.as_bytes()))
|
|
118
|
-
} else if let Ok(bytes) = bytes.
|
|
118
|
+
} else if let Ok(bytes) = bytes.cast::<PyString>() {
|
|
119
119
|
Some(Bytes::Slice(bytes.to_str().unwrap().as_bytes()))
|
|
120
|
-
} else if let Ok(bytes) = bytes.
|
|
120
|
+
} else if let Ok(bytes) = bytes.cast::<PyByteArray>() {
|
|
121
121
|
Some(Bytes::Vec(bytes.to_vec()))
|
|
122
122
|
} else {
|
|
123
123
|
None
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use parsepatch::{BinaryHunk, Diff, FileMode, FileOp, Patch};
|
|
2
2
|
use pyo3::prelude::PyDictMethods;
|
|
3
3
|
use pyo3::types::PyDict;
|
|
4
|
-
use pyo3::{Bound,
|
|
4
|
+
use pyo3::{Bound, IntoPyObject, Py, PyAny, PyResult, Python};
|
|
5
5
|
|
|
6
6
|
pub struct PyDiff<'a> {
|
|
7
7
|
py: Python<'a>,
|
|
@@ -14,7 +14,7 @@ impl<'a> PyDiff<'a> {
|
|
|
14
14
|
fn new(py: Python<'a>) -> Self {
|
|
15
15
|
PyDiff {
|
|
16
16
|
py,
|
|
17
|
-
diff: PyDict::
|
|
17
|
+
diff: PyDict::new(py),
|
|
18
18
|
add: 0,
|
|
19
19
|
del: 0,
|
|
20
20
|
}
|
|
@@ -45,19 +45,19 @@ impl<'a> Patch<PyDiff<'a>> for PyPatch<'a> {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
impl<'a> PyPatch<'a> {
|
|
48
|
-
pub fn get_result(mut self) -> PyResult<
|
|
48
|
+
pub fn get_result(mut self) -> PyResult<Py<PyAny>> {
|
|
49
49
|
let py = self.py;
|
|
50
|
-
let diffs: Vec<
|
|
50
|
+
let diffs: Vec<Py<PyAny>> = self
|
|
51
51
|
.diffs
|
|
52
52
|
.drain(..)
|
|
53
53
|
.map(move |x| {
|
|
54
54
|
x.diff.set_item("added_lines", x.add).unwrap();
|
|
55
55
|
x.diff.set_item("deleted_lines", x.del).unwrap();
|
|
56
|
-
x.diff.
|
|
56
|
+
x.diff.into_any().unbind()
|
|
57
57
|
})
|
|
58
58
|
.collect();
|
|
59
59
|
|
|
60
|
-
Ok(diffs.
|
|
60
|
+
Ok(diffs.into_pyobject(py)?.into_any().unbind())
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
use parsepatch::{BinaryHunk, Diff, FileMode, FileOp, Patch};
|
|
2
2
|
use pyo3::prelude::PyDictMethods;
|
|
3
3
|
use pyo3::types::{PyBytes, PyDict, PyTuple};
|
|
4
|
-
use pyo3::{Bound,
|
|
4
|
+
use pyo3::{Bound, IntoPyObject, Py, PyAny, PyResult, Python};
|
|
5
5
|
|
|
6
6
|
pub struct PyDiff<'a> {
|
|
7
7
|
py: Python<'a>,
|
|
8
8
|
diff: Bound<'a, PyDict>,
|
|
9
|
-
lines: Vec<
|
|
10
|
-
hunks: Vec<Vec<
|
|
9
|
+
lines: Vec<Py<PyAny>>,
|
|
10
|
+
hunks: Vec<Vec<Py<PyAny>>>,
|
|
11
11
|
has_hunks: bool,
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -15,18 +15,18 @@ impl<'a> PyDiff<'a> {
|
|
|
15
15
|
fn new(py: Python<'a>, has_hunks: bool) -> Self {
|
|
16
16
|
PyDiff {
|
|
17
17
|
py,
|
|
18
|
-
diff: PyDict::
|
|
18
|
+
diff: PyDict::new(py),
|
|
19
19
|
lines: Vec::new(),
|
|
20
20
|
hunks: Vec::new(),
|
|
21
21
|
has_hunks,
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
fn get_line(&self, line: u32) ->
|
|
25
|
+
fn get_line(&self, line: u32) -> Py<PyAny> {
|
|
26
26
|
if line == 0 {
|
|
27
27
|
self.py.None()
|
|
28
28
|
} else {
|
|
29
|
-
line.
|
|
29
|
+
line.into_pyobject(self.py).unwrap().into_any().unbind()
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -57,28 +57,28 @@ impl<'a> Patch<PyDiff<'a>> for PyPatch<'a> {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
impl<'a> PyPatch<'a> {
|
|
60
|
-
pub fn get_result(mut self) -> PyResult<
|
|
60
|
+
pub fn get_result(mut self) -> PyResult<Py<PyAny>> {
|
|
61
61
|
let py = self.py;
|
|
62
62
|
if self.hunks {
|
|
63
|
-
let diffs: Vec<
|
|
63
|
+
let diffs: Vec<Py<PyAny>> = self
|
|
64
64
|
.diffs
|
|
65
65
|
.drain(..)
|
|
66
66
|
.map(move |x| {
|
|
67
|
-
x.diff.set_item("hunks", x.hunks
|
|
68
|
-
x.diff.
|
|
67
|
+
x.diff.set_item("hunks", x.hunks).unwrap();
|
|
68
|
+
x.diff.into_any().unbind()
|
|
69
69
|
})
|
|
70
70
|
.collect();
|
|
71
|
-
Ok(diffs.
|
|
71
|
+
Ok(diffs.into_pyobject(py)?.into_any().unbind())
|
|
72
72
|
} else {
|
|
73
|
-
let diffs: Vec<
|
|
73
|
+
let diffs: Vec<Py<PyAny>> = self
|
|
74
74
|
.diffs
|
|
75
75
|
.drain(..)
|
|
76
76
|
.map(move |x| {
|
|
77
|
-
x.diff.set_item("lines", x.lines
|
|
78
|
-
x.diff.
|
|
77
|
+
x.diff.set_item("lines", x.lines).unwrap();
|
|
78
|
+
x.diff.into_any().unbind()
|
|
79
79
|
})
|
|
80
80
|
.collect();
|
|
81
|
-
Ok(diffs.
|
|
81
|
+
Ok(diffs.into_pyobject(py)?.into_any().unbind())
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -104,15 +104,17 @@ impl<'a> Diff for PyDiff<'a> {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
fn add_line(&mut self, old_line: u32, new_line: u32, line: &[u8]) {
|
|
107
|
-
let line = PyTuple::
|
|
107
|
+
let line = PyTuple::new(
|
|
108
108
|
self.py,
|
|
109
109
|
&[
|
|
110
110
|
self.get_line(old_line),
|
|
111
111
|
self.get_line(new_line),
|
|
112
|
-
PyBytes::
|
|
112
|
+
PyBytes::new(self.py, line).into_any().unbind(),
|
|
113
113
|
],
|
|
114
114
|
)
|
|
115
|
-
.
|
|
115
|
+
.unwrap()
|
|
116
|
+
.into_any()
|
|
117
|
+
.unbind();
|
|
116
118
|
|
|
117
119
|
if self.has_hunks {
|
|
118
120
|
self.hunks.last_mut().unwrap().push(line);
|
|
@@ -2,7 +2,7 @@ use parsepatch::{ParsepatchError, PatchReader};
|
|
|
2
2
|
use pyo3::exceptions::{PyRuntimeError, PyTypeError};
|
|
3
3
|
use pyo3::prelude::*;
|
|
4
4
|
use pyo3::types::{PyBool, PyDict, PyModule};
|
|
5
|
-
use pyo3::{PyErr, Python};
|
|
5
|
+
use pyo3::{Py, PyAny, PyErr, Python};
|
|
6
6
|
|
|
7
7
|
struct PPError(ParsepatchError);
|
|
8
8
|
|
|
@@ -42,12 +42,12 @@ macro_rules! parse_patch {
|
|
|
42
42
|
/// If the hunks=True is passed as argument then the lines are gathered by hunk
|
|
43
43
|
fn get_diffs(
|
|
44
44
|
py: Python,
|
|
45
|
-
bytes:
|
|
45
|
+
bytes: Py<PyAny>,
|
|
46
46
|
kwargs: Option<&Bound<'_, PyDict>>,
|
|
47
|
-
) -> PyResult<
|
|
47
|
+
) -> PyResult<Py<PyAny>> {
|
|
48
48
|
let hunks = if let Some(kwargs) = kwargs {
|
|
49
49
|
kwargs.get_item("hunks")?.map_or(false, |h| {
|
|
50
|
-
h.
|
|
50
|
+
h.cast::<PyBool>().ok().map_or(false, |h| h.is_true())
|
|
51
51
|
})
|
|
52
52
|
} else {
|
|
53
53
|
false
|
|
@@ -73,13 +73,13 @@ fn get_diffs(
|
|
|
73
73
|
|
|
74
74
|
#[pyfunction]
|
|
75
75
|
/// Get the number of added/deleted lines for each file in the patch
|
|
76
|
-
fn get_counts(py: Python, bytes:
|
|
76
|
+
fn get_counts(py: Python, bytes: Py<PyAny>) -> PyResult<Py<PyAny>> {
|
|
77
77
|
parse_patch!(py, bytes, counts)
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
#[pyfunction]
|
|
81
81
|
/// Get the added/deleted line numbers for each file in the patch
|
|
82
|
-
fn get_lines(py: Python, bytes:
|
|
82
|
+
fn get_lines(py: Python, bytes: Py<PyAny>) -> PyResult<Py<PyAny>> {
|
|
83
83
|
parse_patch!(py, bytes, lines)
|
|
84
84
|
}
|
|
85
85
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
use parsepatch::{BinaryHunk, Diff, FileMode, FileOp, Patch};
|
|
2
2
|
use pyo3::prelude::PyDictMethods;
|
|
3
3
|
use pyo3::types::PyDict;
|
|
4
|
-
use pyo3::{Bound,
|
|
4
|
+
use pyo3::{Bound, IntoPyObject, Py, PyAny, PyResult, Python};
|
|
5
5
|
|
|
6
6
|
pub struct PyDiff<'a> {
|
|
7
7
|
py: Python<'a>,
|
|
@@ -14,7 +14,7 @@ impl<'a> PyDiff<'a> {
|
|
|
14
14
|
fn new(py: Python<'a>) -> Self {
|
|
15
15
|
PyDiff {
|
|
16
16
|
py,
|
|
17
|
-
diff: PyDict::
|
|
17
|
+
diff: PyDict::new(py),
|
|
18
18
|
add: Vec::new(),
|
|
19
19
|
del: Vec::new(),
|
|
20
20
|
}
|
|
@@ -45,19 +45,19 @@ impl<'a> Patch<PyDiff<'a>> for PyPatch<'a> {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
impl<'a> PyPatch<'a> {
|
|
48
|
-
pub fn get_result(mut self) -> PyResult<
|
|
48
|
+
pub fn get_result(mut self) -> PyResult<Py<PyAny>> {
|
|
49
49
|
let py = self.py;
|
|
50
|
-
let diffs: Vec<
|
|
50
|
+
let diffs: Vec<Py<PyAny>> = self
|
|
51
51
|
.diffs
|
|
52
52
|
.drain(..)
|
|
53
53
|
.map(move |x| {
|
|
54
54
|
x.diff.set_item("added_lines", x.add).unwrap();
|
|
55
55
|
x.diff.set_item("deleted_lines", x.del).unwrap();
|
|
56
|
-
x.diff.
|
|
56
|
+
x.diff.into_any().unbind()
|
|
57
57
|
})
|
|
58
58
|
.collect();
|
|
59
59
|
|
|
60
|
-
Ok(diffs.
|
|
60
|
+
Ok(diffs.into_pyobject(py)?.into_any().unbind())
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
rs_parsepatch-0.4.4/PKG-INFO
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: rs_parsepatch
|
|
3
|
-
Version: 0.4.4
|
|
4
|
-
Home-Page: https://github.com/mozilla/pyo3-parsepatch
|
|
5
|
-
Author: calixteman <cdenizet@mozilla.com>
|
|
6
|
-
Author-email: calixteman <cdenizet@mozilla.com>
|
|
7
|
-
License: MPL-2.0
|
|
8
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
9
|
-
Project-URL: Source Code, https://github.com/mozilla/pyo3-parsepatch
|
|
10
|
-
|
|
11
|
-
# pyo3-parsepatch
|
|
12
|
-
|
|
13
|
-
A Python wrapper for https://github.com/mozilla/rust-parsepatch.
|
|
14
|
-
The goal of this library is to be able to parse the patches coming from mercurial.
|
|
15
|
-
All the patches in https://hg.mozilla.org/mozilla-central/ have been successfully parsed !
|
|
16
|
-
It's used in https://github.com/mozilla/bugbug to get some metrics on patches.
|
|
17
|
-
|
|
18
|
-
## License
|
|
19
|
-
|
|
20
|
-
Published under the MPL 2.0 license.
|
|
21
|
-
|
|
22
|
-
## Publish
|
|
23
|
-
|
|
24
|
-
Install docker and then:
|
|
25
|
-
```sh
|
|
26
|
-
docker build -t rs_pp
|
|
27
|
-
```
|
|
28
|
-
It will compile everything and run tests in a manylinux environment.
|
|
29
|
-
|
|
30
|
-
And then:
|
|
31
|
-
```sh
|
|
32
|
-
docker run -it rs_pp
|
|
33
|
-
```
|
|
34
|
-
to publish the packages on Pypi.
|
|
35
|
-
|
|
36
|
-
## Contact
|
|
37
|
-
|
|
38
|
-
Email: calixte@mozilla.com
|
|
39
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|