rhg: Replace subcommand boilerplate with a macro
This removes some repetition, and will avoid additional repetition in the next commit.
Differential Revision: https://phab.mercurial-scm.org/D9969