Fix erroneous variable name and conditional in hg state, Fix #6661