equal
deleted
inserted
replaced
79 at: current_directory, |
79 at: current_directory, |
80 }) |
80 }) |
81 } |
81 } |
82 } |
82 } |
83 |
83 |
84 /// Like `Repo::find`, but not finding a repository is not an error if no |
|
85 /// explicit path is given. `Ok(None)` is returned in that case. |
|
86 /// |
|
87 /// If an explicit path *is* given, not finding a repository there is still |
|
88 /// an error. |
|
89 /// |
|
90 /// For sub-commands that don’t need a repository, configuration should |
|
91 /// still be affected by a repository’s `.hg/hgrc` file. This is the |
|
92 /// constructor to use. |
|
93 pub fn find_optional( |
|
94 config: &Config, |
|
95 explicit_path: Option<&Path>, |
|
96 ) -> Result<Option<Self>, RepoError> { |
|
97 match Self::find(config, explicit_path) { |
|
98 Ok(repo) => Ok(Some(repo)), |
|
99 Err(RepoError::NotFound { .. }) if explicit_path.is_none() => { |
|
100 Ok(None) |
|
101 } |
|
102 Err(error) => Err(error), |
|
103 } |
|
104 } |
|
105 |
|
106 /// To be called after checking that `.hg` is a sub-directory |
84 /// To be called after checking that `.hg` is a sub-directory |
107 fn new_at_path( |
85 fn new_at_path( |
108 working_directory: PathBuf, |
86 working_directory: PathBuf, |
109 config: &Config, |
87 config: &Config, |
110 ) -> Result<Self, RepoError> { |
88 ) -> Result<Self, RepoError> { |