mercurial/wireproto.py
changeset 37537 be5d4749edc0
parent 37536 2003da12f49b
child 37538 89fed81bbb6c
equal deleted inserted replaced
37536:2003da12f49b 37537:be5d4749edc0
  1143 def protocaps(repo, proto, caps):
  1143 def protocaps(repo, proto, caps):
  1144     if proto.name == wireprototypes.SSHV1:
  1144     if proto.name == wireprototypes.SSHV1:
  1145         proto._protocaps = set(caps.split(' '))
  1145         proto._protocaps = set(caps.split(' '))
  1146     return wireprototypes.bytesresponse('OK')
  1146     return wireprototypes.bytesresponse('OK')
  1147 
  1147 
  1148 @wireprotocommand('pushkey', 'namespace key old new', permission='push')
  1148 @wireprotocommand('pushkey', 'namespace key old new', permission='push',
       
  1149                   transportpolicy=POLICY_V1_ONLY)
  1149 def pushkey(repo, proto, namespace, key, old, new):
  1150 def pushkey(repo, proto, namespace, key, old, new):
  1150     # compatibility with pre-1.8 clients which were accidentally
  1151     # compatibility with pre-1.8 clients which were accidentally
  1151     # sending raw binary nodes rather than utf-8-encoded hex
  1152     # sending raw binary nodes rather than utf-8-encoded hex
  1152     if len(new) == 20 and stringutil.escapestr(new) != new:
  1153     if len(new) == 20 and stringutil.escapestr(new) != new:
  1153         # looks like it could be a binary node
  1154         # looks like it could be a binary node
  1374     keys = repo.listkeys(encoding.tolocal(namespace))
  1375     keys = repo.listkeys(encoding.tolocal(namespace))
  1375     keys = {encoding.fromlocal(k): encoding.fromlocal(v)
  1376     keys = {encoding.fromlocal(k): encoding.fromlocal(v)
  1376             for k, v in keys.iteritems()}
  1377             for k, v in keys.iteritems()}
  1377 
  1378 
  1378     return wireprototypes.cborresponse(keys)
  1379     return wireprototypes.cborresponse(keys)
       
  1380 
       
  1381 @wireprotocommand('pushkey',
       
  1382                   args={
       
  1383                       'namespace': b'ns',
       
  1384                       'key': b'key',
       
  1385                       'old': b'old',
       
  1386                       'new': b'new',
       
  1387                   },
       
  1388                   permission='push',
       
  1389                   transportpolicy=POLICY_V2_ONLY)
       
  1390 def pushkeyv2(repo, proto, namespace, key, old, new):
       
  1391     # TODO handle ui output redirection
       
  1392     r = repo.pushkey(encoding.tolocal(namespace),
       
  1393                      encoding.tolocal(key),
       
  1394                      encoding.tolocal(old),
       
  1395                      encoding.tolocal(new))
       
  1396 
       
  1397     return wireprototypes.cborresponse(r)