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

I have this error with the one shipped in ubuntu 14.04. "2.8.2".