47
47
log .addHandler (logging .NullHandler ())
48
48
49
49
50
- __all__ = ('RemoteProgress' , 'PushInfo' , 'FetchInfo' , 'Remote' )
50
+ __all__ = ('RemoteProgress' , 'PushInfo' , 'PushInfoList' , ' FetchInfo' , 'Remote' )
51
51
52
52
#{ Utilities
53
53
@@ -84,6 +84,19 @@ def to_progress_instance(progress):
84
84
return progress
85
85
86
86
87
+ class PushInfoList (list ):
88
+ def __init__ (self ):
89
+ super ().__init__ ()
90
+ self .exception = None
91
+
92
+ def raise_on_error (self ):
93
+ """
94
+ Raise an exception if any ref failed to push.
95
+ """
96
+ if self .exception :
97
+ raise self .exception
98
+
99
+
87
100
class PushInfo (object ):
88
101
"""
89
102
Carries information about the result of a push operation of a single head::
@@ -728,7 +741,7 @@ def _get_push_info(self, proc, progress):
728
741
# read the lines manually as it will use carriage returns between the messages
729
742
# to override the previous one. This is why we read the bytes manually
730
743
progress_handler = progress .new_message_handler ()
731
- output = []
744
+ output = PushInfoList ()
732
745
733
746
def stdout_handler (line ):
734
747
try :
@@ -741,11 +754,12 @@ def stdout_handler(line):
741
754
stderr_text = progress .error_lines and '\n ' .join (progress .error_lines ) or ''
742
755
try :
743
756
proc .wait (stderr = stderr_text )
744
- except Exception :
757
+ except Exception as e :
745
758
if not output :
746
759
raise
747
760
elif stderr_text :
748
- log .warning ("Error lines received while fetching: %s" , stderr_text )
761
+ log .warning ("Error lines received while pushing: %s" , stderr_text )
762
+ output .exception = e
749
763
750
764
return output
751
765
@@ -843,7 +857,7 @@ def push(self, refspec=None, progress=None, **kwargs):
843
857
:note: No further progress information is returned after push returns.
844
858
:param kwargs: Additional arguments to be passed to git-push
845
859
:return:
846
- list(PushInfo, ...) list of PushInfo instances, each
860
+ PushInfoList list-like of PushInfo instances, each
847
861
one informing about an individual head which had been updated on the remote
848
862
side.
849
863
If the push contains rejected heads, these will have the PushInfo.ERROR bit set
0 commit comments