equal
deleted
inserted
replaced
|
1 use crate::config::Config; |
1 use crate::errors::{HgError, IoResultExt}; |
2 use crate::errors::{HgError, IoResultExt}; |
2 use crate::requirements; |
3 use crate::requirements; |
3 use crate::utils::files::get_path_from_bytes; |
4 use crate::utils::files::get_path_from_bytes; |
4 use memmap::{Mmap, MmapOptions}; |
5 use memmap::{Mmap, MmapOptions}; |
5 use std::collections::HashSet; |
6 use std::collections::HashSet; |
29 } |
30 } |
30 |
31 |
31 impl Repo { |
32 impl Repo { |
32 /// Search the current directory and its ancestores for a repository: |
33 /// Search the current directory and its ancestores for a repository: |
33 /// a working directory that contains a `.hg` sub-directory. |
34 /// a working directory that contains a `.hg` sub-directory. |
34 pub fn find() -> Result<Self, RepoFindError> { |
35 pub fn find(_config: &Config) -> Result<Self, RepoFindError> { |
35 let current_directory = crate::utils::current_dir()?; |
36 let current_directory = crate::utils::current_dir()?; |
36 // ancestors() is inclusive: it first yields `current_directory` as-is. |
37 // ancestors() is inclusive: it first yields `current_directory` as-is. |
37 for ancestor in current_directory.ancestors() { |
38 for ancestor in current_directory.ancestors() { |
38 if ancestor.join(".hg").is_dir() { |
39 if ancestor.join(".hg").is_dir() { |
39 return Ok(Self::new_at_path(ancestor.to_owned())?); |
40 return Ok(Self::new_at_path(ancestor.to_owned())?); |