mercurial/pycompat.py
changeset 36644 e2b87e19c6ef
parent 36556 63fe5ca93b13
child 36647 052351e3e1cd
equal deleted inserted replaced
36643:1e1c1bfb0be4 36644:e2b87e19c6ef
   190             return s
   190             return s
   191         return s.decode(u'latin-1')
   191         return s.decode(u'latin-1')
   192 
   192 
   193     def strurl(url):
   193     def strurl(url):
   194         """Converts a bytes url back to str"""
   194         """Converts a bytes url back to str"""
   195         return url.decode(u'ascii')
   195         if isinstance(url, bytes):
       
   196             return url.decode(u'ascii')
       
   197         return url
   196 
   198 
   197     def bytesurl(url):
   199     def bytesurl(url):
   198         """Converts a str url to bytes by encoding in ascii"""
   200         """Converts a str url to bytes by encoding in ascii"""
   199         return url.encode(u'ascii')
   201         if isinstance(url, str):
       
   202             return url.encode(u'ascii')
       
   203         return url
   200 
   204 
   201     def raisewithtb(exc, tb):
   205     def raisewithtb(exc, tb):
   202         """Raise exception with the given traceback"""
   206         """Raise exception with the given traceback"""
   203         raise exc.with_traceback(tb)
   207         raise exc.with_traceback(tb)
   204 
   208