##// END OF EJS Templates
git: make sure we don't break streaming in case of empty pull messages....
marcink -
r273:6ed1dd13 default
parent child Browse files
Show More
@@ -229,7 +229,7 b' class GitRepository(object):'
229 def _inject_messages_to_response(self, response, capabilities,
229 def _inject_messages_to_response(self, response, capabilities,
230 start_messages, end_messages):
230 start_messages, end_messages):
231 """
231 """
232 Given a list reponse we inject the pre/post-pull messages.
232 Given a list response we inject the pre/post-pull messages.
233
233
234 We only inject the messages if the client supports sideband, and the
234 We only inject the messages if the client supports sideband, and the
235 response has the format:
235 response has the format:
@@ -241,13 +241,18 b' class GitRepository(object):'
241 if not self.SIDE_BAND_CAPS.intersection(capabilities):
241 if not self.SIDE_BAND_CAPS.intersection(capabilities):
242 return response
242 return response
243
243
244 if not start_messages and not end_messages:
245 return response
246
247 # make a list out of response if it's an iterator
248 # so we can investigate it for message injection.
249 if hasattr(response, '__iter__'):
250 response = list(response)
251
244 if (not response[0].startswith('0008NAK\n') or
252 if (not response[0].startswith('0008NAK\n') or
245 not response[-1].endswith('0000')):
253 not response[-1].endswith('0000')):
246 return response
254 return response
247
255
248 if not start_messages and not end_messages:
249 return response
250
251 new_response = ['0008NAK\n']
256 new_response = ['0008NAK\n']
252 new_response.extend(self._get_messages(start_messages, capabilities))
257 new_response.extend(self._get_messages(start_messages, capabilities))
253 if len(response) == 1:
258 if len(response) == 1:
@@ -303,6 +308,7 b' class GitRepository(object):'
303 git_command.encode('utf8'))
308 git_command.encode('utf8'))
304 resp.charset = None
309 resp.charset = None
305
310
311 pre_pull_messages = ''
306 if git_command == 'git-upload-pack':
312 if git_command == 'git-upload-pack':
307 status, pre_pull_messages = hooks.git_pre_pull(self.extras)
313 status, pre_pull_messages = hooks.git_pre_pull(self.extras)
308 if status != 0:
314 if status != 0:
@@ -352,7 +358,6 b' class GitRepository(object):'
352 pass
358 pass
353
359
354 if git_command == 'git-upload-pack':
360 if git_command == 'git-upload-pack':
355 out = list(out)
356 unused_status, post_pull_messages = hooks.git_post_pull(self.extras)
361 unused_status, post_pull_messages = hooks.git_post_pull(self.extras)
357 resp.app_iter = self._inject_messages_to_response(
362 resp.app_iter = self._inject_messages_to_response(
358 out, capabilities, pre_pull_messages, post_pull_messages)
363 out, capabilities, pre_pull_messages, post_pull_messages)
General Comments 1
Approved

Build Succeeded. Build log: xxx

You need to be logged in to leave comments. Login now