comparison rust/hg-core/src/repo.rs @ 46543:a6e4e4650bac

rhg: Parse system and user configuration at program start ? and pass it around up to `Repo::find` Differential Revision: https://phab.mercurial-scm.org/D9962
author Simon Sapin <simon.sapin@octobus.net>
date Thu, 04 Feb 2021 13:17:55 +0100
parents 95b276283b67
children f031fe1c6ede
comparison
equal deleted inserted replaced
46542:2845892dd489 46543:a6e4e4650bac
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())?);