##// END OF EJS Templates
rust: run a clippy pass with the latest stable version...
Raphaël Gomès -
r52013:532e74ad default
parent child Browse files
Show More
@@ -107,7 +107,7 b' impl ConfigLayer {'
107 ) {
107 ) {
108 self.sections
108 self.sections
109 .entry(section)
109 .entry(section)
110 .or_insert_with(HashMap::new)
110 .or_default()
111 .insert(item, ConfigValue { bytes: value, line });
111 .insert(item, ConfigValue { bytes: value, line });
112 }
112 }
113
113
@@ -178,7 +178,7 b' impl ConfigLayer {'
178 .expect("Path::parent fail on a file we’ve read");
178 .expect("Path::parent fail on a file we’ve read");
179 // `Path::join` with an absolute argument correctly ignores the
179 // `Path::join` with an absolute argument correctly ignores the
180 // base path
180 // base path
181 let filename = dir.join(&get_path_from_bytes(&filename_bytes));
181 let filename = dir.join(get_path_from_bytes(&filename_bytes));
182 match std::fs::read(&filename) {
182 match std::fs::read(&filename) {
183 Ok(data) => {
183 Ok(data) => {
184 layers.push(current_layer);
184 layers.push(current_layer);
@@ -758,7 +758,7 b' mod tests {'
758 let tmpdir = tempfile::tempdir().unwrap();
758 let tmpdir = tempfile::tempdir().unwrap();
759 let tmpdir_path = tmpdir.path();
759 let tmpdir_path = tmpdir.path();
760 let mut included_file =
760 let mut included_file =
761 File::create(&tmpdir_path.join("included.rc")).unwrap();
761 File::create(tmpdir_path.join("included.rc")).unwrap();
762
762
763 included_file.write_all(b"[section]\nitem=value1").unwrap();
763 included_file.write_all(b"[section]\nitem=value1").unwrap();
764 let base_config_path = tmpdir_path.join("base.rc");
764 let base_config_path = tmpdir_path.join("base.rc");
@@ -205,8 +205,7 b' mod tests {'
205 graph: &impl Graph,
205 graph: &impl Graph,
206 revs: &[BaseRevision],
206 revs: &[BaseRevision],
207 ) -> Result<Vec<Revision>, GraphError> {
207 ) -> Result<Vec<Revision>, GraphError> {
208 let iter_revs: Vec<_> =
208 let iter_revs: Vec<_> = revs.iter().cloned().map(Revision).collect();
209 revs.into_iter().cloned().map(Revision).collect();
210 let heads = heads(graph, iter_revs.iter())?;
209 let heads = heads(graph, iter_revs.iter())?;
211 let mut as_vec: Vec<Revision> = heads.iter().cloned().collect();
210 let mut as_vec: Vec<Revision> = heads.iter().cloned().collect();
212 as_vec.sort_unstable();
211 as_vec.sort_unstable();
@@ -178,7 +178,7 b" impl<'on_disk> ChildNodes<'on_disk> {"
178 ChildNodes::InMemory(nodes) => Ok(nodes),
178 ChildNodes::InMemory(nodes) => Ok(nodes),
179 ChildNodes::OnDisk(nodes) => {
179 ChildNodes::OnDisk(nodes) => {
180 *unreachable_bytes +=
180 *unreachable_bytes +=
181 std::mem::size_of_val::<[on_disk::Node]>(nodes) as u32;
181 std::mem::size_of_val::<[on_disk::Node]>(*nodes) as u32;
182 let nodes = nodes
182 let nodes = nodes
183 .iter()
183 .iter()
184 .map(|node| {
184 .map(|node| {
@@ -764,7 +764,7 b" impl<'on_disk> DirstateMap<'on_disk> {"
764 ) -> Result<bool, DirstateV2ParseError> {
764 ) -> Result<bool, DirstateV2ParseError> {
765 let was_tracked = old_entry_opt.map_or(false, |e| e.tracked());
765 let was_tracked = old_entry_opt.map_or(false, |e| e.tracked());
766 let had_entry = old_entry_opt.is_some();
766 let had_entry = old_entry_opt.is_some();
767 let tracked_count_increment = if was_tracked { 0 } else { 1 };
767 let tracked_count_increment = u32::from(!was_tracked);
768 let mut new = false;
768 let mut new = false;
769
769
770 let node = self.get_or_insert_node(filename, |ancestor| {
770 let node = self.get_or_insert_node(filename, |ancestor| {
@@ -249,7 +249,7 b" impl<'a> HasIgnoredAncestor<'a> {"
249 }
249 }
250 }
250 }
251
251
252 fn force<'b>(&self, ignore_fn: &IgnoreFnType<'b>) -> bool {
252 fn force(&self, ignore_fn: &IgnoreFnType<'_>) -> bool {
253 match self.parent {
253 match self.parent {
254 None => false,
254 None => false,
255 Some(parent) => {
255 Some(parent) => {
@@ -332,7 +332,7 b' impl<G: Graph + Clone> PartialDiscovery<'
332 FastHashMap::default();
332 FastHashMap::default();
333 for &rev in self.undecided.as_ref().unwrap() {
333 for &rev in self.undecided.as_ref().unwrap() {
334 for p in ParentsIterator::graph_parents(&self.graph, rev)? {
334 for p in ParentsIterator::graph_parents(&self.graph, rev)? {
335 children.entry(p).or_insert_with(Vec::new).push(rev);
335 children.entry(p).or_default().push(rev);
336 }
336 }
337 }
337 }
338 self.children_cache = Some(children);
338 self.children_cache = Some(children);
@@ -695,7 +695,7 b' mod tests {'
695 #[test]
695 #[test]
696 fn test_bidirectional_sample() -> Result<(), GraphError> {
696 fn test_bidirectional_sample() -> Result<(), GraphError> {
697 let mut disco = full_disco();
697 let mut disco = full_disco();
698 disco.undecided = Some((0..=13).into_iter().map(Revision).collect());
698 disco.undecided = Some((0..=13).map(Revision).collect());
699
699
700 let (sample_set, size) = disco.bidirectional_sample(7)?;
700 let (sample_set, size) = disco.bidirectional_sample(7)?;
701 assert_eq!(size, 7);
701 assert_eq!(size, 7);
@@ -629,8 +629,7 b' impl SubInclude {'
629 normalize_path_bytes(&get_bytes_from_path(source));
629 normalize_path_bytes(&get_bytes_from_path(source));
630
630
631 let source_root = get_path_from_bytes(&normalized_source);
631 let source_root = get_path_from_bytes(&normalized_source);
632 let source_root =
632 let source_root = source_root.parent().unwrap_or(source_root);
633 source_root.parent().unwrap_or_else(|| source_root.deref());
634
633
635 let path = source_root.join(get_path_from_bytes(pattern));
634 let path = source_root.join(get_path_from_bytes(pattern));
636 let new_root = path.parent().unwrap_or_else(|| path.deref());
635 let new_root = path.parent().unwrap_or_else(|| path.deref());
@@ -682,22 +681,21 b' mod tests {'
682 assert_eq!(escape_pattern(untouched), untouched.to_vec());
681 assert_eq!(escape_pattern(untouched), untouched.to_vec());
683 // All escape codes
682 // All escape codes
684 assert_eq!(
683 assert_eq!(
685 escape_pattern(br#"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"#),
684 escape_pattern(br"()[]{}?*+-|^$\\.&~#\t\n\r\v\f"),
686 br#"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f"#
685 br"\(\)\[\]\{\}\?\*\+\-\|\^\$\\\\\.\&\~\#\\t\\n\\r\\v\\f".to_vec()
687 .to_vec()
688 );
686 );
689 }
687 }
690
688
691 #[test]
689 #[test]
692 fn glob_test() {
690 fn glob_test() {
693 assert_eq!(glob_to_re(br#"?"#), br#"."#);
691 assert_eq!(glob_to_re(br"?"), br".");
694 assert_eq!(glob_to_re(br#"*"#), br#"[^/]*"#);
692 assert_eq!(glob_to_re(br"*"), br"[^/]*");
695 assert_eq!(glob_to_re(br#"**"#), br#".*"#);
693 assert_eq!(glob_to_re(br"**"), br".*");
696 assert_eq!(glob_to_re(br#"**/a"#), br#"(?:.*/)?a"#);
694 assert_eq!(glob_to_re(br"**/a"), br"(?:.*/)?a");
697 assert_eq!(glob_to_re(br#"a/**/b"#), br#"a/(?:.*/)?b"#);
695 assert_eq!(glob_to_re(br"a/**/b"), br"a/(?:.*/)?b");
698 assert_eq!(glob_to_re(br#"[a*?!^][^b][!c]"#), br#"[a*?!^][\^b][^c]"#);
696 assert_eq!(glob_to_re(br"[a*?!^][^b][!c]"), br"[a*?!^][\^b][^c]");
699 assert_eq!(glob_to_re(br#"{a,b}"#), br#"(?:a|b)"#);
697 assert_eq!(glob_to_re(br"{a,b}"), br"(?:a|b)");
700 assert_eq!(glob_to_re(br#".\*\?"#), br#"\.\*\?"#);
698 assert_eq!(glob_to_re(br".\*\?"), br"\.\*\?");
701 }
699 }
702
700
703 #[test]
701 #[test]
@@ -28,7 +28,6 b' use crate::dirstate::status::IgnoreFnTyp'
28 use crate::filepatterns::normalize_path_bytes;
28 use crate::filepatterns::normalize_path_bytes;
29 use std::collections::HashSet;
29 use std::collections::HashSet;
30 use std::fmt::{Display, Error, Formatter};
30 use std::fmt::{Display, Error, Formatter};
31 use std::ops::Deref;
32 use std::path::{Path, PathBuf};
31 use std::path::{Path, PathBuf};
33 use std::{borrow::ToOwned, collections::BTreeSet};
32 use std::{borrow::ToOwned, collections::BTreeSet};
34
33
@@ -183,7 +182,7 b' impl FileMatcher {'
183 pub fn new(files: Vec<HgPathBuf>) -> Result<Self, HgPathError> {
182 pub fn new(files: Vec<HgPathBuf>) -> Result<Self, HgPathError> {
184 let dirs = DirsMultiset::from_manifest(&files)?;
183 let dirs = DirsMultiset::from_manifest(&files)?;
185 Ok(Self {
184 Ok(Self {
186 files: HashSet::from_iter(files.into_iter()),
185 files: HashSet::from_iter(files),
187 dirs,
186 dirs,
188 sorted_visitchildrenset_candidates: OnceCell::new(),
187 sorted_visitchildrenset_candidates: OnceCell::new(),
189 })
188 })
@@ -316,7 +315,7 b" impl<'a> PatternMatcher<'a> {"
316 pub fn new(ignore_patterns: Vec<IgnorePattern>) -> PatternResult<Self> {
315 pub fn new(ignore_patterns: Vec<IgnorePattern>) -> PatternResult<Self> {
317 let (files, _) = roots_and_dirs(&ignore_patterns);
316 let (files, _) = roots_and_dirs(&ignore_patterns);
318 let dirs = DirsMultiset::from_manifest(&files)?;
317 let dirs = DirsMultiset::from_manifest(&files)?;
319 let files: HashSet<HgPathBuf> = HashSet::from_iter(files.into_iter());
318 let files: HashSet<HgPathBuf> = HashSet::from_iter(files);
320
319
321 let prefix = ignore_patterns.iter().all(|k| {
320 let prefix = ignore_patterns.iter().all(|k| {
322 matches!(k.syntax, PatternSyntax::Path | PatternSyntax::RelPath)
321 matches!(k.syntax, PatternSyntax::Path | PatternSyntax::RelPath)
@@ -773,10 +772,10 b' fn re_matcher(pattern: &[u8]) -> Pattern'
773
772
774 /// Returns the regex pattern and a function that matches an `HgPath` against
773 /// Returns the regex pattern and a function that matches an `HgPath` against
775 /// said regex formed by the given ignore patterns.
774 /// said regex formed by the given ignore patterns.
776 fn build_regex_match<'a, 'b>(
775 fn build_regex_match<'a>(
777 ignore_patterns: &'a [IgnorePattern],
776 ignore_patterns: &[IgnorePattern],
778 glob_suffix: &[u8],
777 glob_suffix: &[u8],
779 ) -> PatternResult<(Vec<u8>, IgnoreFnType<'b>)> {
778 ) -> PatternResult<(Vec<u8>, IgnoreFnType<'a>)> {
780 let mut regexps = vec![];
779 let mut regexps = vec![];
781 let mut exact_set = HashSet::new();
780 let mut exact_set = HashSet::new();
782
781
@@ -958,7 +957,7 b" fn build_match<'a>("
958 } else {
957 } else {
959 b"."
958 b"."
960 };
959 };
961 dirs.contains(dir.deref())
960 dirs.contains(dir)
962 };
961 };
963 match_funcs.push(Box::new(match_func));
962 match_funcs.push(Box::new(match_func));
964
963
@@ -686,7 +686,7 b' impl Repo {'
686 }
686 }
687 file.write_all(&data)?;
687 file.write_all(&data)?;
688 file.flush()?;
688 file.flush()?;
689 file.seek(SeekFrom::Current(0))
689 file.stream_position()
690 })()
690 })()
691 .when_writing_file(&data_filename)?;
691 .when_writing_file(&data_filename)?;
692
692
@@ -248,8 +248,8 b' impl Revlog {'
248 ) -> Result<Self, HgError> {
248 ) -> Result<Self, HgError> {
249 let index_path = index_path.as_ref();
249 let index_path = index_path.as_ref();
250 let index = {
250 let index = {
251 match store_vfs.mmap_open_opt(&index_path)? {
251 match store_vfs.mmap_open_opt(index_path)? {
252 None => Index::new(Box::new(vec![])),
252 None => Index::new(Box::<Vec<_>>::default()),
253 Some(index_mmap) => {
253 Some(index_mmap) => {
254 let index = Index::new(Box::new(index_mmap))?;
254 let index = Index::new(Box::new(index_mmap))?;
255 Ok(index)
255 Ok(index)
@@ -348,7 +348,7 b' mod tests {'
348 assert_eq!(Node::from_hex(SAMPLE_NODE_HEX).unwrap(), SAMPLE_NODE);
348 assert_eq!(Node::from_hex(SAMPLE_NODE_HEX).unwrap(), SAMPLE_NODE);
349 assert!(Node::from_hex(not_hex).is_err());
349 assert!(Node::from_hex(not_hex).is_err());
350 assert!(Node::from_hex(too_short).is_err());
350 assert!(Node::from_hex(too_short).is_err());
351 assert!(Node::from_hex(&too_long).is_err());
351 assert!(Node::from_hex(too_long).is_err());
352 }
352 }
353
353
354 #[test]
354 #[test]
@@ -656,7 +656,7 b' impl From<Vec<Block>> for NodeTree {'
656
656
657 impl fmt::Debug for NodeTree {
657 impl fmt::Debug for NodeTree {
658 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
658 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
659 let readonly: &[Block] = &*self.readonly;
659 let readonly: &[Block] = &self.readonly;
660 write!(
660 write!(
661 f,
661 f,
662 "readonly: {:?}, growable: {:?}, root: {:?}",
662 "readonly: {:?}, growable: {:?}, root: {:?}",
@@ -668,7 +668,7 b' impl fmt::Debug for NodeTree {'
668 impl Default for NodeTree {
668 impl Default for NodeTree {
669 /// Create a fully mutable empty NodeTree
669 /// Create a fully mutable empty NodeTree
670 fn default() -> Self {
670 fn default() -> Self {
671 NodeTree::new(Box::new(Vec::new()))
671 NodeTree::new(Box::<Vec<_>>::default())
672 }
672 }
673 }
673 }
674
674
@@ -775,7 +775,7 b' pub mod tests {'
775 /// strings for test data, and brings actual hash size independency.
775 /// strings for test data, and brings actual hash size independency.
776 #[cfg(test)]
776 #[cfg(test)]
777 fn pad_node(hex: &str) -> Node {
777 fn pad_node(hex: &str) -> Node {
778 Node::from_hex(&hex_pad_right(hex)).unwrap()
778 Node::from_hex(hex_pad_right(hex)).unwrap()
779 }
779 }
780
780
781 /// Pad hexadecimal Node prefix with zeros on the right, then insert
781 /// Pad hexadecimal Node prefix with zeros on the right, then insert
@@ -824,7 +824,7 b' pub mod tests {'
824 nt.find_node(&idx, idx.get(&1.into()).unwrap())?,
824 nt.find_node(&idx, idx.get(&1.into()).unwrap())?,
825 Some(R!(1))
825 Some(R!(1))
826 );
826 );
827 let unknown = Node::from_hex(&hex_pad_right("3d")).unwrap();
827 let unknown = Node::from_hex(hex_pad_right("3d")).unwrap();
828 assert_eq!(nt.find_node(&idx, &unknown)?, None);
828 assert_eq!(nt.find_node(&idx, &unknown)?, None);
829 Ok(())
829 Ok(())
830 }
830 }
@@ -900,7 +900,7 b' pub mod tests {'
900 hex: &str,
900 hex: &str,
901 ) -> Result<(), NodeMapError> {
901 ) -> Result<(), NodeMapError> {
902 let node = pad_node(hex);
902 let node = pad_node(hex);
903 return self.insert_node(rev, node);
903 self.insert_node(rev, node)
904 }
904 }
905
905
906 fn find_hex(
906 fn find_hex(
@@ -931,6 +931,12 b' pub mod tests {'
931 }
931 }
932 }
932 }
933
933
934 impl Default for TestNtIndex {
935 fn default() -> Self {
936 Self::new()
937 }
938 }
939
934 #[test]
940 #[test]
935 fn test_insert_full_mutable() -> Result<(), NodeMapError> {
941 fn test_insert_full_mutable() -> Result<(), NodeMapError> {
936 let mut idx = TestNtIndex::new();
942 let mut idx = TestNtIndex::new();
@@ -1003,7 +1009,7 b' pub mod tests {'
1003 let mut node1_hex = hex_pad_right("444444");
1009 let mut node1_hex = hex_pad_right("444444");
1004 node1_hex.pop();
1010 node1_hex.pop();
1005 node1_hex.push('5');
1011 node1_hex.push('5');
1006 let node0 = Node::from_hex(&node0_hex).unwrap();
1012 let node0 = Node::from_hex(node0_hex).unwrap();
1007 let node1 = Node::from_hex(&node1_hex).unwrap();
1013 let node1 = Node::from_hex(&node1_hex).unwrap();
1008
1014
1009 idx.insert(0.into(), node0);
1015 idx.insert(0.into(), node0);
@@ -75,7 +75,7 b' impl NodeMapDocket {'
75 // TODO: use `vfs.read()` here when the `persistent-nodemap.mmap`
75 // TODO: use `vfs.read()` here when the `persistent-nodemap.mmap`
76 // config is false?
76 // config is false?
77 if let Some(mmap) =
77 if let Some(mmap) =
78 store_vfs.mmap_open(&data_path).io_not_found_as_none()?
78 store_vfs.mmap_open(data_path).io_not_found_as_none()?
79 {
79 {
80 if mmap.len() >= data_length {
80 if mmap.len() >= data_length {
81 Ok(Some((docket, mmap)))
81 Ok(Some((docket, mmap)))
@@ -192,13 +192,13 b' pub fn canonical_path('
192 let name = name.as_ref();
192 let name = name.as_ref();
193
193
194 let name = if !name.is_absolute() {
194 let name = if !name.is_absolute() {
195 root.join(&cwd).join(&name)
195 root.join(cwd).join(name)
196 } else {
196 } else {
197 name.to_owned()
197 name.to_owned()
198 };
198 };
199 let auditor = PathAuditor::new(&root);
199 let auditor = PathAuditor::new(root);
200 if name != root && name.starts_with(&root) {
200 if name != root && name.starts_with(root) {
201 let name = name.strip_prefix(&root).unwrap();
201 let name = name.strip_prefix(root).unwrap();
202 auditor.audit_path(path_to_hg_path_buf(name)?)?;
202 auditor.audit_path(path_to_hg_path_buf(name)?)?;
203 Ok(name.to_owned())
203 Ok(name.to_owned())
204 } else if name == root {
204 } else if name == root {
@@ -210,7 +210,7 b' pub fn canonical_path('
210 let mut name = name.deref();
210 let mut name = name.deref();
211 let original_name = name.to_owned();
211 let original_name = name.to_owned();
212 loop {
212 loop {
213 let same = is_same_file(&name, &root).unwrap_or(false);
213 let same = is_same_file(name, root).unwrap_or(false);
214 if same {
214 if same {
215 if name == original_name {
215 if name == original_name {
216 // `name` was actually the same as root (maybe a symlink)
216 // `name` was actually the same as root (maybe a symlink)
@@ -218,8 +218,8 b' pub fn canonical_path('
218 }
218 }
219 // `name` is a symlink to root, so `original_name` is under
219 // `name` is a symlink to root, so `original_name` is under
220 // root
220 // root
221 let rel_path = original_name.strip_prefix(&name).unwrap();
221 let rel_path = original_name.strip_prefix(name).unwrap();
222 auditor.audit_path(path_to_hg_path_buf(&rel_path)?)?;
222 auditor.audit_path(path_to_hg_path_buf(rel_path)?)?;
223 return Ok(rel_path.to_owned());
223 return Ok(rel_path.to_owned());
224 }
224 }
225 name = match name.parent() {
225 name = match name.parent() {
@@ -429,7 +429,7 b' mod tests {'
429 })
429 })
430 );
430 );
431 assert_eq!(
431 assert_eq!(
432 canonical_path(&root, Path::new(""), &under_repo_symlink),
432 canonical_path(&root, Path::new(""), under_repo_symlink),
433 Ok(PathBuf::from("d"))
433 Ok(PathBuf::from("d"))
434 );
434 );
435 }
435 }
@@ -117,7 +117,7 b' impl PathAuditor {'
117 if self.audited_dirs.read().unwrap().contains(prefix) {
117 if self.audited_dirs.read().unwrap().contains(prefix) {
118 continue;
118 continue;
119 }
119 }
120 self.check_filesystem(&prefix, &path)?;
120 self.check_filesystem(prefix, path)?;
121 self.audited_dirs.write().unwrap().insert(prefix.to_owned());
121 self.audited_dirs.write().unwrap().insert(prefix.to_owned());
122 }
122 }
123
123
@@ -203,12 +203,12 b' mod tests {'
203 })
203 })
204 );
204 );
205
205
206 create_dir(&base_dir_path.join("realdir")).unwrap();
206 create_dir(base_dir_path.join("realdir")).unwrap();
207 File::create(&base_dir_path.join("realdir/realfile")).unwrap();
207 File::create(base_dir_path.join("realdir/realfile")).unwrap();
208 // TODO make portable
208 // TODO make portable
209 std::os::unix::fs::symlink(
209 std::os::unix::fs::symlink(
210 &base_dir_path.join("realdir"),
210 base_dir_path.join("realdir"),
211 &base_dir_path.join("symlink"),
211 base_dir_path.join("symlink"),
212 )
212 )
213 .unwrap();
213 .unwrap();
214 let path = HgPath::new(b"symlink/realfile");
214 let path = HgPath::new(b"symlink/realfile");
@@ -273,7 +273,7 b' fn build_response('
273 py_warnings.append(
273 py_warnings.append(
274 py,
274 py,
275 (
275 (
276 PyBytes::new(py, &get_bytes_from_path(&file)),
276 PyBytes::new(py, &get_bytes_from_path(file)),
277 PyBytes::new(py, syn),
277 PyBytes::new(py, syn),
278 )
278 )
279 .to_py_object(py)
279 .to_py_object(py)
@@ -282,7 +282,7 b' fn build_response('
282 }
282 }
283 PatternFileWarning::NoSuchFile(file) => py_warnings.append(
283 PatternFileWarning::NoSuchFile(file) => py_warnings.append(
284 py,
284 py,
285 PyBytes::new(py, &get_bytes_from_path(&file)).into_object(),
285 PyBytes::new(py, &get_bytes_from_path(file)).into_object(),
286 ),
286 ),
287 }
287 }
288 }
288 }
@@ -348,7 +348,7 b' impl MixedIndex {'
348 py: Python<'a>,
348 py: Python<'a>,
349 ) -> PyResult<&'a RefCell<Option<NodeTree>>> {
349 ) -> PyResult<&'a RefCell<Option<NodeTree>>> {
350 if self.nt(py).borrow().is_none() {
350 if self.nt(py).borrow().is_none() {
351 let readonly = Box::new(Vec::new());
351 let readonly = Box::<Vec<_>>::default();
352 let mut nt = NodeTree::load_bytes(readonly, 0);
352 let mut nt = NodeTree::load_bytes(readonly, 0);
353 self.fill_nodemap(py, &mut nt)?;
353 self.fill_nodemap(py, &mut nt)?;
354 self.nt(py).borrow_mut().replace(nt);
354 self.nt(py).borrow_mut().replace(nt);
@@ -382,7 +382,7 b' impl MixedIndex {'
382 // If there's anything readonly, we need to build the data again from
382 // If there's anything readonly, we need to build the data again from
383 // scratch
383 // scratch
384 let bytes = if readonly.len() > 0 {
384 let bytes = if readonly.len() > 0 {
385 let mut nt = NodeTree::load_bytes(Box::new(vec![]), 0);
385 let mut nt = NodeTree::load_bytes(Box::<Vec<_>>::default(), 0);
386 self.fill_nodemap(py, &mut nt)?;
386 self.fill_nodemap(py, &mut nt)?;
387
387
388 let (readonly, bytes) = nt.into_readonly_and_added_bytes();
388 let (readonly, bytes) = nt.into_readonly_and_added_bytes();
@@ -62,7 +62,7 b' pub fn run(invocation: &crate::CliInvoca'
62 return Err(CommandError::unsupported(message));
62 return Err(CommandError::unsupported(message));
63 }
63 }
64
64
65 let normalized = cwd.join(&file);
65 let normalized = cwd.join(file);
66 // TODO: actually normalize `..` path segments etc?
66 // TODO: actually normalize `..` path segments etc?
67 let dotted = normalized.components().any(|c| c.as_os_str() == "..");
67 let dotted = normalized.components().any(|c| c.as_os_str() == "..");
68 if file.as_bytes() == b"." || dotted {
68 if file.as_bytes() == b"." || dotted {
@@ -23,7 +23,7 b' pub fn args() -> clap::Command {'
23 )
23 )
24 .group(
24 .group(
25 ArgGroup::new("revlog")
25 ArgGroup::new("revlog")
26 .args(&["changelog", "manifest"])
26 .args(["changelog", "manifest"])
27 .required(true),
27 .required(true),
28 )
28 )
29 .arg(
29 .arg(
@@ -20,7 +20,7 b' pub fn run(invocation: &crate::CliInvoca'
20 .with_context(|| {
20 .with_context(|| {
21 IoErrorContext::CanonicalizingPath(working_directory.to_owned())
21 IoErrorContext::CanonicalizingPath(working_directory.to_owned())
22 })?;
22 })?;
23 let bytes = get_bytes_from_path(&working_directory);
23 let bytes = get_bytes_from_path(working_directory);
24 invocation
24 invocation
25 .ui
25 .ui
26 .write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?;
26 .write_stdout(&format_bytes!(b"{}\n", bytes.as_slice()))?;
@@ -404,8 +404,8 b' fn exit_code('
404 }
404 }
405 }
405 }
406
406
407 fn exit<'a>(
407 fn exit(
408 original_args: &'a [OsString],
408 original_args: &[OsString],
409 initial_current_dir: &Option<PathBuf>,
409 initial_current_dir: &Option<PathBuf>,
410 ui: &Ui,
410 ui: &Ui,
411 mut on_unsupported: OnUnsupported,
411 mut on_unsupported: OnUnsupported,
@@ -251,7 +251,7 b' pub(crate) fn format_pattern_file_warnin'
251 PatternFileWarning::InvalidSyntax(path, syntax) => format_bytes!(
251 PatternFileWarning::InvalidSyntax(path, syntax) => format_bytes!(
252 b"{}: ignoring invalid syntax '{}'\n",
252 b"{}: ignoring invalid syntax '{}'\n",
253 get_bytes_from_path(path),
253 get_bytes_from_path(path),
254 &*syntax
254 syntax
255 ),
255 ),
256 PatternFileWarning::NoSuchFile(path) => {
256 PatternFileWarning::NoSuchFile(path) => {
257 let path = if let Ok(relative) =
257 let path = if let Ok(relative) =
@@ -259,7 +259,7 b' pub(crate) fn format_pattern_file_warnin'
259 {
259 {
260 relative
260 relative
261 } else {
261 } else {
262 &*path
262 path
263 };
263 };
264 format_bytes!(
264 format_bytes!(
265 b"skipping unreadable pattern file '{}': \
265 b"skipping unreadable pattern file '{}': \
General Comments 0
You need to be logged in to leave comments. Login now