added compat.py

fixed a UnicodeError under git usage
fixed a test for older mercurial version

Btw. there are some fixes inside that are not yet released like a converting bytes to string to prevent from:

"WARNING: Can't update package 'XXX' because its URL doesn't match."

Why is this needed? Is that the fix for Python 2 on Travis? It seems weird that this is needed. I have to look into it.