hg-fast-export.py: do not generate invalid ref names
Git has various rules about what is and is not a valid ref
name. These are summarized in the 'git help check-ref-format'
output.
Update the ref name conversion code to take into account all the
rules. Also compile the regexs only once and eliminate invalid
index exceptions.
These reference names no longer cause exceptions:
/a
a//b
These reference names no longer generate invalid names:
a@{b}
a.lock
All ref names that were previously converted to valid Git ref names
should continue to be converted to the same ref name now.