comparison mercurial/wireproto.py @ 13450:b3f9af7c22c5 stable

wireproto: catch possible cast error in pushkey The server can return an unexpected answer like 'ssl required'. We catch those possible cast errors and abort the operation.
author David Soria Parra <dsp@php.net>
date Mon, 21 Feb 2011 00:37:55 +0100
parents 3790452d499b
children 9c4e04fe267e
comparison
equal deleted inserted replaced
13449:8b1125eb361e 13450:b3f9af7c22c5
78 d = self._call("pushkey", 78 d = self._call("pushkey",
79 namespace=encoding.fromlocal(namespace), 79 namespace=encoding.fromlocal(namespace),
80 key=encoding.fromlocal(key), 80 key=encoding.fromlocal(key),
81 old=encoding.fromlocal(old), 81 old=encoding.fromlocal(old),
82 new=encoding.fromlocal(new)) 82 new=encoding.fromlocal(new))
83 return bool(int(d)) 83 try:
84 d = bool(int(d))
85 except ValueError:
86 raise error.ResponseError(
87 _('push failed (unexpected response):'), d)
88 return d
84 89
85 def listkeys(self, namespace): 90 def listkeys(self, namespace):
86 if not self.capable('pushkey'): 91 if not self.capable('pushkey'):
87 return {} 92 return {}
88 d = self._call("listkeys", namespace=encoding.fromlocal(namespace)) 93 d = self._call("listkeys", namespace=encoding.fromlocal(namespace))