Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/repo.rs @ 46632:5ce2aa7c2ad5
rhg: Move `Repo` object creation into `main()`
? rather than in each sub-command that needs a local repository.
This will allow accessing e.g. `.hg/blackbox.log` before dispatching
to sub-commands.
Differential Revision: https://phab.mercurial-scm.org/D10004
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 15 Feb 2021 20:13:09 +0100 |
parents | a25033eb43b5 |
children | 1f55cd5b292f |
line wrap: on
line diff
--- a/rust/hg-core/src/repo.rs Mon Feb 15 20:05:32 2021 +0100 +++ b/rust/hg-core/src/repo.rs Mon Feb 15 20:13:09 2021 +0100 @@ -81,28 +81,6 @@ } } - /// Like `Repo::find`, but not finding a repository is not an error if no - /// explicit path is given. `Ok(None)` is returned in that case. - /// - /// If an explicit path *is* given, not finding a repository there is still - /// an error. - /// - /// For sub-commands that don’t need a repository, configuration should - /// still be affected by a repository’s `.hg/hgrc` file. This is the - /// constructor to use. - pub fn find_optional( - config: &Config, - explicit_path: Option<&Path>, - ) -> Result<Option<Self>, RepoError> { - match Self::find(config, explicit_path) { - Ok(repo) => Ok(Some(repo)), - Err(RepoError::NotFound { .. }) if explicit_path.is_none() => { - Ok(None) - } - Err(error) => Err(error), - } - } - /// To be called after checking that `.hg` is a sub-directory fn new_at_path( working_directory: PathBuf,