diff options
author | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-12 23:09:54 +0200 |
---|---|---|
committer | Kostis Anagnostopoulos <ankostis@gmail.com> | 2016-10-13 02:04:18 +0200 |
commit | 85f38a1bbc8fc4b19ebf2a52a3640b59a5dcf9fe (patch) | |
tree | 4f8df05b1a0c0f9168e86743888fcaf92dbfab5f /git/util.py | |
parent | 83645971b8e134f45bded528e0e0786819203252 (diff) | |
download | gitpython-85f38a1bbc8fc4b19ebf2a52a3640b59a5dcf9fe.tar.gz |
remote, #525: pump fetch-infos instead of GIL-read stderr
+ `handle_process_output()` accepts null-finalizer, to pump completely
stderr before raising any errors.
+ test: Enable `TestGit.test_environment()` on Windows (to checks stderr
consumption).
Diffstat (limited to 'git/util.py')
-rw-r--r-- | git/util.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/git/util.py b/git/util.py index 568d9328..7f18eed9 100644 --- a/git/util.py +++ b/git/util.py @@ -199,33 +199,34 @@ class RemoteProgress(object): DONE_TOKEN = 'done.' TOKEN_SEPARATOR = ', ' - __slots__ = ("_cur_line", "_seen_ops", "_error_lines") + __slots__ = ('_cur_line', + '_seen_ops', + 'error_lines', # Lines that started with 'error:' or 'fatal:'. + 'other_lines') # Lines not denoting progress (i.e.g. push-infos). re_op_absolute = re.compile(r"(remote: )?([\w\s]+):\s+()(\d+)()(.*)") re_op_relative = re.compile(r"(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)") def __init__(self): self._seen_ops = list() self._cur_line = None - self._error_lines = [] - - def error_lines(self): - """Returns all lines that started with error: or fatal:""" - return self._error_lines + self.error_lines = [] + self.other_lines = [] def _parse_progress_line(self, line): """Parse progress information from the given line as retrieved by git-push or git-fetch. - Lines that seem to contain an error (i.e. start with error: or fatal:) are stored - separately and can be queried using `error_lines()`. + - Lines that do not contain progress info are stored in :attr:`other_lines`. + - Lines that seem to contain an error (i.e. start with error: or fatal:) are stored + in :attr:`error_lines`. :return: list(line, ...) list of lines that could not be processed""" # handle # Counting objects: 4, done. # Compressing objects: 50% (1/2) \rCompressing objects: 100% (2/2) \rCompressing objects: 100% (2/2), done. self._cur_line = line - if len(self._error_lines) > 0 or self._cur_line.startswith(('error:', 'fatal:')): - self._error_lines.append(self._cur_line) + if len(self.error_lines) > 0 or self._cur_line.startswith(('error:', 'fatal:')): + self.error_lines.append(self._cur_line) return [] sub_lines = line.split('\r') @@ -284,6 +285,7 @@ class RemoteProgress(object): self.line_dropped(sline) # Note: Don't add this line to the failed lines, as we have to silently # drop it + self.other_lines.extend(failed_lines) return failed_lines # END handle op code @@ -309,6 +311,7 @@ class RemoteProgress(object): max_count and float(max_count), message) # END for each sub line + self.other_lines.extend(failed_lines) return failed_lines def new_message_handler(self): |