changeset 9878:7e7d56fe4833 stable

branchmap: fix defective fallback fix 0262bb59016f The fix applied as 0262bb59016f doesn't work and is essentially a no-op. This fix also adds a comment about the nature of the problem, and a test.
author Sune Foldager <cryo@cyanite.org>
date Wed, 18 Nov 2009 15:20:08 +0100
parents c51494c53841
children 7bb004fc14ec
files mercurial/httprepo.py mercurial/sshrepo.py
diffstat 2 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/httprepo.py	Tue Nov 17 22:16:41 2009 +0100
+++ b/mercurial/httprepo.py	Wed Nov 18 15:20:08 2009 +0100
@@ -154,10 +154,13 @@
             for branchpart in d.splitlines():
                 branchheads = branchpart.split(' ')
                 branchname = urllib.unquote(branchheads[0])
+                # Earlier servers (1.3.x) send branch names in (their) local
+                # charset. The best we can do is assume it's identical to our
+                # own local charset, in case it's not utf-8.
                 try:
-                    branchname.decode('utf-8', 'strict')
+                    branchname.decode('utf-8')
                 except UnicodeDecodeError:
-                    branchname = encoding.tolocal(branchname)
+                    branchname = encoding.fromlocal(branchname)
                 branchheads = [bin(x) for x in branchheads[1:]]
                 branchmap[branchname] = branchheads
             return branchmap
--- a/mercurial/sshrepo.py	Tue Nov 17 22:16:41 2009 +0100
+++ b/mercurial/sshrepo.py	Wed Nov 18 15:20:08 2009 +0100
@@ -173,10 +173,13 @@
             for branchpart in d.splitlines():
                 branchheads = branchpart.split(' ')
                 branchname = urllib.unquote(branchheads[0])
+                # Earlier servers (1.3.x) send branch names in (their) local
+                # charset. The best we can do is assume it's identical to our
+                # own local charset, in case it's not utf-8.
                 try:
-                    branchname.decode('utf-8', 'strict')
+                    branchname.decode('utf-8')
                 except UnicodeDecodeError:
-                    branchname = encoding.tolocal(branchname)
+                    branchname = encoding.fromlocal(branchname)
                 branchheads = [bin(x) for x in branchheads[1:]]
                 branchmap[branchname] = branchheads
             return branchmap