@@ -538,7 +538,6 @@ def update(self, **kwargs):
538538
539539def _get_fetch_info_from_stderr (self ,proc ,progress ):
540540# skip first line as it is some remote info we are not interested in
541- # TODO: Use poll() to process stdout and stderr at same time
542541output = IterableList ('name' )
543542
544543# lines which are no progress are fetch info lines
@@ -551,9 +550,7 @@ def _get_fetch_info_from_stderr(self, proc, progress):
551550
552551progress_handler = progress .new_message_handler ()
553552
554- for line in proc .stderr :
555- line = line .decode (defenc )
556- line = line .rstrip ()
553+ def my_progress_handler (line ):
557554for pline in progress_handler (line ):
558555if line .startswith ('fatal:' )or line .startswith ('error:' ):
559556raise GitCommandError (("Error when fetching: %s" % line ,),2 )
@@ -568,12 +565,7 @@ def _get_fetch_info_from_stderr(self, proc, progress):
568565# end
569566
570567# We are only interested in stderr here ...
571- try :
572- finalize_process (proc )
573- except Exception :
574- if len (fetch_info_lines )== 0 :
575- raise
576- # end exception handler
568+ handle_process_output (proc ,None ,my_progress_handler ,finalize_process )
577569
578570# read head information
579571fp = open (join (self .repo .git_dir ,'FETCH_HEAD' ),'rb' )
@@ -593,7 +585,6 @@ def _get_push_info(self, proc, progress):
593585# we hope stdout can hold all the data, it should ...
594586# read the lines manually as it will use carriage returns between the messages
595587# to override the previous one. This is why we read the bytes manually
596- # TODO: poll() on file descriptors to know what to read next, process streams concurrently
597588progress_handler = progress .new_message_handler ()
598589output = IterableList ('name' )
599590
@@ -647,7 +638,6 @@ def fetch(self, refspec=None, progress=None, **kwargs):
647638args = [refspec ]
648639
649640proc = self .repo .git .fetch (self ,* args ,with_extended_output = True ,as_process = True ,v = True ,** kwargs )
650- proc .stdout .close ()
651641res = self ._get_fetch_info_from_stderr (proc ,progress or RemoteProgress ())
652642if hasattr (self .repo .odb ,'update_cache' ):
653643self .repo .odb .update_cache ()
@@ -663,7 +653,6 @@ def pull(self, refspec=None, progress=None, **kwargs):
663653 :return: Please see 'fetch' method """
664654kwargs = add_progress (kwargs ,self .repo .git ,progress )
665655proc = self .repo .git .pull (self ,refspec ,with_extended_output = True ,as_process = True ,v = True ,** kwargs )
666- proc .stdout .close ()
667656res = self ._get_fetch_info_from_stderr (proc ,progress or RemoteProgress ())
668657if hasattr (self .repo .odb ,'update_cache' ):
669658self .repo .odb .update_cache ()