Refactor hg path cleaning to use one line