Page MenuHomePhabricator

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
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

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.

85–86

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
85–86

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