HgGitRepository refactors and proper project path in environment variables
Took the opportunity of !114 (merged) to solve a few old TODOs, and it grew enough that a separate (stacked) MR is probably clearer.
Notably decided to report #359 (closed) and fix it.