bin: install-user: extract repeated code into a function "ensure_hg"