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."

Adding this makes a lot of sense now that we have several places this is needed in.