Mercurial > public > mercurial-scm > hg
comparison rust/hg-core/src/filepatterns.rs @ 51117:532e74ad3ff6
rust: run a clippy pass with the latest stable version
Our current version of clippy is older than the latest stable.
The newest version has new lints that are moslty good advice, so let's apply
them ahead of time. This has the added benefit of reducing the noise for
developpers like myself that use clippy as an IDE helper, as well as being
more prepared for a future clippy upgrade.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 06 Nov 2023 11:06:08 +0100 |
parents | c112cc9effdc |
children | 406b413e3cf2 |
comparison
equal
deleted
inserted
replaced
51116:d58e754f2db0 | 51117:532e74ad3ff6 |
---|---|
627 ) -> Result<SubInclude, HgPathError> { | 627 ) -> Result<SubInclude, HgPathError> { |
628 let normalized_source = | 628 let normalized_source = |
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()); |
637 | 636 |
638 let prefix = canonical_path(root_dir, root_dir, new_root)?; | 637 let prefix = canonical_path(root_dir, root_dir, new_root)?; |
680 let untouched = | 679 let untouched = |
681 br#"!"%',/0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ_`abcdefghijklmnopqrstuvwxyz"#; | 680 br#"!"%',/0123456789:;<=>@ABCDEFGHIJKLMNOPQRSTUVWXYZ_`abcdefghijklmnopqrstuvwxyz"#; |
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] |
704 fn test_parse_pattern_file_contents() { | 702 fn test_parse_pattern_file_contents() { |
705 let lines = b"syntax: glob\n*.elc"; | 703 let lines = b"syntax: glob\n*.elc"; |