74 |
74 |
75 def pushkey(self, namespace, key, old, new): |
75 def pushkey(self, namespace, key, old, new): |
76 if not self.capable('pushkey'): |
76 if not self.capable('pushkey'): |
77 return False |
77 return False |
78 d = self._call("pushkey", |
78 d = self._call("pushkey", |
79 namespace=namespace, key=key, old=old, new=new) |
79 namespace=encoding.fromlocal(namespace), |
|
80 key=encoding.fromlocal(key), |
|
81 old=encoding.fromlocal(old), |
|
82 new=encoding.fromlocal(new)) |
80 return bool(int(d)) |
83 return bool(int(d)) |
81 |
84 |
82 def listkeys(self, namespace): |
85 def listkeys(self, namespace): |
83 if not self.capable('pushkey'): |
86 if not self.capable('pushkey'): |
84 return {} |
87 return {} |
85 d = self._call("listkeys", namespace=namespace) |
88 d = self._call("listkeys", namespace=encoding.fromlocal(namespace)) |
86 r = {} |
89 r = {} |
87 for l in d.splitlines(): |
90 for l in d.splitlines(): |
88 k, v = l.split('\t') |
91 k, v = l.split('\t') |
89 r[k.decode('string-escape')] = v.decode('string-escape') |
92 r[encoding.tolocal(k)] = encoding.tolocal(v) |
90 return r |
93 return r |
91 |
94 |
92 def stream_out(self): |
95 def stream_out(self): |
93 return self._callstream('stream_out') |
96 return self._callstream('stream_out') |
94 |
97 |
204 capabilities: space separated list of tokens |
207 capabilities: space separated list of tokens |
205 ''' |
208 ''' |
206 return "capabilities: %s\n" % (capabilities(repo, proto)) |
209 return "capabilities: %s\n" % (capabilities(repo, proto)) |
207 |
210 |
208 def listkeys(repo, proto, namespace): |
211 def listkeys(repo, proto, namespace): |
209 d = pushkeymod.list(repo, namespace).items() |
212 d = pushkeymod.list(repo, encoding.tolocal(namespace)).items() |
210 t = '\n'.join(['%s\t%s' % (k.encode('string-escape'), |
213 t = '\n'.join(['%s\t%s' % (encoding.fromlocal(k), encoding.fromlocal(v)) |
211 v.encode('string-escape')) for k, v in d]) |
214 for k, v in d]) |
212 return t |
215 return t |
213 |
216 |
214 def lookup(repo, proto, key): |
217 def lookup(repo, proto, key): |
215 try: |
218 try: |
216 r = hex(repo.lookup(encoding.tolocal(key))) |
219 r = hex(repo.lookup(encoding.tolocal(key))) |
219 r = str(inst) |
222 r = str(inst) |
220 success = 0 |
223 success = 0 |
221 return "%s %s\n" % (success, r) |
224 return "%s %s\n" % (success, r) |
222 |
225 |
223 def pushkey(repo, proto, namespace, key, old, new): |
226 def pushkey(repo, proto, namespace, key, old, new): |
224 r = pushkeymod.push(repo, namespace, key, old, new) |
227 # compatibility with pre-1.8 clients which were accidentally |
|
228 # sending raw binary nodes rather than utf-8-encoded hex |
|
229 if len(new) == 20 and new.encode('string-escape') != new: |
|
230 # looks like it could be a binary node |
|
231 try: |
|
232 u = new.decode('utf-8') |
|
233 new = encoding.tolocal(new) # but cleanly decodes as UTF-8 |
|
234 except UnicodeDecodeError: |
|
235 pass # binary, leave unmodified |
|
236 else: |
|
237 new = encoding.tolocal(new) # normal path |
|
238 |
|
239 r = pushkeymod.push(repo, |
|
240 encoding.tolocal(namespace), encoding.tolocal(key), |
|
241 encoding.tolocal(old), new) |
225 return '%s\n' % int(r) |
242 return '%s\n' % int(r) |
226 |
243 |
227 def _allowstream(ui): |
244 def _allowstream(ui): |
228 return ui.configbool('server', 'uncompressed', True, untrusted=True) |
245 return ui.configbool('server', 'uncompressed', True, untrusted=True) |
229 |
246 |