Page MenuHomePhabricator

rhg: Replace subcommand boilerplate with a macro
ClosedPublic

Authored by SimonSapin on Feb 8 2021, 5:44 PM.

Details

Summary

This removes some repetition, and will avoid additional repetition
in the next commit.

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

SimonSapin created this revision.Feb 8 2021, 5:44 PM
Alphare accepted this revision.Feb 9 2021, 4:03 AM
Alphare added a subscriber: Alphare.
Alphare added inline comments.
rust/rhg/src/main.rs
29

This should be a fallback to Python (if the "no fallback" config option is not set, when we're at that point) instead of a panic. Maybe this handling can be done in the same follow-up patch as the catch_unwind one from the previous patch?
Note that the previous behavior of exiting is not valid either, hence why I propose a follow-up.

SimonSapin added inline comments.Feb 9 2021, 4:14 AM
rust/rhg/src/main.rs
29

My understanding of SubcommandRequired is that it makes get_matches_safe return an error (so this code is not even reached) in all cases that would otherwise return None here. Is that not how it works?

Alphare added inline comments.Feb 9 2021, 4:18 AM
rust/rhg/src/main.rs
29

Ha, it does, but we also print an error to stderr at line 24 which confused me, when it should go to log::debug to grep for the fallback reason and not print anything to the user.

This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.