branchmap: fix defective fallback fix a3d9c67908ca

The fix applied as a3d9c67908ca doesn't work and is essentially a no-op.
This fix also adds a comment about the nature of the problem, and a test.
This commit is contained in:
Sune Foldager 2009-11-18 15:20:08 +01:00
parent d5e8634932
commit a2d25fc09b
2 changed files with 10 additions and 4 deletions

View File

@ -154,10 +154,13 @@ class httprepository(repo.repository):
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

View File

@ -173,10 +173,13 @@ class sshrepository(repo.repository):
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