##// END OF EJS Templates
fix(svn): more binary protocol svn ssh fixes
super-admin -
r5333:545f9333 default
parent child Browse files
Show More
@@ -25,7 +25,6 b' import tempfile'
25 from subprocess import Popen, PIPE
25 from subprocess import Popen, PIPE
26 import urllib.parse
26 import urllib.parse
27
27
28 from rhodecode.lib.str_utils import safe_bytes
29 from rhodecode_tools.lib.utils import safe_str
28 from rhodecode_tools.lib.utils import safe_str
30 from .base import SshVcsServer
29 from .base import SshVcsServer
31
30
@@ -103,19 +102,27 b' class SubversionTunnelWrapper(object):'
103
102
104 def patch_first_client_response(self, response, **kwargs):
103 def patch_first_client_response(self, response, **kwargs):
105 self.create_hooks_env()
104 self.create_hooks_env()
106 data = response.copy()
105
107 data.update(kwargs)
106 version = response['version']
108 data['url'] = self._svn_string(data['url'])
107 capabilities = response['capabilities']
109 data['ra_client'] = self._svn_string(data['ra_client'])
108 client = response['client'] or b''
110 data['client'] = data['client'] or ''
109
111 buffer_ = safe_bytes(
110 url = self._svn_bytes(response['url'])
112 "( {version} ( {capabilities} ) {url}{ra_client}"
111 ra_client = self._svn_bytes(response['ra_client'])
113 "( {client}) ) ".format(**data))
112
113 buffer_ = b"( %b ( %b ) %b%b( %b) ) " % (
114 version,
115 capabilities,
116 url,
117 ra_client,
118 client
119 )
114 self.process.stdin.write(buffer_)
120 self.process.stdin.write(buffer_)
115
121
116 def fail(self, message):
122 def fail(self, message):
117 print("( failure ( ( 210005 {message} 0: 0 ) ) )".format(
123 fail_msg = b"( failure ( ( 210005 %b 0: 0 ) ) )" % self._svn_bytes(message)
118 message=self._svn_string(message)))
124 sys.stdout.buffer.write(fail_msg)
125 sys.stdout.flush()
119 self.remove_configs()
126 self.remove_configs()
120 self.process.kill()
127 self.process.kill()
121 return 1
128 return 1
@@ -123,10 +130,11 b' class SubversionTunnelWrapper(object):'
123 def interrupt(self, signum, frame):
130 def interrupt(self, signum, frame):
124 self.fail("Exited by timeout")
131 self.fail("Exited by timeout")
125
132
126 def _svn_string(self, str_):
133 def _svn_bytes(self, bytes_: bytes) -> bytes:
127 if not str_:
134 if not bytes_:
128 return ''
135 return b''
129 return f'{len(str_)}:{str_} '
136
137 return f'{len(bytes_)}:'.encode() + bytes_ + b' '
130
138
131 def _read_first_client_response(self):
139 def _read_first_client_response(self):
132 buffer_ = b""
140 buffer_ = b""
General Comments 0
You need to be logged in to leave comments. Login now