[PATCH 07 of 12 py3] util: teach url object about __bytes__

Augie Fackler raf at durin42.com
Sun Mar 12 15:49:56 EDT 2017


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1489304002 14400
#      Sun Mar 12 03:33:22 2017 -0400
# Node ID 84996257b560fa41535e4d0360cb33436662581c
# Parent  5a0a53d127726a34013a34156d47ab873f6dc8df
util: teach url object about __bytes__

__str__ tries to do something reasonable, but someone else more
familiar with encoding bugs should check my work.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2651,6 +2651,11 @@ class url(object):
         >>> print url(r'file:///D:\data\hg')
         file:///D:\data\hg
         """
+        if pycompat.ispy3:
+            return encoding.fromlocal(self.__bytes__()).decode('utf-8')
+        return self.__bytes__()
+
+    def __bytes__(self):
         if self._localpath:
             s = self.path
             if self.scheme == 'bundle':


More information about the Mercurial-devel mailing list