def missing(self): try: self.attempt() log.debug("Recombination with patches successful, ready to create review") except RecombinationFailed as e: self.upload() status = e.args[0] suggested_solution = e.args[1] if not suggested_solution: suggested_solution=" No clue why this may have happened." message = '''Cherry pick failed with status: %s %s Manual conflict resolution is needed. Follow this steps to unblock this recombination: git review -d %s git cherry-pick -x %s solve the conflicts, then git commit -a --amend changing recombine-status to SUCCESSFUL. Limit any eventual other modifications to sources.main.body *ONLY*, then update review as usual with git review -D If you decide to discard this pick instead, please comment to this change with a single line: DISCARD''' % (status, suggested_solution, self.number, self.evolution_change.revision ) self.comment(message, verified="-1") else: self.upload()
def scan_original_distance(self, original_branch): replica_branch = self.underlayer.branch_maps['original->replica'][original_branch] target_branch = self.underlayer.branch_maps['original->target'][original_branch] log.debug("Scanning distance from original branch %s" % original_branch) # if self.replication_strategy == "change-by-change" and revision_exists(self.ref_locks[replica_branch], replica_branch): # log.info("Cannot replicate branch past the specified lock") self.recombinations[original_branch] = self.get_recombinations_by_interval(original_branch) slices = self.get_slices(self.recombinations[original_branch]) recombinations = self.recombinations[original_branch] log.debugvar('slices') # Master sync on merged changes # we really need only the last commit in the slice # we advance the master to that, and all the others will be merged too if slices['MERGED']: # one or more changes are merged in midstream, but missing in master # master is out of sync, changes need to be pushed # but check first if the change was changed with a merge commit # if yes, push THAT to master, if not, it's just a fast forward segment = slices['MERGED'][0] recomb_id = list(recombinations)[segment['end'] - 1] recombination = recombinations[recomb_id] recombination.handle_status() # Gerrit operations from approved changes # NOthing 'approved' can be merged if it has some "present" before in the history skip_list = set() for index, approved_segment in enumerate(slices['APPROVED']): for present_segment in slices['PRESENT']: if present_segment['start'] < approved_segment['start']: skip_list.add(index) for index in list(skip_list)[::-1]: segment = slices['APPROVED'].pop(index) for recomb_id in list(recombinations)[segment['start']:segment['end']]: log.warning("Recombination %s is approved but waiting for previous unapproved changes, skipping" % recomb_id) # Merge what remains for segment in slices['APPROVED']: for recomb_id in list(recombinations)[segment['start']:segment['end']]: recombination = recombinations[recomb_id] recombination.handle_status() # Notify of presence for segment in slices['PRESENT']: for recomb_id in list(recombinations)[segment['start']:segment['end']]: recombination = recombinations[recomb_id] log.warning("Recombination %s already present in replica gerrit as change %s and waiting for approval" % (recomb_id, recombination.number)) recombination.handle_status() # Gerrit operations for missing changes for segment in slices['MISSING']: for recomb_id in list(recombinations)[segment['start']:segment['end']]: log.warning("Recombination %s is missing from replica gerrit" % recomb_id) recombination = recombinations[recomb_id] recombination.handle_status() return True
def load_change_data(self, change_data): """ Common load operations for all recombination types """ self.load_data(change_data) log.debug(self.commit_message) try: metadata = yaml.load(self.commit_message) except (ValueError, yaml.scanner.ScannerError,yaml.parser.ParserError): log.error("commit message not in yaml") raise DecodeError header = metadata['Recombination'] recomb_header = header.split('~')[0] metadata['recomb-type'] = re.sub(':[a-zA-Z0-9]{6}', '',recomb_header) if 'recombine-status' in metadata: self.status = metadata['recombine-status'] metadata.update(self.analyze_comments()) self.set_status(metadata=metadata) return metadata
def scan_original_distance(self, original_branch): replica_branch = self.underlayer.branch_maps['original->replica'][ original_branch] target_branch = self.underlayer.branch_maps['original->target'][ original_branch] log.debug("Scanning distance from original branch %s" % original_branch) # if self.replication_strategy == "change-by-change" and revision_exists(self.ref_locks[replica_branch], replica_branch): # log.info("Cannot replicate branch past the specified lock") self.recombinations[ original_branch] = self.get_recombinations_by_interval( original_branch) slices = self.get_slices(self.recombinations[original_branch]) recombinations = self.recombinations[original_branch] log.debugvar('slices') # Master sync on merged changes # we really need only the last commit in the slice # we advance the master to that, and all the others will be merged too if slices['MERGED']: # one or more changes are merged in midstream, but missing in master # master is out of sync, changes need to be pushed # but check first if the change was changed with a merge commit # if yes, push THAT to master, if not, it's just a fast forward segment = slices['MERGED'][0] recomb_id = list(recombinations)[segment['end'] - 1] recombination = recombinations[recomb_id] recombination.handle_status() # Gerrit operations from approved changes # NOthing 'approved' can be merged if it has some "present" before in the history skip_list = set() for index, approved_segment in enumerate(slices['APPROVED']): for present_segment in slices['PRESENT']: if present_segment['start'] < approved_segment['start']: skip_list.add(index) for index in list(skip_list)[::-1]: segment = slices['APPROVED'].pop(index) for recomb_id in list( recombinations)[segment['start']:segment['end']]: log.warning( "Recombination %s is approved but waiting for previous unapproved changes, skipping" % recomb_id) # Merge what remains for segment in slices['APPROVED']: for recomb_id in list( recombinations)[segment['start']:segment['end']]: recombination = recombinations[recomb_id] recombination.handle_status() # Notify of presence for segment in slices['PRESENT']: for recomb_id in list( recombinations)[segment['start']:segment['end']]: recombination = recombinations[recomb_id] log.warning( "Recombination %s already present in replica gerrit as change %s and waiting for approval" % (recomb_id, recombination.number)) recombination.handle_status() # Gerrit operations for missing changes for segment in slices['MISSING']: for recomb_id in list( recombinations)[segment['start']:segment['end']]: log.warning("Recombination %s is missing from replica gerrit" % recomb_id) recombination = recombinations[recomb_id] recombination.handle_status() return True
def attempt(self): try: self.underlayer.merge_recombine(self) log.debug("Merge check with master-patches successful, ready to create review") except AttemptError: raise AttemptError