[hg] Log hg command _before_ executing it.

That way we can still see hg commands in the log, even if they didn't
complete because of some problem (e.g. hanging password prompt).

Split logging to logCommand & logResult.
logCommand before executing a command, log result after it.
WEB-6373 fixed tests. added anchor inspection.