Add type hints and clean up some code for Mercurial.
Review Request #13609 — Created March 4, 2024 and submitted — Latest diff uploaded
This change modernizes the Mercurial backend somewhat through type hints
and general code housekeeping.
Ran unit tests.