( )⚙ D10767 rhg: look for repository in ancestors also instead of cwd only

This is an archive of the discontinued Mercurial Phabricator instance.

rhg: look for repository in ancestors also instead of cwd only
ClosedPublic

Authored by pulkit on May 24 2021, 6:59 AM.

Details

Summary

Last patch introduced config reading at startup to parse value of --repository
flag. However, that patch only tried to check for current repository at current
working directory and not it's ancestors. This patch fixes that.

Diff Detail

Repository
rHG Mercurial
Branch
default
Lint
No Linters Available
Unit
No Unit Test Coverage

Event Timeline

pulkit created this revision.May 24 2021, 6:59 AM
SimonSapin added inline comments.
rust/hg-core/src/repo.rs
46–48

This doc should also mention ancestors. Something like "Find the nearest repository root, if any, in the current directory or its ancestors"

The try_ prefix can be dropped from the name since fallibility is already apparent from the return type and there’s no equivalent infallibly (panicky) API. Compare with std::cell::RefCell which has both borrow and try_borrow, and std::fs::File whose open method is not named try_open.

86–87

Please use if let or match instead of is_ok + unwrap

pulkit updated this revision to Diff 28196.May 24 2021, 6:31 PM
pulkit updated this revision to Diff 28202.May 25 2021, 6:01 PM
baymax updated this revision to Diff 28207.May 26 2021, 4:48 PM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

baymax updated this revision to Diff 28505.Jun 7 2021, 7:15 AM

✅ refresh by Heptapod after a successful CI run (🐙 💚)

SimonSapin added inline comments.Jun 7 2021, 10:59 AM
rust/hg-core/src/repo.rs
86–87

Sorry I didn’t realize this earlier: this entire match can be replaced with the ? operator:

let root = Self::find_repo_root()?
Self::new_at_path(root, config)
pulkit updated this revision to Diff 28514.Jun 9 2021, 3:51 AM
Alphare accepted this revision.Jun 9 2021, 5:14 AM
This revision is now accepted and ready to land.Jun 9 2021, 5:14 AM