Show More
@@ -0,0 +1,177 b'' | |||||
|
1 | // parsers.rs | |||
|
2 | // | |||
|
3 | // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> | |||
|
4 | // | |||
|
5 | // This software may be used and distributed according to the terms of the | |||
|
6 | // GNU General Public License version 2 or any later version. | |||
|
7 | ||||
|
8 | //! Bindings for the `hg::dirstate::parsers` module provided by the | |||
|
9 | //! `hg-core` package. | |||
|
10 | //! | |||
|
11 | //! From Python, this will be seen as `mercurial.rustext.parsers` | |||
|
12 | //! | |||
|
13 | use cpython::{ | |||
|
14 | exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyResult, PyTuple, Python, | |||
|
15 | PythonObject, ToPyObject, | |||
|
16 | }; | |||
|
17 | use hg::{ | |||
|
18 | pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry, | |||
|
19 | DirstatePackError, DirstateParents, DirstateParseError, | |||
|
20 | }; | |||
|
21 | use std::collections::HashMap; | |||
|
22 | ||||
|
23 | use libc::c_char; | |||
|
24 | ||||
|
25 | use crate::dirstate::{decapsule_make_dirstate_tuple, extract_dirstate_vec}; | |||
|
26 | ||||
|
27 | fn parse_dirstate_wrapper( | |||
|
28 | py: Python, | |||
|
29 | dmap: PyDict, | |||
|
30 | copymap: PyDict, | |||
|
31 | st: PyBytes, | |||
|
32 | ) -> PyResult<PyTuple> { | |||
|
33 | match parse_dirstate(st.data(py)) { | |||
|
34 | Ok((parents, dirstate_vec, copies)) => { | |||
|
35 | for (filename, entry) in dirstate_vec { | |||
|
36 | dmap.set_item( | |||
|
37 | py, | |||
|
38 | PyBytes::new(py, &filename[..]), | |||
|
39 | decapsule_make_dirstate_tuple(py)?( | |||
|
40 | entry.state as c_char, | |||
|
41 | entry.mode, | |||
|
42 | entry.size, | |||
|
43 | entry.mtime, | |||
|
44 | ), | |||
|
45 | )?; | |||
|
46 | } | |||
|
47 | for CopyVecEntry { path, copy_path } in copies { | |||
|
48 | copymap.set_item( | |||
|
49 | py, | |||
|
50 | PyBytes::new(py, path), | |||
|
51 | PyBytes::new(py, copy_path), | |||
|
52 | )?; | |||
|
53 | } | |||
|
54 | Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2)) | |||
|
55 | .to_py_object(py)) | |||
|
56 | } | |||
|
57 | Err(e) => Err(PyErr::new::<exc::ValueError, _>( | |||
|
58 | py, | |||
|
59 | match e { | |||
|
60 | DirstateParseError::TooLittleData => { | |||
|
61 | "too little data for parents".to_string() | |||
|
62 | } | |||
|
63 | DirstateParseError::Overflow => { | |||
|
64 | "overflow in dirstate".to_string() | |||
|
65 | } | |||
|
66 | DirstateParseError::CorruptedEntry(e) => e, | |||
|
67 | }, | |||
|
68 | )), | |||
|
69 | } | |||
|
70 | } | |||
|
71 | ||||
|
72 | fn pack_dirstate_wrapper( | |||
|
73 | py: Python, | |||
|
74 | dmap: PyDict, | |||
|
75 | copymap: PyDict, | |||
|
76 | pl: PyTuple, | |||
|
77 | now: PyInt, | |||
|
78 | ) -> PyResult<PyBytes> { | |||
|
79 | let p1 = pl.get_item(py, 0).extract::<PyBytes>(py)?; | |||
|
80 | let p1: &[u8] = p1.data(py); | |||
|
81 | let p2 = pl.get_item(py, 1).extract::<PyBytes>(py)?; | |||
|
82 | let p2: &[u8] = p2.data(py); | |||
|
83 | ||||
|
84 | let dirstate_vec = extract_dirstate_vec(py, &dmap)?; | |||
|
85 | ||||
|
86 | let copies: Result<HashMap<Vec<u8>, Vec<u8>>, PyErr> = copymap | |||
|
87 | .items(py) | |||
|
88 | .iter() | |||
|
89 | .map(|(key, value)| { | |||
|
90 | Ok(( | |||
|
91 | key.extract::<PyBytes>(py)?.data(py).to_owned(), | |||
|
92 | value.extract::<PyBytes>(py)?.data(py).to_owned(), | |||
|
93 | )) | |||
|
94 | }) | |||
|
95 | .collect(); | |||
|
96 | ||||
|
97 | match pack_dirstate( | |||
|
98 | &dirstate_vec, | |||
|
99 | &copies?, | |||
|
100 | DirstateParents { p1, p2 }, | |||
|
101 | now.as_object().extract::<i32>(py)?, | |||
|
102 | ) { | |||
|
103 | Ok((packed, new_dirstate_vec)) => { | |||
|
104 | for ( | |||
|
105 | filename, | |||
|
106 | DirstateEntry { | |||
|
107 | state, | |||
|
108 | mode, | |||
|
109 | size, | |||
|
110 | mtime, | |||
|
111 | }, | |||
|
112 | ) in new_dirstate_vec | |||
|
113 | { | |||
|
114 | dmap.set_item( | |||
|
115 | py, | |||
|
116 | PyBytes::new(py, &filename[..]), | |||
|
117 | decapsule_make_dirstate_tuple(py)?( | |||
|
118 | state as c_char, | |||
|
119 | mode, | |||
|
120 | size, | |||
|
121 | mtime, | |||
|
122 | ), | |||
|
123 | )?; | |||
|
124 | } | |||
|
125 | Ok(PyBytes::new(py, &packed)) | |||
|
126 | } | |||
|
127 | Err(error) => Err(PyErr::new::<exc::ValueError, _>( | |||
|
128 | py, | |||
|
129 | match error { | |||
|
130 | DirstatePackError::CorruptedParent => { | |||
|
131 | "expected a 20-byte hash".to_string() | |||
|
132 | } | |||
|
133 | DirstatePackError::CorruptedEntry(e) => e, | |||
|
134 | DirstatePackError::BadSize(expected, actual) => { | |||
|
135 | format!("bad dirstate size: {} != {}", actual, expected) | |||
|
136 | } | |||
|
137 | }, | |||
|
138 | )), | |||
|
139 | } | |||
|
140 | } | |||
|
141 | ||||
|
142 | /// Create the module, with `__package__` given from parent | |||
|
143 | pub fn init_parsers_module(py: Python, package: &str) -> PyResult<PyModule> { | |||
|
144 | let dotted_name = &format!("{}.parsers", package); | |||
|
145 | let m = PyModule::new(py, dotted_name)?; | |||
|
146 | ||||
|
147 | m.add(py, "__package__", package)?; | |||
|
148 | m.add(py, "__doc__", "Parsers - Rust implementation")?; | |||
|
149 | ||||
|
150 | m.add( | |||
|
151 | py, | |||
|
152 | "parse_dirstate", | |||
|
153 | py_fn!( | |||
|
154 | py, | |||
|
155 | parse_dirstate_wrapper(dmap: PyDict, copymap: PyDict, st: PyBytes) | |||
|
156 | ), | |||
|
157 | )?; | |||
|
158 | m.add( | |||
|
159 | py, | |||
|
160 | "pack_dirstate", | |||
|
161 | py_fn!( | |||
|
162 | py, | |||
|
163 | pack_dirstate_wrapper( | |||
|
164 | dmap: PyDict, | |||
|
165 | copymap: PyDict, | |||
|
166 | pl: PyTuple, | |||
|
167 | now: PyInt | |||
|
168 | ) | |||
|
169 | ), | |||
|
170 | )?; | |||
|
171 | ||||
|
172 | let sys = PyModule::import(py, "sys")?; | |||
|
173 | let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?; | |||
|
174 | sys_modules.set_item(py, dotted_name, &m)?; | |||
|
175 | ||||
|
176 | Ok(m) | |||
|
177 | } |
@@ -27,14 +27,14 b' from . import (' | |||||
27 | util, |
|
27 | util, | |
28 | ) |
|
28 | ) | |
29 |
|
29 | |||
30 | parsers = policy.importmod(r'parsers') |
|
30 | orig_parsers = policy.importmod(r'parsers') | |
31 |
|
|
31 | parsers = policy.importrust(r'parsers', default=orig_parsers) | |
32 |
|
32 | |||
33 | propertycache = util.propertycache |
|
33 | propertycache = util.propertycache | |
34 | filecache = scmutil.filecache |
|
34 | filecache = scmutil.filecache | |
35 | _rangemask = 0x7fffffff |
|
35 | _rangemask = 0x7fffffff | |
36 |
|
36 | |||
37 | dirstatetuple = parsers.dirstatetuple |
|
37 | dirstatetuple = orig_parsers.dirstatetuple | |
38 |
|
38 | |||
39 | class repocache(filecache): |
|
39 | class repocache(filecache): | |
40 | """filecache for files in .hg/""" |
|
40 | """filecache for files in .hg/""" | |
@@ -1475,7 +1475,7 b' class dirstatemap(object):' | |||||
1475 | # parsing the dirstate. |
|
1475 | # parsing the dirstate. | |
1476 | # |
|
1476 | # | |
1477 | # (we cannot decorate the function directly since it is in a C module) |
|
1477 | # (we cannot decorate the function directly since it is in a C module) | |
1478 |
parse_dirstate = util.nogc( |
|
1478 | parse_dirstate = util.nogc(parsers.parse_dirstate) | |
1479 | p = parse_dirstate(self._map, self.copymap, st) |
|
1479 | p = parse_dirstate(self._map, self.copymap, st) | |
1480 | if not self._dirtyparents: |
|
1480 | if not self._dirtyparents: | |
1481 | self.setparents(*p) |
|
1481 | self.setparents(*p) | |
@@ -1486,8 +1486,8 b' class dirstatemap(object):' | |||||
1486 | self.get = self._map.get |
|
1486 | self.get = self._map.get | |
1487 |
|
1487 | |||
1488 | def write(self, st, now): |
|
1488 | def write(self, st, now): | |
1489 |
st.write( |
|
1489 | st.write(parsers.pack_dirstate(self._map, self.copymap, | |
1490 |
|
|
1490 | self.parents(), now)) | |
1491 | st.close() |
|
1491 | st.close() | |
1492 | self._dirtyparents = False |
|
1492 | self._dirtyparents = False | |
1493 | self.nonnormalset, self.otherparentset = self.nonnormalentries() |
|
1493 | self.nonnormalset, self.otherparentset = self.nonnormalentries() |
@@ -12,19 +12,14 b'' | |||||
12 | mod dirs_multiset; |
|
12 | mod dirs_multiset; | |
13 | use crate::dirstate::dirs_multiset::Dirs; |
|
13 | use crate::dirstate::dirs_multiset::Dirs; | |
14 | use cpython::{ |
|
14 | use cpython::{ | |
15 |
|
|
15 | PyBytes, PyDict, PyErr, PyModule, PyObject, PyResult, PySequence, Python, | |
16 | PySequence, PyTuple, Python, PythonObject, ToPyObject, |
|
|||
17 | }; |
|
16 | }; | |
18 | use hg::{ |
|
17 | use hg::{DirstateEntry, DirstateVec}; | |
19 | pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry, |
|
|||
20 | DirstatePackError, DirstateParents, DirstateParseError, DirstateVec, |
|
|||
21 | }; |
|
|||
22 | use libc::{c_char, c_int}; |
|
18 | use libc::{c_char, c_int}; | |
23 | #[cfg(feature = "python27")] |
|
19 | #[cfg(feature = "python27")] | |
24 | use python27_sys::PyCapsule_Import; |
|
20 | use python27_sys::PyCapsule_Import; | |
25 | #[cfg(feature = "python3")] |
|
21 | #[cfg(feature = "python3")] | |
26 | use python3_sys::PyCapsule_Import; |
|
22 | use python3_sys::PyCapsule_Import; | |
27 | use std::collections::HashMap; |
|
|||
28 | use std::ffi::CStr; |
|
23 | use std::ffi::CStr; | |
29 | use std::mem::transmute; |
|
24 | use std::mem::transmute; | |
30 |
|
25 | |||
@@ -44,7 +39,9 b' type MakeDirstateTupleFn = extern "C" fn' | |||||
44 | /// This is largely a copy/paste from cindex.rs, pending the merge of a |
|
39 | /// This is largely a copy/paste from cindex.rs, pending the merge of a | |
45 | /// `py_capsule_fn!` macro in the rust-cpython project: |
|
40 | /// `py_capsule_fn!` macro in the rust-cpython project: | |
46 | /// https://github.com/dgrunwald/rust-cpython/pull/169 |
|
41 | /// https://github.com/dgrunwald/rust-cpython/pull/169 | |
47 | fn decapsule_make_dirstate_tuple(py: Python) -> PyResult<MakeDirstateTupleFn> { |
|
42 | pub fn decapsule_make_dirstate_tuple( | |
|
43 | py: Python, | |||
|
44 | ) -> PyResult<MakeDirstateTupleFn> { | |||
48 | unsafe { |
|
45 | unsafe { | |
49 | let caps_name = CStr::from_bytes_with_nul_unchecked( |
|
46 | let caps_name = CStr::from_bytes_with_nul_unchecked( | |
50 | b"mercurial.cext.parsers.make_dirstate_tuple_CAPI\0", |
|
47 | b"mercurial.cext.parsers.make_dirstate_tuple_CAPI\0", | |
@@ -57,52 +54,7 b' fn decapsule_make_dirstate_tuple(py: Pyt' | |||||
57 | } |
|
54 | } | |
58 | } |
|
55 | } | |
59 |
|
56 | |||
60 | fn parse_dirstate_wrapper( |
|
57 | pub fn extract_dirstate_vec( | |
61 | py: Python, |
|
|||
62 | dmap: PyDict, |
|
|||
63 | copymap: PyDict, |
|
|||
64 | st: PyBytes, |
|
|||
65 | ) -> PyResult<PyTuple> { |
|
|||
66 | match parse_dirstate(st.data(py)) { |
|
|||
67 | Ok((parents, dirstate_vec, copies)) => { |
|
|||
68 | for (filename, entry) in dirstate_vec { |
|
|||
69 | dmap.set_item( |
|
|||
70 | py, |
|
|||
71 | PyBytes::new(py, &filename[..]), |
|
|||
72 | decapsule_make_dirstate_tuple(py)?( |
|
|||
73 | entry.state as c_char, |
|
|||
74 | entry.mode, |
|
|||
75 | entry.size, |
|
|||
76 | entry.mtime, |
|
|||
77 | ), |
|
|||
78 | )?; |
|
|||
79 | } |
|
|||
80 | for CopyVecEntry { path, copy_path } in copies { |
|
|||
81 | copymap.set_item( |
|
|||
82 | py, |
|
|||
83 | PyBytes::new(py, path), |
|
|||
84 | PyBytes::new(py, copy_path), |
|
|||
85 | )?; |
|
|||
86 | } |
|
|||
87 | Ok((PyBytes::new(py, parents.p1), PyBytes::new(py, parents.p2)) |
|
|||
88 | .to_py_object(py)) |
|
|||
89 | } |
|
|||
90 | Err(e) => Err(PyErr::new::<exc::ValueError, _>( |
|
|||
91 | py, |
|
|||
92 | match e { |
|
|||
93 | DirstateParseError::TooLittleData => { |
|
|||
94 | "too little data for parents".to_string() |
|
|||
95 | } |
|
|||
96 | DirstateParseError::Overflow => { |
|
|||
97 | "overflow in dirstate".to_string() |
|
|||
98 | } |
|
|||
99 | DirstateParseError::CorruptedEntry(e) => e, |
|
|||
100 | }, |
|
|||
101 | )), |
|
|||
102 | } |
|
|||
103 | } |
|
|||
104 |
|
||||
105 | fn extract_dirstate_vec( |
|
|||
106 | py: Python, |
|
58 | py: Python, | |
107 | dmap: &PyDict, |
|
59 | dmap: &PyDict, | |
108 | ) -> Result<DirstateVec, PyErr> { |
|
60 | ) -> Result<DirstateVec, PyErr> { | |
@@ -130,76 +82,6 b' fn extract_dirstate_vec(' | |||||
130 | .collect() |
|
82 | .collect() | |
131 | } |
|
83 | } | |
132 |
|
84 | |||
133 | fn pack_dirstate_wrapper( |
|
|||
134 | py: Python, |
|
|||
135 | dmap: PyDict, |
|
|||
136 | copymap: PyDict, |
|
|||
137 | pl: PyTuple, |
|
|||
138 | now: PyInt, |
|
|||
139 | ) -> PyResult<PyBytes> { |
|
|||
140 | let p1 = pl.get_item(py, 0).extract::<PyBytes>(py)?; |
|
|||
141 | let p1: &[u8] = p1.data(py); |
|
|||
142 | let p2 = pl.get_item(py, 1).extract::<PyBytes>(py)?; |
|
|||
143 | let p2: &[u8] = p2.data(py); |
|
|||
144 |
|
||||
145 | let dirstate_vec = extract_dirstate_vec(py, &dmap)?; |
|
|||
146 |
|
||||
147 | let copies: Result<HashMap<Vec<u8>, Vec<u8>>, PyErr> = copymap |
|
|||
148 | .items(py) |
|
|||
149 | .iter() |
|
|||
150 | .map(|(key, value)| { |
|
|||
151 | Ok(( |
|
|||
152 | key.extract::<PyBytes>(py)?.data(py).to_owned(), |
|
|||
153 | value.extract::<PyBytes>(py)?.data(py).to_owned(), |
|
|||
154 | )) |
|
|||
155 | }) |
|
|||
156 | .collect(); |
|
|||
157 |
|
||||
158 | match pack_dirstate( |
|
|||
159 | &dirstate_vec, |
|
|||
160 | &copies?, |
|
|||
161 | DirstateParents { p1, p2 }, |
|
|||
162 | now.as_object().extract::<i32>(py)?, |
|
|||
163 | ) { |
|
|||
164 | Ok((packed, new_dirstate_vec)) => { |
|
|||
165 | for ( |
|
|||
166 | filename, |
|
|||
167 | DirstateEntry { |
|
|||
168 | state, |
|
|||
169 | mode, |
|
|||
170 | size, |
|
|||
171 | mtime, |
|
|||
172 | }, |
|
|||
173 | ) in new_dirstate_vec |
|
|||
174 | { |
|
|||
175 | dmap.set_item( |
|
|||
176 | py, |
|
|||
177 | PyBytes::new(py, &filename[..]), |
|
|||
178 | decapsule_make_dirstate_tuple(py)?( |
|
|||
179 | state as c_char, |
|
|||
180 | mode, |
|
|||
181 | size, |
|
|||
182 | mtime, |
|
|||
183 | ), |
|
|||
184 | )?; |
|
|||
185 | } |
|
|||
186 | Ok(PyBytes::new(py, &packed)) |
|
|||
187 | } |
|
|||
188 | Err(error) => Err(PyErr::new::<exc::ValueError, _>( |
|
|||
189 | py, |
|
|||
190 | match error { |
|
|||
191 | DirstatePackError::CorruptedParent => { |
|
|||
192 | "expected a 20-byte hash".to_string() |
|
|||
193 | } |
|
|||
194 | DirstatePackError::CorruptedEntry(e) => e, |
|
|||
195 | DirstatePackError::BadSize(expected, actual) => { |
|
|||
196 | format!("bad dirstate size: {} != {}", actual, expected) |
|
|||
197 | } |
|
|||
198 | }, |
|
|||
199 | )), |
|
|||
200 | } |
|
|||
201 | } |
|
|||
202 |
|
||||
203 | /// Create the module, with `__package__` given from parent |
|
85 | /// Create the module, with `__package__` given from parent | |
204 | pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { |
|
86 | pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { | |
205 | let dotted_name = &format!("{}.dirstate", package); |
|
87 | let dotted_name = &format!("{}.dirstate", package); | |
@@ -207,27 +89,6 b' pub fn init_module(py: Python, package: ' | |||||
207 |
|
89 | |||
208 | m.add(py, "__package__", package)?; |
|
90 | m.add(py, "__package__", package)?; | |
209 | m.add(py, "__doc__", "Dirstate - Rust implementation")?; |
|
91 | m.add(py, "__doc__", "Dirstate - Rust implementation")?; | |
210 | m.add( |
|
|||
211 | py, |
|
|||
212 | "parse_dirstate", |
|
|||
213 | py_fn!( |
|
|||
214 | py, |
|
|||
215 | parse_dirstate_wrapper(dmap: PyDict, copymap: PyDict, st: PyBytes) |
|
|||
216 | ), |
|
|||
217 | )?; |
|
|||
218 | m.add( |
|
|||
219 | py, |
|
|||
220 | "pack_dirstate", |
|
|||
221 | py_fn!( |
|
|||
222 | py, |
|
|||
223 | pack_dirstate_wrapper( |
|
|||
224 | dmap: PyDict, |
|
|||
225 | copymap: PyDict, |
|
|||
226 | pl: PyTuple, |
|
|||
227 | now: PyInt |
|
|||
228 | ) |
|
|||
229 | ), |
|
|||
230 | )?; |
|
|||
231 |
|
92 | |||
232 | m.add_class::<Dirs>(py)?; |
|
93 | m.add_class::<Dirs>(py)?; | |
233 |
|
94 |
@@ -29,6 +29,7 b' mod cindex;' | |||||
29 | mod conversion; |
|
29 | mod conversion; | |
30 | pub mod dagops; |
|
30 | pub mod dagops; | |
31 | pub mod dirstate; |
|
31 | pub mod dirstate; | |
|
32 | pub mod parsers; | |||
32 | pub mod discovery; |
|
33 | pub mod discovery; | |
33 | pub mod exceptions; |
|
34 | pub mod exceptions; | |
34 | pub mod filepatterns; |
|
35 | pub mod filepatterns; | |
@@ -50,6 +51,11 b' py_module_initializer!(rustext, initrust' | |||||
50 | "filepatterns", |
|
51 | "filepatterns", | |
51 | filepatterns::init_module(py, &dotted_name)?, |
|
52 | filepatterns::init_module(py, &dotted_name)?, | |
52 | )?; |
|
53 | )?; | |
|
54 | m.add( | |||
|
55 | py, | |||
|
56 | "parsers", | |||
|
57 | parsers::init_parsers_module(py, &dotted_name)?, | |||
|
58 | )?; | |||
53 | m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?; |
|
59 | m.add(py, "GraphError", py.get_type::<exceptions::GraphError>())?; | |
54 | m.add( |
|
60 | m.add( | |
55 | py, |
|
61 | py, |
@@ -30,6 +30,7 b" configitem(b'fakedirstatewritetime', b'f" | |||||
30 | ) |
|
30 | ) | |
31 |
|
31 | |||
32 | parsers = policy.importmod(r'parsers') |
|
32 | parsers = policy.importmod(r'parsers') | |
|
33 | rustmod = policy.importrust(r'parsers') | |||
33 |
|
34 | |||
34 | def pack_dirstate(fakenow, orig, dmap, copymap, pl, now): |
|
35 | def pack_dirstate(fakenow, orig, dmap, copymap, pl, now): | |
35 | # execute what original parsers.pack_dirstate should do actually |
|
36 | # execute what original parsers.pack_dirstate should do actually | |
@@ -57,16 +58,21 b' def fakewrite(ui, func):' | |||||
57 | # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy |
|
58 | # 'fakenow' value and 'touch -t YYYYmmddHHMM' argument easy | |
58 | fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0] |
|
59 | fakenow = dateutil.parsedate(fakenow, [b'%Y%m%d%H%M'])[0] | |
59 |
|
60 | |||
60 |
if rust |
|
61 | if rustmod is not None: | |
61 | orig_module = rustext.dirstate |
|
62 | # The Rust implementation does not use public parse/pack dirstate | |
62 | orig_pack_dirstate = rustext.dirstate.pack_dirstate |
|
63 | # to prevent conversion round-trips | |
63 | else: |
|
64 | orig_dirstatemap_write = dirstate.dirstatemap.write | |
64 | orig_module = parsers |
|
65 | wrapper = lambda self, st, now: orig_dirstatemap_write(self, | |
65 | orig_pack_dirstate = parsers.pack_dirstate |
|
66 | st, | |
|
67 | fakenow) | |||
|
68 | dirstate.dirstatemap.write = wrapper | |||
66 |
|
69 | |||
67 | orig_dirstate_getfsnow = dirstate._getfsnow |
|
70 | orig_dirstate_getfsnow = dirstate._getfsnow | |
68 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) |
|
71 | wrapper = lambda *args: pack_dirstate(fakenow, orig_pack_dirstate, *args) | |
69 |
|
72 | |||
|
73 | orig_module = parsers | |||
|
74 | orig_pack_dirstate = parsers.pack_dirstate | |||
|
75 | ||||
70 | orig_module.pack_dirstate = wrapper |
|
76 | orig_module.pack_dirstate = wrapper | |
71 | dirstate._getfsnow = lambda *args: fakenow |
|
77 | dirstate._getfsnow = lambda *args: fakenow | |
72 | try: |
|
78 | try: | |
@@ -74,6 +80,8 b' def fakewrite(ui, func):' | |||||
74 | finally: |
|
80 | finally: | |
75 | orig_module.pack_dirstate = orig_pack_dirstate |
|
81 | orig_module.pack_dirstate = orig_pack_dirstate | |
76 | dirstate._getfsnow = orig_dirstate_getfsnow |
|
82 | dirstate._getfsnow = orig_dirstate_getfsnow | |
|
83 | if rustmod is not None: | |||
|
84 | dirstate.dirstatemap.write = orig_dirstatemap_write | |||
77 |
|
85 | |||
78 | def _poststatusfixup(orig, workingctx, status, fixup): |
|
86 | def _poststatusfixup(orig, workingctx, status, fixup): | |
79 | ui = workingctx.repo().ui |
|
87 | ui = workingctx.repo().ui |
General Comments 0
You need to be logged in to leave comments.
Login now