mercurial/httprepo.py
changeset 9861 0262bb59016f
parent 9748 67e5d5a2f625
child 9878 7e7d56fe4833
equal deleted inserted replaced
9860:9c43089b372a 9861:0262bb59016f
     9 from node import bin, hex, nullid
     9 from node import bin, hex, nullid
    10 from i18n import _
    10 from i18n import _
    11 import repo, changegroup, statichttprepo, error, url, util
    11 import repo, changegroup, statichttprepo, error, url, util
    12 import os, urllib, urllib2, urlparse, zlib, httplib
    12 import os, urllib, urllib2, urlparse, zlib, httplib
    13 import errno, socket
    13 import errno, socket
       
    14 import encoding
    14 
    15 
    15 def zgenerator(f):
    16 def zgenerator(f):
    16     zd = zlib.decompressobj()
    17     zd = zlib.decompressobj()
    17     try:
    18     try:
    18         for chunk in util.filechunkiter(f):
    19         for chunk in util.filechunkiter(f):
   151         try:
   152         try:
   152             branchmap = {}
   153             branchmap = {}
   153             for branchpart in d.splitlines():
   154             for branchpart in d.splitlines():
   154                 branchheads = branchpart.split(' ')
   155                 branchheads = branchpart.split(' ')
   155                 branchname = urllib.unquote(branchheads[0])
   156                 branchname = urllib.unquote(branchheads[0])
       
   157                 try:
       
   158                     branchname.decode('utf-8', 'strict')
       
   159                 except UnicodeDecodeError:
       
   160                     branchname = encoding.tolocal(branchname)
   156                 branchheads = [bin(x) for x in branchheads[1:]]
   161                 branchheads = [bin(x) for x in branchheads[1:]]
   157                 branchmap[branchname] = branchheads
   162                 branchmap[branchname] = branchheads
   158             return branchmap
   163             return branchmap
   159         except:
   164         except:
   160             raise error.ResponseError(_("unexpected response:"), d)
   165             raise error.ResponseError(_("unexpected response:"), d)