@@ -538,7 +538,6 @@ def update(self, **kwargs):
538
538
539
539
def _get_fetch_info_from_stderr (self , proc , progress ):
540
540
# 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
542
541
output = IterableList ('name' )
543
542
544
543
# lines which are no progress are fetch info lines
@@ -551,11 +550,9 @@ def _get_fetch_info_from_stderr(self, proc, progress):
551
550
552
551
progress_handler = progress .new_message_handler ()
553
552
554
- for line in proc .stderr :
555
- line = line .decode (defenc )
556
- line = line .rstrip ()
553
+ def my_progress_handler (line ):
557
554
for pline in progress_handler (line ):
558
- if line .startswith ('fatal:' ):
555
+ if line .startswith ('fatal:' ) or line . startswith ( 'error:' ) :
559
556
raise GitCommandError (("Error when fetching: %s" % line ,), 2 )
560
557
# END handle special messages
561
558
for cmd in cmds :
@@ -568,12 +565,7 @@ def _get_fetch_info_from_stderr(self, proc, progress):
568
565
# end
569
566
570
567
# 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 )
577
569
578
570
# read head information
579
571
fp = open (join (self .repo .git_dir , 'FETCH_HEAD' ), 'rb' )
@@ -593,7 +585,6 @@ def _get_push_info(self, proc, progress):
593
585
# we hope stdout can hold all the data, it should ...
594
586
# read the lines manually as it will use carriage returns between the messages
595
587
# 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
597
588
progress_handler = progress .new_message_handler ()
598
589
output = IterableList ('name' )
599
590
@@ -647,7 +638,6 @@ def fetch(self, refspec=None, progress=None, **kwargs):
647
638
args = [refspec ]
648
639
649
640
proc = self .repo .git .fetch (self , * args , with_extended_output = True , as_process = True , v = True , ** kwargs )
650
- proc .stdout .close ()
651
641
res = self ._get_fetch_info_from_stderr (proc , progress or RemoteProgress ())
652
642
if hasattr (self .repo .odb , 'update_cache' ):
653
643
self .repo .odb .update_cache ()
@@ -663,7 +653,6 @@ def pull(self, refspec=None, progress=None, **kwargs):
663
653
:return: Please see 'fetch' method """
664
654
kwargs = add_progress (kwargs , self .repo .git , progress )
665
655
proc = self .repo .git .pull (self , refspec , with_extended_output = True , as_process = True , v = True , ** kwargs )
666
- proc .stdout .close ()
667
656
res = self ._get_fetch_info_from_stderr (proc , progress or RemoteProgress ())
668
657
if hasattr (self .repo .odb , 'update_cache' ):
669
658
self .repo .odb .update_cache ()
0 commit comments