##// END OF EJS Templates
rust: Use `&HgPath` instead of `&HgPathBuf` in may APIs...
Simon Sapin -
r47894:cd8ca38f default
parent child Browse files
Show More
@@ -7,7 +7,8 b''
7
7
8 use crate::errors::HgError;
8 use crate::errors::HgError;
9 use crate::revlog::Node;
9 use crate::revlog::Node;
10 use crate::{utils::hg_path::HgPathBuf, FastHashMap};
10 use crate::utils::hg_path::{HgPath, HgPathBuf};
11 use crate::FastHashMap;
11 use bytes_cast::{unaligned, BytesCast};
12 use bytes_cast::{unaligned, BytesCast};
12 use std::convert::TryFrom;
13 use std::convert::TryFrom;
13
14
@@ -76,11 +77,11 b' pub const SIZE_FROM_OTHER_PARENT: i32 = '
76
77
77 pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
78 pub type StateMap = FastHashMap<HgPathBuf, DirstateEntry>;
78 pub type StateMapIter<'a> =
79 pub type StateMapIter<'a> =
79 Box<dyn Iterator<Item = (&'a HgPathBuf, &'a DirstateEntry)> + Send + 'a>;
80 Box<dyn Iterator<Item = (&'a HgPath, &'a DirstateEntry)> + Send + 'a>;
80
81
81 pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
82 pub type CopyMap = FastHashMap<HgPathBuf, HgPathBuf>;
82 pub type CopyMapIter<'a> =
83 pub type CopyMapIter<'a> =
83 Box<dyn Iterator<Item = (&'a HgPathBuf, &'a HgPathBuf)> + Send + 'a>;
84 Box<dyn Iterator<Item = (&'a HgPath, &'a HgPath)> + Send + 'a>;
84
85
85 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
86 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
86 pub enum EntryState {
87 pub enum EntryState {
@@ -30,17 +30,22 b' impl DirsMultiset {'
30 /// Initializes the multiset from a dirstate.
30 /// Initializes the multiset from a dirstate.
31 ///
31 ///
32 /// If `skip_state` is provided, skips dirstate entries with equal state.
32 /// If `skip_state` is provided, skips dirstate entries with equal state.
33 pub fn from_dirstate<'a>(
33 pub fn from_dirstate<'a, I, P>(
34 dirstate: impl IntoIterator<Item = (&'a HgPathBuf, &'a DirstateEntry)>,
34 dirstate: I,
35 skip_state: Option<EntryState>,
35 skip_state: Option<EntryState>,
36 ) -> Result<Self, DirstateMapError> {
36 ) -> Result<Self, DirstateMapError>
37 where
38 I: IntoIterator<Item = (P, &'a DirstateEntry)>,
39 P: AsRef<HgPath>,
40 {
37 let mut multiset = DirsMultiset {
41 let mut multiset = DirsMultiset {
38 inner: FastHashMap::default(),
42 inner: FastHashMap::default(),
39 };
43 };
40 for (filename, DirstateEntry { state, .. }) in dirstate {
44 for (filename, entry) in dirstate {
45 let filename = filename.as_ref();
41 // This `if` is optimized out of the loop
46 // This `if` is optimized out of the loop
42 if let Some(skip) = skip_state {
47 if let Some(skip) = skip_state {
43 if skip != *state {
48 if skip != entry.state {
44 multiset.add_path(filename)?;
49 multiset.add_path(filename)?;
45 }
50 }
46 } else {
51 } else {
@@ -260,7 +260,7 b' impl DirstateMap {'
260 pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> {
260 pub fn set_dirs(&mut self) -> Result<(), DirstateMapError> {
261 if self.dirs.is_none() {
261 if self.dirs.is_none() {
262 self.dirs = Some(DirsMultiset::from_dirstate(
262 self.dirs = Some(DirsMultiset::from_dirstate(
263 &self.state_map,
263 self.state_map.iter(),
264 Some(EntryState::Removed),
264 Some(EntryState::Removed),
265 )?);
265 )?);
266 }
266 }
@@ -4,7 +4,7 b''
4 // GNU General Public License version 2 or any later version.
4 // GNU General Public License version 2 or any later version.
5
5
6 use crate::errors::HgError;
6 use crate::errors::HgError;
7 use crate::utils::hg_path::{HgPath, HgPathBuf};
7 use crate::utils::hg_path::HgPath;
8 use crate::{
8 use crate::{
9 dirstate::{CopyMap, EntryState, RawEntry, StateMap},
9 dirstate::{CopyMap, EntryState, RawEntry, StateMap},
10 DirstateEntry, DirstateParents,
10 DirstateEntry, DirstateParents,
@@ -83,8 +83,8 b" pub fn parse_dirstate_entries<'a>("
83 }
83 }
84
84
85 fn packed_filename_and_copy_source_size(
85 fn packed_filename_and_copy_source_size(
86 filename: &HgPathBuf,
86 filename: &HgPath,
87 copy_source: Option<&HgPathBuf>,
87 copy_source: Option<&HgPath>,
88 ) -> usize {
88 ) -> usize {
89 filename.len()
89 filename.len()
90 + if let Some(source) = copy_source {
90 + if let Some(source) = copy_source {
@@ -95,17 +95,17 b' fn packed_filename_and_copy_source_size('
95 }
95 }
96
96
97 pub fn packed_entry_size(
97 pub fn packed_entry_size(
98 filename: &HgPathBuf,
98 filename: &HgPath,
99 copy_source: Option<&HgPathBuf>,
99 copy_source: Option<&HgPath>,
100 ) -> usize {
100 ) -> usize {
101 MIN_ENTRY_SIZE
101 MIN_ENTRY_SIZE
102 + packed_filename_and_copy_source_size(filename, copy_source)
102 + packed_filename_and_copy_source_size(filename, copy_source)
103 }
103 }
104
104
105 pub fn pack_entry(
105 pub fn pack_entry(
106 filename: &HgPathBuf,
106 filename: &HgPath,
107 entry: &DirstateEntry,
107 entry: &DirstateEntry,
108 copy_source: Option<&HgPathBuf>,
108 copy_source: Option<&HgPath>,
109 packed: &mut Vec<u8>,
109 packed: &mut Vec<u8>,
110 ) {
110 ) {
111 let length = packed_filename_and_copy_source_size(filename, copy_source);
111 let length = packed_filename_and_copy_source_size(filename, copy_source);
@@ -159,7 +159,7 b' pub fn pack_dirstate('
159 let expected_size: usize = state_map
159 let expected_size: usize = state_map
160 .iter()
160 .iter()
161 .map(|(filename, _)| {
161 .map(|(filename, _)| {
162 packed_entry_size(filename, copy_map.get(filename))
162 packed_entry_size(filename, copy_map.get(filename).map(|p| &**p))
163 })
163 })
164 .sum();
164 .sum();
165 let expected_size = expected_size + PARENT_SIZE * 2;
165 let expected_size = expected_size + PARENT_SIZE * 2;
@@ -171,7 +171,12 b' pub fn pack_dirstate('
171
171
172 for (filename, entry) in state_map.iter_mut() {
172 for (filename, entry) in state_map.iter_mut() {
173 clear_ambiguous_mtime(entry, now);
173 clear_ambiguous_mtime(entry, now);
174 pack_entry(filename, entry, copy_map.get(filename), &mut packed)
174 pack_entry(
175 filename,
176 entry,
177 copy_map.get(filename).map(|p| &**p),
178 &mut packed,
179 )
175 }
180 }
176
181
177 if packed.len() != expected_size {
182 if packed.len() != expected_size {
@@ -67,7 +67,7 b' impl Node {'
67
67
68 /// `(full_path, entry, copy_source)`
68 /// `(full_path, entry, copy_source)`
69 type NodeDataMut<'a> = (
69 type NodeDataMut<'a> = (
70 &'a WithBasename<HgPathBuf>,
70 &'a HgPath,
71 &'a mut Option<DirstateEntry>,
71 &'a mut Option<DirstateEntry>,
72 &'a mut Option<HgPathBuf>,
72 &'a mut Option<HgPathBuf>,
73 );
73 );
@@ -248,8 +248,7 b" impl<'on_disk> DirstateMap<'on_disk> {"
248
248
249 fn iter_nodes<'a>(
249 fn iter_nodes<'a>(
250 &'a self,
250 &'a self,
251 ) -> impl Iterator<Item = (&'a WithBasename<HgPathBuf>, &'a Node)> + 'a
251 ) -> impl Iterator<Item = (&'a HgPath, &'a Node)> + 'a {
252 {
253 // Depth first tree traversal.
252 // Depth first tree traversal.
254 //
253 //
255 // If we could afford internal iteration and recursion,
254 // If we could afford internal iteration and recursion,
@@ -276,6 +275,7 b" impl<'on_disk> DirstateMap<'on_disk> {"
276 // Pseudo-recursion
275 // Pseudo-recursion
277 let new_iter = child_node.children.iter();
276 let new_iter = child_node.children.iter();
278 let old_iter = std::mem::replace(&mut iter, new_iter);
277 let old_iter = std::mem::replace(&mut iter, new_iter);
278 let key = &**key.full_path();
279 stack.push((key, child_node, old_iter));
279 stack.push((key, child_node, old_iter));
280 }
280 }
281 // Found the end of a `children.iter()` iterator.
281 // Found the end of a `children.iter()` iterator.
@@ -307,8 +307,11 b" impl<'on_disk> DirstateMap<'on_disk> {"
307 std::iter::from_fn(move || {
307 std::iter::from_fn(move || {
308 while let Some((key, child_node)) = iter.next() {
308 while let Some((key, child_node)) = iter.next() {
309 // Pseudo-recursion
309 // Pseudo-recursion
310 let data =
310 let data = (
311 (key, &mut child_node.entry, &mut child_node.copy_source);
311 &**key.full_path(),
312 &mut child_node.entry,
313 &mut child_node.copy_source,
314 );
312 let new_iter = child_node.children.iter_mut();
315 let new_iter = child_node.children.iter_mut();
313 let old_iter = std::mem::replace(&mut iter, new_iter);
316 let old_iter = std::mem::replace(&mut iter, new_iter);
314 stack.push((data, old_iter));
317 stack.push((data, old_iter));
@@ -421,14 +424,14 b" impl<'on_disk> super::dispatch::Dirstate"
421
424
422 fn non_normal_or_other_parent_paths(
425 fn non_normal_or_other_parent_paths(
423 &mut self,
426 &mut self,
424 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_> {
427 ) -> Box<dyn Iterator<Item = &HgPath> + '_> {
425 Box::new(self.iter_nodes().filter_map(|(path, node)| {
428 Box::new(self.iter_nodes().filter_map(|(path, node)| {
426 node.entry
429 node.entry
427 .as_ref()
430 .as_ref()
428 .filter(|entry| {
431 .filter(|entry| {
429 entry.is_non_normal() || entry.is_from_other_parent()
432 entry.is_non_normal() || entry.is_from_other_parent()
430 })
433 })
431 .map(|_| path.full_path())
434 .map(|_| path)
432 }))
435 }))
433 }
436 }
434
437
@@ -439,29 +442,29 b" impl<'on_disk> super::dispatch::Dirstate"
439
442
440 fn iter_non_normal_paths(
443 fn iter_non_normal_paths(
441 &mut self,
444 &mut self,
442 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
445 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
443 self.iter_non_normal_paths_panic()
446 self.iter_non_normal_paths_panic()
444 }
447 }
445
448
446 fn iter_non_normal_paths_panic(
449 fn iter_non_normal_paths_panic(
447 &self,
450 &self,
448 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
451 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
449 Box::new(self.iter_nodes().filter_map(|(path, node)| {
452 Box::new(self.iter_nodes().filter_map(|(path, node)| {
450 node.entry
453 node.entry
451 .as_ref()
454 .as_ref()
452 .filter(|entry| entry.is_non_normal())
455 .filter(|entry| entry.is_non_normal())
453 .map(|_| path.full_path())
456 .map(|_| path)
454 }))
457 }))
455 }
458 }
456
459
457 fn iter_other_parent_paths(
460 fn iter_other_parent_paths(
458 &mut self,
461 &mut self,
459 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
462 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
460 Box::new(self.iter_nodes().filter_map(|(path, node)| {
463 Box::new(self.iter_nodes().filter_map(|(path, node)| {
461 node.entry
464 node.entry
462 .as_ref()
465 .as_ref()
463 .filter(|entry| entry.is_from_other_parent())
466 .filter(|entry| entry.is_from_other_parent())
464 .map(|_| path.full_path())
467 .map(|_| path)
465 }))
468 }))
466 }
469 }
467
470
@@ -502,8 +505,8 b" impl<'on_disk> super::dispatch::Dirstate"
502 for (path, node) in self.iter_nodes() {
505 for (path, node) in self.iter_nodes() {
503 if node.entry.is_some() {
506 if node.entry.is_some() {
504 size += packed_entry_size(
507 size += packed_entry_size(
505 path.full_path(),
508 path,
506 node.copy_source.as_ref(),
509 node.copy_source.as_ref().map(|p| &**p),
507 )
510 )
508 }
511 }
509 }
512 }
@@ -516,9 +519,9 b" impl<'on_disk> super::dispatch::Dirstate"
516 if let Some(entry) = opt_entry {
519 if let Some(entry) = opt_entry {
517 clear_ambiguous_mtime(entry, now);
520 clear_ambiguous_mtime(entry, now);
518 pack_entry(
521 pack_entry(
519 path.full_path(),
522 path,
520 entry,
523 entry,
521 copy_source.as_ref(),
524 copy_source.as_ref().map(|p| &**p),
522 &mut packed,
525 &mut packed,
523 );
526 );
524 }
527 }
@@ -557,7 +560,7 b" impl<'on_disk> super::dispatch::Dirstate"
557 Box::new(self.iter_nodes().filter_map(|(path, node)| {
560 Box::new(self.iter_nodes().filter_map(|(path, node)| {
558 node.copy_source
561 node.copy_source
559 .as_ref()
562 .as_ref()
560 .map(|copy_source| (path.full_path(), copy_source))
563 .map(|copy_source| (path, &**copy_source))
561 }))
564 }))
562 }
565 }
563
566
@@ -569,8 +572,8 b" impl<'on_disk> super::dispatch::Dirstate"
569 }
572 }
570 }
573 }
571
574
572 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> {
575 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPath> {
573 self.get_node(key)?.copy_source.as_ref()
576 self.get_node(key)?.copy_source.as_ref().map(|p| &**p)
574 }
577 }
575
578
576 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf> {
579 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf> {
@@ -609,7 +612,7 b" impl<'on_disk> super::dispatch::Dirstate"
609
612
610 fn iter(&self) -> StateMapIter<'_> {
613 fn iter(&self) -> StateMapIter<'_> {
611 Box::new(self.iter_nodes().filter_map(|(path, node)| {
614 Box::new(self.iter_nodes().filter_map(|(path, node)| {
612 node.entry.as_ref().map(|entry| (path.full_path(), entry))
615 node.entry.as_ref().map(|entry| (path, entry))
613 }))
616 }))
614 }
617 }
615 }
618 }
@@ -47,21 +47,21 b' pub trait DirstateMapMethods {'
47
47
48 fn non_normal_or_other_parent_paths(
48 fn non_normal_or_other_parent_paths(
49 &mut self,
49 &mut self,
50 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_>;
50 ) -> Box<dyn Iterator<Item = &HgPath> + '_>;
51
51
52 fn set_non_normal_other_parent_entries(&mut self, force: bool);
52 fn set_non_normal_other_parent_entries(&mut self, force: bool);
53
53
54 fn iter_non_normal_paths(
54 fn iter_non_normal_paths(
55 &mut self,
55 &mut self,
56 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>;
56 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_>;
57
57
58 fn iter_non_normal_paths_panic(
58 fn iter_non_normal_paths_panic(
59 &self,
59 &self,
60 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>;
60 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_>;
61
61
62 fn iter_other_parent_paths(
62 fn iter_other_parent_paths(
63 &mut self,
63 &mut self,
64 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_>;
64 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_>;
65
65
66 fn has_tracked_dir(
66 fn has_tracked_dir(
67 &mut self,
67 &mut self,
@@ -97,7 +97,7 b' pub trait DirstateMapMethods {'
97
97
98 fn copy_map_contains_key(&self, key: &HgPath) -> bool;
98 fn copy_map_contains_key(&self, key: &HgPath) -> bool;
99
99
100 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf>;
100 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPath>;
101
101
102 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf>;
102 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf>;
103
103
@@ -163,10 +163,10 b' impl DirstateMapMethods for DirstateMap '
163
163
164 fn non_normal_or_other_parent_paths(
164 fn non_normal_or_other_parent_paths(
165 &mut self,
165 &mut self,
166 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_> {
166 ) -> Box<dyn Iterator<Item = &HgPath> + '_> {
167 let (non_normal, other_parent) =
167 let (non_normal, other_parent) =
168 self.get_non_normal_other_parent_entries();
168 self.get_non_normal_other_parent_entries();
169 Box::new(non_normal.union(other_parent))
169 Box::new(non_normal.union(other_parent).map(|p| &**p))
170 }
170 }
171
171
172 fn set_non_normal_other_parent_entries(&mut self, force: bool) {
172 fn set_non_normal_other_parent_entries(&mut self, force: bool) {
@@ -175,26 +175,26 b' impl DirstateMapMethods for DirstateMap '
175
175
176 fn iter_non_normal_paths(
176 fn iter_non_normal_paths(
177 &mut self,
177 &mut self,
178 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
178 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
179 let (non_normal, _other_parent) =
179 let (non_normal, _other_parent) =
180 self.get_non_normal_other_parent_entries();
180 self.get_non_normal_other_parent_entries();
181 Box::new(non_normal.iter())
181 Box::new(non_normal.iter().map(|p| &**p))
182 }
182 }
183
183
184 fn iter_non_normal_paths_panic(
184 fn iter_non_normal_paths_panic(
185 &self,
185 &self,
186 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
186 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
187 let (non_normal, _other_parent) =
187 let (non_normal, _other_parent) =
188 self.get_non_normal_other_parent_entries_panic();
188 self.get_non_normal_other_parent_entries_panic();
189 Box::new(non_normal.iter())
189 Box::new(non_normal.iter().map(|p| &**p))
190 }
190 }
191
191
192 fn iter_other_parent_paths(
192 fn iter_other_parent_paths(
193 &mut self,
193 &mut self,
194 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
194 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
195 let (_non_normal, other_parent) =
195 let (_non_normal, other_parent) =
196 self.get_non_normal_other_parent_entries();
196 self.get_non_normal_other_parent_entries();
197 Box::new(other_parent.iter())
197 Box::new(other_parent.iter().map(|p| &**p))
198 }
198 }
199
199
200 fn has_tracked_dir(
200 fn has_tracked_dir(
@@ -243,15 +243,15 b' impl DirstateMapMethods for DirstateMap '
243 }
243 }
244
244
245 fn copy_map_iter(&self) -> CopyMapIter<'_> {
245 fn copy_map_iter(&self) -> CopyMapIter<'_> {
246 Box::new(self.copy_map.iter())
246 Box::new(self.copy_map.iter().map(|(key, value)| (&**key, &**value)))
247 }
247 }
248
248
249 fn copy_map_contains_key(&self, key: &HgPath) -> bool {
249 fn copy_map_contains_key(&self, key: &HgPath) -> bool {
250 self.copy_map.contains_key(key)
250 self.copy_map.contains_key(key)
251 }
251 }
252
252
253 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> {
253 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPath> {
254 self.copy_map.get(key)
254 self.copy_map.get(key).map(|p| &**p)
255 }
255 }
256
256
257 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf> {
257 fn copy_map_remove(&mut self, key: &HgPath) -> Option<HgPathBuf> {
@@ -279,6 +279,6 b' impl DirstateMapMethods for DirstateMap '
279 }
279 }
280
280
281 fn iter(&self) -> StateMapIter<'_> {
281 fn iter(&self) -> StateMapIter<'_> {
282 Box::new((&**self).iter())
282 Box::new((&**self).iter().map(|(key, value)| (&**key, value)))
283 }
283 }
284 }
284 }
@@ -14,7 +14,8 b' use cpython::{'
14 use std::cell::RefCell;
14 use std::cell::RefCell;
15
15
16 use crate::dirstate::dirstate_map::DirstateMap;
16 use crate::dirstate::dirstate_map::DirstateMap;
17 use hg::{utils::hg_path::HgPathBuf, CopyMapIter};
17 use hg::utils::hg_path::HgPath;
18 use hg::CopyMapIter;
18
19
19 py_class!(pub class CopyMap |py| {
20 py_class!(pub class CopyMap |py| {
20 data dirstate_map: DirstateMap;
21 data dirstate_map: DirstateMap;
@@ -87,13 +88,13 b' impl CopyMap {'
87 }
88 }
88 fn translate_key(
89 fn translate_key(
89 py: Python,
90 py: Python,
90 res: (&HgPathBuf, &HgPathBuf),
91 res: (&HgPath, &HgPath),
91 ) -> PyResult<Option<PyBytes>> {
92 ) -> PyResult<Option<PyBytes>> {
92 Ok(Some(PyBytes::new(py, res.0.as_bytes())))
93 Ok(Some(PyBytes::new(py, res.0.as_bytes())))
93 }
94 }
94 fn translate_key_value(
95 fn translate_key_value(
95 py: Python,
96 py: Python,
96 res: (&HgPathBuf, &HgPathBuf),
97 res: (&HgPath, &HgPath),
97 ) -> PyResult<Option<(PyBytes, PyBytes)>> {
98 ) -> PyResult<Option<(PyBytes, PyBytes)>> {
98 let (k, v) = res;
99 let (k, v) = res;
99 Ok(Some((
100 Ok(Some((
@@ -514,13 +514,13 b' impl DirstateMap {'
514 }
514 }
515 fn translate_key(
515 fn translate_key(
516 py: Python,
516 py: Python,
517 res: (&HgPathBuf, &DirstateEntry),
517 res: (&HgPath, &DirstateEntry),
518 ) -> PyResult<Option<PyBytes>> {
518 ) -> PyResult<Option<PyBytes>> {
519 Ok(Some(PyBytes::new(py, res.0.as_bytes())))
519 Ok(Some(PyBytes::new(py, res.0.as_bytes())))
520 }
520 }
521 fn translate_key_value(
521 fn translate_key_value(
522 py: Python,
522 py: Python,
523 res: (&HgPathBuf, &DirstateEntry),
523 res: (&HgPath, &DirstateEntry),
524 ) -> PyResult<Option<(PyBytes, PyObject)>> {
524 ) -> PyResult<Option<(PyBytes, PyObject)>> {
525 let (f, entry) = res;
525 let (f, entry) = res;
526 Ok(Some((
526 Ok(Some((
@@ -61,7 +61,7 b' impl DirstateMapMethods for OwningDirsta'
61
61
62 fn non_normal_or_other_parent_paths(
62 fn non_normal_or_other_parent_paths(
63 &mut self,
63 &mut self,
64 ) -> Box<dyn Iterator<Item = &HgPathBuf> + '_> {
64 ) -> Box<dyn Iterator<Item = &HgPath> + '_> {
65 self.get_mut().non_normal_or_other_parent_paths()
65 self.get_mut().non_normal_or_other_parent_paths()
66 }
66 }
67
67
@@ -71,19 +71,19 b' impl DirstateMapMethods for OwningDirsta'
71
71
72 fn iter_non_normal_paths(
72 fn iter_non_normal_paths(
73 &mut self,
73 &mut self,
74 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
74 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
75 self.get_mut().iter_non_normal_paths()
75 self.get_mut().iter_non_normal_paths()
76 }
76 }
77
77
78 fn iter_non_normal_paths_panic(
78 fn iter_non_normal_paths_panic(
79 &self,
79 &self,
80 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
80 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
81 self.get().iter_non_normal_paths_panic()
81 self.get().iter_non_normal_paths_panic()
82 }
82 }
83
83
84 fn iter_other_parent_paths(
84 fn iter_other_parent_paths(
85 &mut self,
85 &mut self,
86 ) -> Box<dyn Iterator<Item = &HgPathBuf> + Send + '_> {
86 ) -> Box<dyn Iterator<Item = &HgPath> + Send + '_> {
87 self.get_mut().iter_other_parent_paths()
87 self.get_mut().iter_other_parent_paths()
88 }
88 }
89
89
@@ -141,7 +141,7 b' impl DirstateMapMethods for OwningDirsta'
141 self.get().copy_map_contains_key(key)
141 self.get().copy_map_contains_key(key)
142 }
142 }
143
143
144 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPathBuf> {
144 fn copy_map_get(&self, key: &HgPath) -> Option<&HgPath> {
145 self.get().copy_map_get(key)
145 self.get().copy_map_get(key)
146 }
146 }
147
147
@@ -12,7 +12,7 b' use cpython::{'
12 };
12 };
13
13
14 use crate::dirstate::DirstateMap;
14 use crate::dirstate::DirstateMap;
15 use hg::utils::hg_path::HgPathBuf;
15 use hg::utils::hg_path::HgPath;
16 use std::cell::RefCell;
16 use std::cell::RefCell;
17
17
18 py_class!(pub class NonNormalEntries |py| {
18 py_class!(pub class NonNormalEntries |py| {
@@ -54,16 +54,13 b' impl NonNormalEntries {'
54 Ok(true)
54 Ok(true)
55 }
55 }
56
56
57 fn translate_key(
57 fn translate_key(py: Python, key: &HgPath) -> PyResult<Option<PyBytes>> {
58 py: Python,
59 key: &HgPathBuf,
60 ) -> PyResult<Option<PyBytes>> {
61 Ok(Some(PyBytes::new(py, key.as_bytes())))
58 Ok(Some(PyBytes::new(py, key.as_bytes())))
62 }
59 }
63 }
60 }
64
61
65 type NonNormalEntriesIter<'a> =
62 type NonNormalEntriesIter<'a> =
66 Box<dyn Iterator<Item = &'a HgPathBuf> + Send + 'a>;
63 Box<dyn Iterator<Item = &'a HgPath> + Send + 'a>;
67
64
68 py_shared_iterator!(
65 py_shared_iterator!(
69 NonNormalEntriesIterator,
66 NonNormalEntriesIterator,
General Comments 0
You need to be logged in to leave comments. Login now