mercurial/wireproto.py
changeset 13723 e615765fdcc7
parent 13722 f4a85acef50c
child 13726 378522bdc059
equal deleted inserted replaced
13722:f4a85acef50c 13723:e615765fdcc7
    35 
    35 
    36     def heads(self):
    36     def heads(self):
    37         d = self._call("heads")
    37         d = self._call("heads")
    38         try:
    38         try:
    39             return decodelist(d[:-1])
    39             return decodelist(d[:-1])
       
    40         except:
       
    41             self._abort(error.ResponseError(_("unexpected response:"), d))
       
    42 
       
    43     def known(self, nodes):
       
    44         n = encodelist(nodes)
       
    45         d = self._call("known", nodes=n)
       
    46         try:
       
    47             return [bool(int(f)) for f in d]
    40         except:
    48         except:
    41             self._abort(error.ResponseError(_("unexpected response:"), d))
    49             self._abort(error.ResponseError(_("unexpected response:"), d))
    42 
    50 
    43     def branchmap(self):
    51     def branchmap(self):
    44         d = self._call("branchmap")
    52         d = self._call("branchmap")
   196     for b in repo.branches(nodes):
   204     for b in repo.branches(nodes):
   197         r.append(encodelist(b) + "\n")
   205         r.append(encodelist(b) + "\n")
   198     return "".join(r)
   206     return "".join(r)
   199 
   207 
   200 def capabilities(repo, proto):
   208 def capabilities(repo, proto):
   201     caps = 'lookup changegroupsubset branchmap pushkey'.split()
   209     caps = 'lookup changegroupsubset branchmap pushkey known'.split()
   202     if _allowstream(repo.ui):
   210     if _allowstream(repo.ui):
   203         requiredformats = repo.requirements & repo.supportedformats
   211         requiredformats = repo.requirements & repo.supportedformats
   204         # if our local revlogs are just revlogv1, add 'stream' cap
   212         # if our local revlogs are just revlogv1, add 'stream' cap
   205         if not requiredformats - set(('revlogv1',)):
   213         if not requiredformats - set(('revlogv1',)):
   206             caps.append('stream')
   214             caps.append('stream')
   252         success = 1
   260         success = 1
   253     except Exception, inst:
   261     except Exception, inst:
   254         r = str(inst)
   262         r = str(inst)
   255         success = 0
   263         success = 0
   256     return "%s %s\n" % (success, r)
   264     return "%s %s\n" % (success, r)
       
   265 
       
   266 def known(repo, proto, nodes):
       
   267     return ''.join(b and "1" or "0" for b in repo.known(decodelist(nodes)))
   257 
   268 
   258 def pushkey(repo, proto, namespace, key, old, new):
   269 def pushkey(repo, proto, namespace, key, old, new):
   259     # compatibility with pre-1.8 clients which were accidentally
   270     # compatibility with pre-1.8 clients which were accidentally
   260     # sending raw binary nodes rather than utf-8-encoded hex
   271     # sending raw binary nodes rather than utf-8-encoded hex
   261     if len(new) == 20 and new.encode('string-escape') != new:
   272     if len(new) == 20 and new.encode('string-escape') != new:
   371     'changegroup': (changegroup, 'roots'),
   382     'changegroup': (changegroup, 'roots'),
   372     'changegroupsubset': (changegroupsubset, 'bases heads'),
   383     'changegroupsubset': (changegroupsubset, 'bases heads'),
   373     'debugwireargs': (debugwireargs, 'one two *'),
   384     'debugwireargs': (debugwireargs, 'one two *'),
   374     'heads': (heads, ''),
   385     'heads': (heads, ''),
   375     'hello': (hello, ''),
   386     'hello': (hello, ''),
       
   387     'known': (known, 'nodes'),
   376     'listkeys': (listkeys, 'namespace'),
   388     'listkeys': (listkeys, 'namespace'),
   377     'lookup': (lookup, 'key'),
   389     'lookup': (lookup, 'key'),
   378     'pushkey': (pushkey, 'namespace key old new'),
   390     'pushkey': (pushkey, 'namespace key old new'),
   379     'stream_out': (stream, ''),
   391     'stream_out': (stream, ''),
   380     'unbundle': (unbundle, 'heads'),
   392     'unbundle': (unbundle, 'heads'),