Let's use the new API.
Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
| No Linters Available |
| No Unit Test Coverage |
| Path | Packages | |||
|---|---|---|---|---|
| M | rust/hg-core/src/dirstate/dirs_multiset.rs (5 lines) |
| Commit | Parents | Author | Summary | Date |
|---|---|---|---|---|
| 2e66c371b80e | a4308ec870a8 | Raphaël Gomès | Tue, Apr 12, 11:27 AM |
| Status | Author | Revision | |
|---|---|---|---|
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare | ||
| Needs Review | Alphare |
| // dirs_multiset.rs | // dirs_multiset.rs | ||||
| // | // | ||||
| // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> | // Copyright 2019 Raphaël Gomès <rgomes@octobus.net> | ||||
| // | // | ||||
| // This software may be used and distributed according to the terms of the | // This software may be used and distributed according to the terms of the | ||||
| // GNU General Public License version 2 or any later version. | // GNU General Public License version 2 or any later version. | ||||
| //! A multiset of directory names. | //! A multiset of directory names. | ||||
| //! | //! | ||||
| //! Used to counts the references to directories in a manifest or dirstate. | //! Used to counts the references to directories in a manifest or dirstate. | ||||
| use crate::dirstate_tree::on_disk::DirstateV2ParseError; | use crate::dirstate_tree::on_disk::DirstateV2ParseError; | ||||
| use crate::{ | use crate::{ | ||||
| dirstate::EntryState, | |||||
| utils::{ | utils::{ | ||||
| files, | files, | ||||
| hg_path::{HgPath, HgPathBuf, HgPathError}, | hg_path::{HgPath, HgPathBuf, HgPathError}, | ||||
| }, | }, | ||||
| DirstateEntry, DirstateError, DirstateMapError, FastHashMap, | DirstateEntry, DirstateError, DirstateMapError, FastHashMap, | ||||
| }; | }; | ||||
| use std::collections::{hash_map, hash_map::Entry, HashMap, HashSet}; | use std::collections::{hash_map, hash_map::Entry, HashMap, HashSet}; | ||||
| let mut multiset = DirsMultiset { | let mut multiset = DirsMultiset { | ||||
| inner: FastHashMap::default(), | inner: FastHashMap::default(), | ||||
| }; | }; | ||||
| for item in dirstate { | for item in dirstate { | ||||
| let (filename, entry) = item?; | let (filename, entry) = item?; | ||||
| let filename = filename.as_ref(); | let filename = filename.as_ref(); | ||||
| // This `if` is optimized out of the loop | // This `if` is optimized out of the loop | ||||
| if only_tracked { | if only_tracked { | ||||
| if entry.state() != EntryState::Removed { | if !entry.removed() { | ||||
| multiset.add_path(filename)?; | multiset.add_path(filename)?; | ||||
| } | } | ||||
| } else { | } else { | ||||
| multiset.add_path(filename)?; | multiset.add_path(filename)?; | ||||
| } | } | ||||
| } | } | ||||
| Ok(multiset) | Ok(multiset) | ||||
| path: impl AsRef<HgPath>, | path: impl AsRef<HgPath>, | ||||
| ) -> Option<&HashSet<&'a HgPath>> { | ) -> Option<&HashSet<&'a HgPath>> { | ||||
| self.inner.get(path.as_ref()) | self.inner.get(path.as_ref()) | ||||
| } | } | ||||
| } | } | ||||
| #[cfg(test)] | #[cfg(test)] | ||||
| mod tests { | mod tests { | ||||
| use crate::EntryState; | |||||
| use super::*; | use super::*; | ||||
| #[test] | #[test] | ||||
| fn test_delete_path_path_not_found() { | fn test_delete_path_path_not_found() { | ||||
| let manifest: Vec<HgPathBuf> = vec![]; | let manifest: Vec<HgPathBuf> = vec![]; | ||||
| let mut map = DirsMultiset::from_manifest(&manifest).unwrap(); | let mut map = DirsMultiset::from_manifest(&manifest).unwrap(); | ||||
| let path = HgPathBuf::from_bytes(b"doesnotexist/"); | let path = HgPathBuf::from_bytes(b"doesnotexist/"); | ||||
| assert_eq!( | assert_eq!( | ||||