This is an archive of the discontinued Mercurial Phabricator instance.

rhg: use `Command::exec` instead of `Command::status`
ClosedPublic

Authored by Alphare on Apr 20 2022, 11:10 AM.

Details

Summary

rhg is supposed to be a transparent executable, using a subprocess defeats
that purpose. See inline comments for more details.

This also introduces the which crate to check if the fallback executable
actually exists to help debugging (plain execve doesn't give much
information).

The error code 253 is used to signify that the fallback is not found, but may
mean in the future that it is otherwise invalid if we start being more
specific.

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

Alphare created this revision.Apr 20 2022, 11:10 AM

Pending CI refresh

martinvonz requested changes to this revision.Apr 21 2022, 3:42 PM
martinvonz added a subscriber: martinvonz.
martinvonz added inline comments.
rust/rhg/src/main.rs
421

Since you said you used the which crate in order to make debugging easier, it surprised me that you just call .is_ok() here. How about replacing it by a if let Err(err) = ... and debug message based on that err?

441

nit: s/is ran/is run/

This revision now requires changes to proceed.Apr 21 2022, 3:42 PM
Alphare updated this revision to Diff 33308.Apr 25 2022, 5:36 AM
Alphare updated this revision to Diff 33309.
martinvonz accepted this revision.Apr 25 2022, 12:06 PM
This revision is now accepted and ready to land.Apr 25 2022, 12:06 PM
This revision was automatically updated to reflect the committed changes.