@@ -90,7 +90,8 @@ def accept(config, logpath, *changeentries):
9090 for changeEntry in changeentries :
9191 shouter .shout ("Accepting: " + changeEntry .tostring ())
9292 revisions = Changes ._collectids (changeentries )
93- Changes .latest_accept_command = config .scmcommand + " accept -v -o -r " + config .repo + " -t " + config .workspace + " --changes" + revisions
93+ Changes .latest_accept_command = config .scmcommand + " accept -v -o -r " + config .repo + " -t " + \
94+ config .workspace + " --changes" + revisions
9495 return shell .execute (Changes .latest_accept_command , logpath , "a" )
9596
9697 @staticmethod
@@ -100,6 +101,21 @@ def _collectids(changeentries):
100101 ids += " " + changeentry .revision
101102 return ids
102103
104+ @staticmethod
105+ def arereleatedmergechangesets (changeentry1 , changeentry2 ):
106+ if changeentry1 and changeentry2 :
107+ if changeentry1 .author == changeentry2 .author or "merge" in changeentry2 .comment .lower ():
108+ return True
109+ return False
110+
111+ @staticmethod
112+ def tostring (* changes ):
113+ logmessage = "Changes: \n "
114+ for change in changes :
115+ logmessage += change .tostring () + "\n "
116+ shouter .shout (logmessage )
117+
118+
103119
104120class ImportHandler :
105121 def __init__ (self , config ):
@@ -168,51 +184,80 @@ def determineinitialbaseline(self, stream):
168184 return componentbaselinesentries
169185
170186 def acceptchangesintoworkspace (self , changeentries ):
171- git = Commiter
172187 amountofchanges = len (changeentries )
173188 shouter .shoutwithdate ("Start accepting %s changesets" % amountofchanges )
174189 amountofacceptedchanges = 0
175- skipnextchangeset = False
190+ changestoskip = 0
176191 reloaded = False
177192 for changeEntry in changeentries :
178193 amountofacceptedchanges += 1
179- if skipnextchangeset :
180- skipnextchangeset = False
194+ if changestoskip > 0 :
195+ shouter .shout ("Skipping " + changeEntry .tostring ())
196+ changestoskip -= 1
181197 continue
182198 acceptedsuccesfully = Changes .accept (self .config , self .acceptlogpath ,
183199 changeEntry ) is 0
184200 if not acceptedsuccesfully :
185201 shouter .shout ("Change wasnt succesfully accepted into workspace" )
186- skipnextchangeset = self .retryacceptincludingnextchangeset (changeEntry , changeentries )
202+ changestoskip = self .retryacceptincludingnextchangesets (changeEntry , changeentries )
187203 elif not reloaded :
188204 if self .is_reloading_necessary ():
189205 WorkspaceHandler (self .config ).load ()
190206 reloaded = True
191207 shouter .shout ("Accepted change %s/%s into working directory" % (amountofacceptedchanges , amountofchanges ))
192- git .addandcommit (changeEntry )
208+ Commiter .addandcommit (changeEntry )
193209
194210 @staticmethod
195211 def is_reloading_necessary ():
196212 return shell .execute ("git diff --exit-code" ) is 0
197213
198- def retryacceptincludingnextchangeset (self , change , changes ):
199- successfull = False
200- nextchangeentry = self .getnextchangeset (change , changes )
201- if nextchangeentry and (change .author == nextchangeentry .author or "merge" in nextchangeentry .comment .lower ()):
202- shouter .shout ("Next changeset: " + nextchangeentry .tostring ())
203- if (not self .config .useautomaticconflictresolution ) and input ("Press Enter to try to accept it with next changeset together, press any other key to skip this changeset and continue" ):
204- return False
205- Changes .discard (self .config , change )
206- successfull = Changes .accept (self .config , self .acceptlogpath , change , nextchangeentry ) is 0
207- if not successfull :
208- Changes .discard (self .config , change , nextchangeentry )
209-
210- if not successfull :
211- shouter .shout ("Last executed command: \n " + Changes .latest_accept_command )
212- shouter .shout ("Apropriate git commit command \n " + Commiter .getcommitcommand (change ))
213- if not input ("Press Enter to continue or any other key to exit the program and rerun it with resume" ):
214- sys .exit ("Please check the output and rerun programm with resume" )
215- return successfull
214+ @staticmethod
215+ def collect_changes_to_accept_to_avoid_conflicts (changewhichcantacceptedallone , changes ):
216+ changestoaccept = [changewhichcantacceptedallone ]
217+ nextchange = ImportHandler .getnextchangeset (changewhichcantacceptedallone , changes )
218+
219+ while True :
220+ if Changes .arereleatedmergechangesets (changewhichcantacceptedallone , nextchange ):
221+ changestoaccept .append (nextchange )
222+ nextchange = ImportHandler .getnextchangeset (nextchange , changes )
223+ else :
224+ break
225+ return changestoaccept
226+
227+ def retryacceptincludingnextchangesets (self , change , changes ):
228+ changestoskip = 0
229+ changestoaccept = ImportHandler .collect_changes_to_accept_to_avoid_conflicts (change , changes )
230+ amountofchangestoaccept = len (changestoaccept )
231+
232+ if amountofchangestoaccept > 1 :
233+ Changes .tostring (* changestoaccept )
234+ if self .config .useautomaticconflictresolution or self .is_user_agreeing_to_accept_next_change (change ):
235+ for index in range (1 , amountofchangestoaccept ):
236+ toaccept = changestoaccept [0 :index + 1 ] # accept least possible amount of changes
237+ if Changes .accept (self .config , self .acceptlogpath , * toaccept ) is 0 :
238+ changestoskip = len (toaccept ) - 1 # initialchange shouldnt be skipped
239+ break
240+ else :
241+ Changes .discard (self .config , * toaccept ) # revert initial state
242+ return changestoskip
243+
244+ @staticmethod
245+ def is_user_agreeing_to_accept_next_change (change ):
246+ messagetoask = "Press Y for accepting following changes, press N to skip"
247+ while True :
248+ answer = input (messagetoask ).lower ()
249+ if answer == "y" :
250+ return True
251+ elif answer == "n" :
252+ shouter .shout ("Last executed command: \n " + Changes .latest_accept_command )
253+ shouter .shout ("Apropriate git commit command \n " + Commiter .getcommitcommand (change ))
254+ reallycontinue = "Do you want to continue? Y for continue, any key for abort"
255+ if input (reallycontinue ).lower () == "y" :
256+ return False
257+ else :
258+ sys .exit ("Please check the output/log and rerun program with resume" )
259+ else :
260+ shouter .shout ("Please answer with Y/N, input was " + answer )
216261
217262 @staticmethod
218263 def getnextchangeset (currentchangeentry , changeentries ):
@@ -228,6 +273,8 @@ def getchangeentriesofstreamcomponents(self, componentbaselineentries):
228273 shouter .shout ("Start collecting changeentries" )
229274 changeentriesbycomponentbaselineentry = {}
230275 for componentBaseLineEntry in componentbaselineentries :
276+ shouter .shout ("Collect changes until baseline %s of component %s" %
277+ (componentBaseLineEntry .baselinename , componentBaseLineEntry .componentname ))
231278 changeentries = self .getchangeentriesofbaseline (componentBaseLineEntry .baseline )
232279 for changeentry in changeentries :
233280 missingchangeentries [changeentry .revision ] = changeentry
0 commit comments