##// END OF EJS Templates
dirstate-tree: Give to `status()` mutable access to the `DirstateMap`...
Simon Sapin -
r47882:d5956136 default
parent child Browse files
Show More
@@ -0,0 +1,17 b''
1 use crate::dirstate_tree::dirstate_map::DirstateMap;
2 use crate::matchers::Matcher;
3 use crate::DirstateStatus;
4 use crate::PatternFileWarning;
5 use crate::StatusError;
6 use crate::StatusOptions;
7 use std::path::PathBuf;
8
9 pub fn status<'a>(
10 _dmap: &'a mut DirstateMap,
11 _matcher: &'a (dyn Matcher + Sync),
12 _root_dir: PathBuf,
13 _ignore_files: Vec<PathBuf>,
14 _options: StatusOptions,
15 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError> {
16 todo!()
17 }
@@ -97,7 +97,8 b' type IoResult<T> = std::io::Result<T>;'
97
97
98 /// `Box<dyn Trait>` is syntactic sugar for `Box<dyn Trait, 'static>`, so add
98 /// `Box<dyn Trait>` is syntactic sugar for `Box<dyn Trait, 'static>`, so add
99 /// an explicit lifetime here to not fight `'static` bounds "out of nowhere".
99 /// an explicit lifetime here to not fight `'static` bounds "out of nowhere".
100 type IgnoreFnType<'a> = Box<dyn for<'r> Fn(&'r HgPath) -> bool + Sync + 'a>;
100 pub type IgnoreFnType<'a> =
101 Box<dyn for<'r> Fn(&'r HgPath) -> bool + Sync + 'a>;
101
102
102 /// We have a good mix of owned (from directory traversal) and borrowed (from
103 /// We have a good mix of owned (from directory traversal) and borrowed (from
103 /// the dirstate/explicit) paths, this comes up a lot.
104 /// the dirstate/explicit) paths, this comes up a lot.
@@ -1,3 +1,4 b''
1 pub mod dirstate_map;
1 pub mod dirstate_map;
2 pub mod dispatch;
2 pub mod dispatch;
3 pub mod path_with_basename;
3 pub mod path_with_basename;
4 mod status;
@@ -576,14 +576,14 b' impl super::dispatch::DirstateMapMethods'
576 }
576 }
577
577
578 fn status<'a>(
578 fn status<'a>(
579 &'a self,
579 &'a mut self,
580 _matcher: &'a (dyn Matcher + Sync),
580 matcher: &'a (dyn Matcher + Sync),
581 _root_dir: PathBuf,
581 root_dir: PathBuf,
582 _ignore_files: Vec<PathBuf>,
582 ignore_files: Vec<PathBuf>,
583 _options: StatusOptions,
583 options: StatusOptions,
584 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>
584 ) -> Result<(DirstateStatus<'a>, Vec<PatternFileWarning>), StatusError>
585 {
585 {
586 todo!()
586 super::status::status(self, matcher, root_dir, ignore_files, options)
587 }
587 }
588
588
589 fn copy_map_len(&self) -> usize {
589 fn copy_map_len(&self) -> usize {
@@ -96,7 +96,7 b' pub trait DirstateMapMethods {'
96 fn set_dirs(&mut self) -> Result<(), DirstateMapError>;
96 fn set_dirs(&mut self) -> Result<(), DirstateMapError>;
97
97
98 fn status<'a>(
98 fn status<'a>(
99 &'a self,
99 &'a mut self,
100 matcher: &'a (dyn Matcher + Sync),
100 matcher: &'a (dyn Matcher + Sync),
101 root_dir: PathBuf,
101 root_dir: PathBuf,
102 ignore_files: Vec<PathBuf>,
102 ignore_files: Vec<PathBuf>,
@@ -258,7 +258,7 b' impl DirstateMapMethods for DirstateMap '
258 }
258 }
259
259
260 fn status<'a>(
260 fn status<'a>(
261 &'a self,
261 &'a mut self,
262 matcher: &'a (dyn Matcher + Sync),
262 matcher: &'a (dyn Matcher + Sync),
263 root_dir: PathBuf,
263 root_dir: PathBuf,
264 ignore_files: Vec<PathBuf>,
264 ignore_files: Vec<PathBuf>,
@@ -8,7 +8,7 b''
8 //! Bindings for the `hg::dirstate::dirstate_map` file provided by the
8 //! Bindings for the `hg::dirstate::dirstate_map` file provided by the
9 //! `hg-core` package.
9 //! `hg-core` package.
10
10
11 use std::cell::{Ref, RefCell};
11 use std::cell::{RefCell, RefMut};
12 use std::convert::TryInto;
12 use std::convert::TryInto;
13
13
14 use cpython::{
14 use cpython::{
@@ -527,11 +527,11 b' py_class!(pub class DirstateMap |py| {'
527 });
527 });
528
528
529 impl DirstateMap {
529 impl DirstateMap {
530 pub fn get_inner<'a>(
530 pub fn get_inner_mut<'a>(
531 &'a self,
531 &'a self,
532 py: Python<'a>,
532 py: Python<'a>,
533 ) -> Ref<'a, Box<dyn DirstateMapMethods + Send>> {
533 ) -> RefMut<'a, Box<dyn DirstateMapMethods + Send>> {
534 self.inner(py).borrow()
534 self.inner(py).borrow_mut()
535 }
535 }
536 fn translate_key(
536 fn translate_key(
537 py: Python,
537 py: Python,
@@ -112,7 +112,7 b' pub fn status_wrapper('
112 let root_dir = get_path_from_bytes(bytes.data(py));
112 let root_dir = get_path_from_bytes(bytes.data(py));
113
113
114 let dmap: DirstateMap = dmap.to_py_object(py);
114 let dmap: DirstateMap = dmap.to_py_object(py);
115 let dmap = dmap.get_inner(py);
115 let mut dmap = dmap.get_inner_mut(py);
116
116
117 let ignore_files: PyResult<Vec<_>> = ignore_files
117 let ignore_files: PyResult<Vec<_>> = ignore_files
118 .iter(py)
118 .iter(py)
General Comments 0
You need to be logged in to leave comments. Login now