diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-03 16:59:22 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-03 17:00:28 +0100 |
commit | 0c4269a21b9edf8477f2fee139d5c1b260ebc4f8 (patch) | |
tree | 07ecdb98f26b0108576000506fd70b3060c76a11 /lib/git/remote.py | |
parent | 3cb5ba18ab1a875ef6b62c65342de476be47871b (diff) | |
download | gitpython-0c4269a21b9edf8477f2fee139d5c1b260ebc4f8.tar.gz |
remote.push: Fixed progress parsing, previously it would read whole lines only which is equivalent to waiting for an operation to finish completely. Now we parse the stream manually, allowing to retrieve progress information as soon as it happens
Diffstat (limited to 'lib/git/remote.py')
-rw-r--r-- | lib/git/remote.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/git/remote.py b/lib/git/remote.py index 1b9c5360..5019daee 100644 --- a/lib/git/remote.py +++ b/lib/git/remote.py @@ -573,9 +573,21 @@ class Remote(LazyMixin, Iterable): def _get_push_info(self, proc, progress): # read progress information from stderr - # we hope stdout can hold all the data, it should ... - for line in proc.stderr.readlines(): - progress._parse_progress_line(line.rstrip()) + # we hope stdout can hold all the data, it should ... + # read the lines manually as it will use carriage returns between the messages + # to override the previous one. This is why we read the bytes manually + line_so_far = '' + while True: + char = proc.stderr.read(1) + if not char: + break + + if char in ('\r', '\n'): + progress._parse_progress_line(line_so_far) + line_so_far = '' + else: + line_so_far += char + # END process parsed line # END for each progress line output = IterableList('name') |