comparison rust/hg-core/src/utils/hg_path.rs @ 47113: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 3da19db33cbc
children 1249eb9cc332
comparison
equal deleted inserted replaced
47112:d5956136d19d 47113:be579775c2d9
4 // 4 //
5 // This software may be used and distributed according to the terms of the 5 // This software may be used and distributed according to the terms of the
6 // GNU General Public License version 2 or any later version. 6 // GNU General Public License version 2 or any later version.
7 7
8 use std::borrow::Borrow; 8 use std::borrow::Borrow;
9 use std::borrow::Cow;
9 use std::convert::TryFrom; 10 use std::convert::TryFrom;
10 use std::ffi::{OsStr, OsString}; 11 use std::ffi::{OsStr, OsString};
11 use std::fmt; 12 use std::fmt;
12 use std::ops::Deref; 13 use std::ops::Deref;
13 use std::path::{Path, PathBuf}; 14 use std::path::{Path, PathBuf};
533 fn try_from(path: PathBuf) -> Result<Self, Self::Error> { 534 fn try_from(path: PathBuf) -> Result<Self, Self::Error> {
534 path_to_hg_path_buf(path) 535 path_to_hg_path_buf(path)
535 } 536 }
536 } 537 }
537 538
539 impl From<HgPathBuf> for Cow<'_, HgPath> {
540 fn from(path: HgPathBuf) -> Self {
541 Cow::Owned(path)
542 }
543 }
544
545 impl<'a> From<&'a HgPath> for Cow<'a, HgPath> {
546 fn from(path: &'a HgPath) -> Self {
547 Cow::Borrowed(path)
548 }
549 }
550
551 impl<'a> From<&'a HgPathBuf> for Cow<'a, HgPath> {
552 fn from(path: &'a HgPathBuf) -> Self {
553 Cow::Borrowed(&**path)
554 }
555 }
556
538 #[cfg(test)] 557 #[cfg(test)]
539 mod tests { 558 mod tests {
540 use super::*; 559 use super::*;
541 use pretty_assertions::assert_eq; 560 use pretty_assertions::assert_eq;
542 561