Mercurial > public > mercurial-scm > hg-stable
comparison rust/hg-core/src/utils/files.rs @ 47127:be579775c2d9
dirstate-tree: Add the new `status()` algorithm
With the dirstate organized in a tree that mirrors the structure of the
filesystem tree, we can traverse both trees at the same time in order to
compare them. This is hopefully more efficient that building multiple
big hashmaps for all of the repository?s contents.
Differential Revision: https://phab.mercurial-scm.org/D10547
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Fri, 16 Apr 2021 12:12:41 +0200 |
parents | c94fa884240b |
children | 789475ef2b22 |
comparison
equal
deleted
inserted
replaced
47126:d5956136d19d | 47127:be579775c2d9 |
---|---|
15 replace_slice, | 15 replace_slice, |
16 }; | 16 }; |
17 use lazy_static::lazy_static; | 17 use lazy_static::lazy_static; |
18 use same_file::is_same_file; | 18 use same_file::is_same_file; |
19 use std::borrow::{Cow, ToOwned}; | 19 use std::borrow::{Cow, ToOwned}; |
20 use std::ffi::OsStr; | 20 use std::ffi::{OsStr, OsString}; |
21 use std::fs::Metadata; | 21 use std::fs::Metadata; |
22 use std::iter::FusedIterator; | 22 use std::iter::FusedIterator; |
23 use std::ops::Deref; | 23 use std::ops::Deref; |
24 use std::path::{Path, PathBuf}; | 24 use std::path::{Path, PathBuf}; |
25 | 25 |
49 | 49 |
50 #[cfg(unix)] | 50 #[cfg(unix)] |
51 pub fn get_bytes_from_os_str(str: impl AsRef<OsStr>) -> Vec<u8> { | 51 pub fn get_bytes_from_os_str(str: impl AsRef<OsStr>) -> Vec<u8> { |
52 use std::os::unix::ffi::OsStrExt; | 52 use std::os::unix::ffi::OsStrExt; |
53 str.as_ref().as_bytes().to_vec() | 53 str.as_ref().as_bytes().to_vec() |
54 } | |
55 | |
56 #[cfg(unix)] | |
57 pub fn get_bytes_from_os_string(str: OsString) -> Vec<u8> { | |
58 use std::os::unix::ffi::OsStringExt; | |
59 str.into_vec() | |
54 } | 60 } |
55 | 61 |
56 /// An iterator over repository path yielding itself and its ancestors. | 62 /// An iterator over repository path yielding itself and its ancestors. |
57 #[derive(Copy, Clone, Debug)] | 63 #[derive(Copy, Clone, Debug)] |
58 pub struct Ancestors<'a> { | 64 pub struct Ancestors<'a> { |