mercurial/wireproto.py
changeset 13047 6c375e07d673
parent 12703 40bb5853fc4b
child 13049 d588326f6321
equal deleted inserted replaced
13046:7cc4263e07a9 13047:6c375e07d673
    42         d = self._call("branchmap")
    42         d = self._call("branchmap")
    43         try:
    43         try:
    44             branchmap = {}
    44             branchmap = {}
    45             for branchpart in d.splitlines():
    45             for branchpart in d.splitlines():
    46                 branchname, branchheads = branchpart.split(' ', 1)
    46                 branchname, branchheads = branchpart.split(' ', 1)
    47                 branchname = urllib.unquote(branchname)
    47                 branchname = encoding.tolocal(urllib.unquote(branchname))
    48                 # Earlier servers (1.3.x) send branch names in (their) local
       
    49                 # charset. The best we can do is assume it's identical to our
       
    50                 # own local charset, in case it's not utf-8.
       
    51                 try:
       
    52                     branchname.decode('utf-8')
       
    53                 except UnicodeDecodeError:
       
    54                     branchname = encoding.fromlocal(branchname)
       
    55                 branchheads = decodelist(branchheads)
    48                 branchheads = decodelist(branchheads)
    56                 branchmap[branchname] = branchheads
    49                 branchmap[branchname] = branchheads
    57             return branchmap
    50             return branchmap
    58         except TypeError:
    51         except TypeError:
    59             self._abort(error.ResponseError(_("unexpected response:"), d))
    52             self._abort(error.ResponseError(_("unexpected response:"), d))
   160 
   153 
   161 def branchmap(repo, proto):
   154 def branchmap(repo, proto):
   162     branchmap = repo.branchmap()
   155     branchmap = repo.branchmap()
   163     heads = []
   156     heads = []
   164     for branch, nodes in branchmap.iteritems():
   157     for branch, nodes in branchmap.iteritems():
   165         branchname = urllib.quote(branch)
   158         branchname = urllib.quote(encoding.fromlocal(branch))
   166         branchnodes = encodelist(nodes)
   159         branchnodes = encodelist(nodes)
   167         heads.append('%s %s' % (branchname, branchnodes))
   160         heads.append('%s %s' % (branchname, branchnodes))
   168     return '\n'.join(heads)
   161     return '\n'.join(heads)
   169 
   162 
   170 def branches(repo, proto, nodes):
   163 def branches(repo, proto, nodes):