Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHG789475ef2b22: rust: remove dead code
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
( )
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | rust/hg-core/src/utils/files.rs (33 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
8947ac1fc26d | 2caf1de2fbe4 | Raphaël Gomès | Oct 1 2021, 12:14 PM |
hg_path::{path_to_hg_path_buf, HgPath, HgPathBuf, HgPathError}, | hg_path::{path_to_hg_path_buf, HgPath, HgPathBuf, HgPathError}, | ||||
path_auditor::PathAuditor, | path_auditor::PathAuditor, | ||||
replace_slice, | replace_slice, | ||||
}; | }; | ||||
use lazy_static::lazy_static; | use lazy_static::lazy_static; | ||||
use same_file::is_same_file; | use same_file::is_same_file; | ||||
use std::borrow::{Cow, ToOwned}; | use std::borrow::{Cow, ToOwned}; | ||||
use std::ffi::{OsStr, OsString}; | use std::ffi::{OsStr, OsString}; | ||||
use std::fs::Metadata; | |||||
use std::iter::FusedIterator; | use std::iter::FusedIterator; | ||||
use std::ops::Deref; | use std::ops::Deref; | ||||
use std::path::{Path, PathBuf}; | use std::path::{Path, PathBuf}; | ||||
pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr { | pub fn get_os_str_from_bytes(bytes: &[u8]) -> &OsStr { | ||||
let os_str; | let os_str; | ||||
#[cfg(unix)] | #[cfg(unix)] | ||||
{ | { | ||||
buf | buf | ||||
} | } | ||||
} | } | ||||
pub fn lower_clean(bytes: &[u8]) -> Vec<u8> { | pub fn lower_clean(bytes: &[u8]) -> Vec<u8> { | ||||
hfs_ignore_clean(&bytes.to_ascii_lowercase()) | hfs_ignore_clean(&bytes.to_ascii_lowercase()) | ||||
} | } | ||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone)] | |||||
pub struct HgMetadata { | |||||
pub st_dev: u64, | |||||
pub st_mode: u32, | |||||
pub st_nlink: u64, | |||||
pub st_size: u64, | |||||
pub st_mtime: i64, | |||||
pub st_ctime: i64, | |||||
} | |||||
// TODO support other plaforms | |||||
#[cfg(unix)] | |||||
impl HgMetadata { | |||||
pub fn from_metadata(metadata: Metadata) -> Self { | |||||
use std::os::unix::fs::MetadataExt; | |||||
Self { | |||||
st_dev: metadata.dev(), | |||||
st_mode: metadata.mode(), | |||||
st_nlink: metadata.nlink(), | |||||
st_size: metadata.size(), | |||||
st_mtime: metadata.mtime(), | |||||
st_ctime: metadata.ctime(), | |||||
} | |||||
} | |||||
pub fn is_symlink(&self) -> bool { | |||||
// This is way too manual, but `HgMetadata` will go away in the | |||||
// near-future dirstate rewrite anyway. | |||||
self.st_mode & 0170000 == 0120000 | |||||
} | |||||
} | |||||
/// Returns the canonical path of `name`, given `cwd` and `root` | /// Returns the canonical path of `name`, given `cwd` and `root` | ||||
pub fn canonical_path( | pub fn canonical_path( | ||||
root: impl AsRef<Path>, | root: impl AsRef<Path>, | ||||
cwd: impl AsRef<Path>, | cwd: impl AsRef<Path>, | ||||
name: impl AsRef<Path>, | name: impl AsRef<Path>, | ||||
) -> Result<PathBuf, HgPathError> { | ) -> Result<PathBuf, HgPathError> { | ||||
// TODO add missing normalization for other platforms | // TODO add missing normalization for other platforms | ||||
let root = root.as_ref(); | let root = root.as_ref(); |