comparison rust/hg-cpython/src/update.rs @ 52186:e6a44bc91bc2 stable

rust-update: make `update_from_null` respect `worker.numcpu` config option This was overlooked in the original series. This is important for tests (because we run many at once), and for the occasional end user that wants to keep their CPU usage in check. A future series should clean up this `worker` parameter tunelling business by rewriting the config in Rust, but doing so on stable would be a very bad idea.
author Rapha?l Gom?s <rgomes@octobus.net>
date Tue, 05 Nov 2024 15:21:09 +0100
parents 8b7123c8947b
children 96b113d22b34
comparison
equal deleted inserted replaced
52185:e698e3e75420 52186:e6a44bc91bc2
20 20
21 pub fn update_from_null_fast_path( 21 pub fn update_from_null_fast_path(
22 py: Python, 22 py: Python,
23 repo_path: PyObject, 23 repo_path: PyObject,
24 to: BaseRevision, 24 to: BaseRevision,
25 num_cpus: Option<usize>,
25 ) -> PyResult<usize> { 26 ) -> PyResult<usize> {
26 log::trace!("Using update from null fastpath"); 27 log::trace!("Using update from null fastpath");
27 let repo = repo_from_path(py, repo_path)?; 28 let repo = repo_from_path(py, repo_path)?;
28 let progress: &dyn Progress = &HgProgressBar::new("updating"); 29 let progress: &dyn Progress = &HgProgressBar::new("updating");
29 hgerror_to_pyerr(py, update_from_null(&repo, to.into(), progress)) 30 hgerror_to_pyerr(
31 py,
32 update_from_null(&repo, to.into(), progress, num_cpus),
33 )
30 } 34 }
31 35
32 pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { 36 pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> {
33 let dotted_name = &format!("{}.update", package); 37 let dotted_name = &format!("{}.update", package);
34 let m = PyModule::new(py, dotted_name)?; 38 let m = PyModule::new(py, dotted_name)?;
39 m.add( 43 m.add(
40 py, 44 py,
41 "update_from_null", 45 "update_from_null",
42 py_fn!( 46 py_fn!(
43 py, 47 py,
44 update_from_null_fast_path(repo_path: PyObject, to: BaseRevision,) 48 update_from_null_fast_path(
49 repo_path: PyObject,
50 to: BaseRevision,
51 num_cpus: Option<usize>
52 )
45 ), 53 ),
46 )?; 54 )?;
47 55
48 let sys = PyModule::import(py, "sys")?; 56 let sys = PyModule::import(py, "sys")?;
49 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?; 57 let sys_modules: PyDict = sys.get(py, "modules")?.extract(py)?;