mirror of
				https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
				synced 2025-11-04 10:34:05 +00:00 
			
		
		
		
	Make "affected" a set based on the usage of it
"affected" is not allowed to contain duplicates. Since the current method of removing any such duplicates is affected = list(set(affected)) then the order of affected is not important. As a side effect, make get_reverse_tree return a set instead of a list as its return value is always inserted into affected. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
		
							parent
							
								
									de8765e918
								
							
						
					
					
						commit
						f48897a3ba
					
				
							
								
								
									
										29
									
								
								britney.py
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								britney.py
									
									
									
									
									
								
							@ -1771,12 +1771,12 @@ class Britney:
 | 
				
			|||||||
        them so it will be possible to revert them.
 | 
					        them so it will be possible to revert them.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        The method returns a list of the package name, the suite where the
 | 
					        The method returns a list of the package name, the suite where the
 | 
				
			||||||
        package comes from, the list of packages affected by the change and
 | 
					        package comes from, the set of packages affected by the change and
 | 
				
			||||||
        the dictionary undo which can be used to rollback the changes.
 | 
					        the dictionary undo which can be used to rollback the changes.
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
        undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []}
 | 
					        undo = {'binaries': {}, 'sources': {}, 'virtual': {}, 'nvirtual': []}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        affected = []
 | 
					        affected = set()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # local copies for better performances
 | 
					        # local copies for better performances
 | 
				
			||||||
        sources = self.sources
 | 
					        sources = self.sources
 | 
				
			||||||
@ -1836,9 +1836,8 @@ class Britney:
 | 
				
			|||||||
                    # save the old binary for undo
 | 
					                    # save the old binary for undo
 | 
				
			||||||
                    undo['binaries'][p] = binaries[parch][0][binary]
 | 
					                    undo['binaries'][p] = binaries[parch][0][binary]
 | 
				
			||||||
                    # all the reverse dependencies are affected by the change
 | 
					                    # all the reverse dependencies are affected by the change
 | 
				
			||||||
                    affected.extend( [ (x, parch) for x in \
 | 
					                    affected.update( [ (x, parch) for x in \
 | 
				
			||||||
                                       self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
					                                       self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
				
			||||||
                    affected = list(set(affected))
 | 
					 | 
				
			||||||
                    # remove the provided virtual packages
 | 
					                    # remove the provided virtual packages
 | 
				
			||||||
                    for j in binaries[parch][0][binary][PROVIDES]:
 | 
					                    for j in binaries[parch][0][binary][PROVIDES]:
 | 
				
			||||||
                        key = j + "/" + parch
 | 
					                        key = j + "/" + parch
 | 
				
			||||||
@ -1862,9 +1861,8 @@ class Britney:
 | 
				
			|||||||
        # updates but not supported as a manual hint
 | 
					        # updates but not supported as a manual hint
 | 
				
			||||||
        elif item.package in binaries[item.architecture][0]:
 | 
					        elif item.package in binaries[item.architecture][0]:
 | 
				
			||||||
            undo['binaries'][item.package + "/" + item.architecture] = binaries[item.architecture][0][item.package]
 | 
					            undo['binaries'][item.package + "/" + item.architecture] = binaries[item.architecture][0][item.package]
 | 
				
			||||||
            affected.extend( [ (x, item.architecture) for x in \
 | 
					            affected.update( [ (x, item.architecture) for x in \
 | 
				
			||||||
               self.get_reverse_tree(item.package, item.architecture, 'testing') ] )
 | 
					               self.get_reverse_tree(item.package, item.architecture, 'testing') ] )
 | 
				
			||||||
            affected = list(set(affected))
 | 
					 | 
				
			||||||
            del binaries[item.architecture][0][item.package]
 | 
					            del binaries[item.architecture][0][item.package]
 | 
				
			||||||
            self.systems[item.architecture].remove_binary(item.package)
 | 
					            self.systems[item.architecture].remove_binary(item.package)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1876,22 +1874,21 @@ class Britney:
 | 
				
			|||||||
                if item.architecture not in ['source', parch]: continue
 | 
					                if item.architecture not in ['source', parch]: continue
 | 
				
			||||||
                key = (binary, parch)
 | 
					                key = (binary, parch)
 | 
				
			||||||
                # obviously, added/modified packages are affected
 | 
					                # obviously, added/modified packages are affected
 | 
				
			||||||
                if key not in affected: affected.append(key)
 | 
					                if key not in affected: affected.add(key)
 | 
				
			||||||
                # if the binary already exists (built from another source)
 | 
					                # if the binary already exists (built from another source)
 | 
				
			||||||
                if binary in binaries[parch][0]:
 | 
					                if binary in binaries[parch][0]:
 | 
				
			||||||
                    # save the old binary package
 | 
					                    # save the old binary package
 | 
				
			||||||
                    undo['binaries'][p] = binaries[parch][0][binary]
 | 
					                    undo['binaries'][p] = binaries[parch][0][binary]
 | 
				
			||||||
                    # all the reverse dependencies are affected by the change
 | 
					                    # all the reverse dependencies are affected by the change
 | 
				
			||||||
                    affected.extend( [ (x, parch) for x in \
 | 
					                    affected.update( [ (x, parch) for x in \
 | 
				
			||||||
                                        self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
					                                        self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
				
			||||||
                    affected = list(set(affected))
 | 
					 | 
				
			||||||
                    # all the reverse conflicts and their dependency tree are affected by the change
 | 
					                    # all the reverse conflicts and their dependency tree are affected by the change
 | 
				
			||||||
                    for j in binaries[parch][0][binary][RCONFLICTS]:
 | 
					                    for j in binaries[parch][0][binary][RCONFLICTS]:
 | 
				
			||||||
                        key = (j, parch)
 | 
					                        key = (j, parch)
 | 
				
			||||||
                        if key not in affected: affected.append(key)
 | 
					                        if key not in affected: affected.add(key)
 | 
				
			||||||
                        for p in self.get_full_tree(j, parch, 'testing'):
 | 
					                        for p in self.get_full_tree(j, parch, 'testing'):
 | 
				
			||||||
                            key = (p, parch)
 | 
					                            key = (p, parch)
 | 
				
			||||||
                            if key not in affected: affected.append(key)
 | 
					                            if key not in affected: affected.add(key)
 | 
				
			||||||
                    self.systems[parch].remove_binary(binary)
 | 
					                    self.systems[parch].remove_binary(binary)
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    # if the binary was previously built by a different
 | 
					                    # if the binary was previously built by a different
 | 
				
			||||||
@ -1905,10 +1902,9 @@ class Britney:
 | 
				
			|||||||
                        if p in tundo['binaries']:
 | 
					                        if p in tundo['binaries']:
 | 
				
			||||||
                            for rdep in tundo['binaries'][p][RDEPENDS]:
 | 
					                            for rdep in tundo['binaries'][p][RDEPENDS]:
 | 
				
			||||||
                                if rdep in binaries[parch][0] and rdep not in source[BINARIES]:
 | 
					                                if rdep in binaries[parch][0] and rdep not in source[BINARIES]:
 | 
				
			||||||
                                    affected.append( (rdep, parch) )
 | 
					                                    affected.add( (rdep, parch) )
 | 
				
			||||||
                                    affected.extend( [ (x, parch) for x in \
 | 
					                                    affected.update( [ (x, parch) for x in \
 | 
				
			||||||
                                                        self.get_reverse_tree(rdep, parch, 'testing') ] )
 | 
					                                                        self.get_reverse_tree(rdep, parch, 'testing') ] )
 | 
				
			||||||
                    affected = list(set(affected))
 | 
					 | 
				
			||||||
                # add/update the binary package
 | 
					                # add/update the binary package
 | 
				
			||||||
                binaries[parch][0][binary] = self.binaries[item.suite][parch][0][binary]
 | 
					                binaries[parch][0][binary] = self.binaries[item.suite][parch][0][binary]
 | 
				
			||||||
                self.systems[parch].add_binary(binary, binaries[parch][0][binary][:PROVIDES] + \
 | 
					                self.systems[parch].add_binary(binary, binaries[parch][0][binary][:PROVIDES] + \
 | 
				
			||||||
@ -1923,9 +1919,8 @@ class Britney:
 | 
				
			|||||||
                        undo['virtual'][key] = binaries[parch][1][j][:]
 | 
					                        undo['virtual'][key] = binaries[parch][1][j][:]
 | 
				
			||||||
                    binaries[parch][1][j].append(binary)
 | 
					                    binaries[parch][1][j].append(binary)
 | 
				
			||||||
                # all the reverse dependencies are affected by the change
 | 
					                # all the reverse dependencies are affected by the change
 | 
				
			||||||
                affected.extend( [ (x, parch) for x in \
 | 
					                affected.update( [ (x, parch) for x in \
 | 
				
			||||||
                                    self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
					                                    self.get_reverse_tree(binary, parch, 'testing') ] )
 | 
				
			||||||
                affected = list(set(affected))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
            # register reverse dependencies and conflicts for the new binary packages
 | 
					            # register reverse dependencies and conflicts for the new binary packages
 | 
				
			||||||
            for p in source[BINARIES]:
 | 
					            for p in source[BINARIES]:
 | 
				
			||||||
@ -1956,7 +1951,7 @@ class Britney:
 | 
				
			|||||||
            # in the process
 | 
					            # in the process
 | 
				
			||||||
            rev_deps = set([ package for sublist in new_rev_deps \
 | 
					            rev_deps = set([ package for sublist in new_rev_deps \
 | 
				
			||||||
                             for package in sublist if package not in seen ])
 | 
					                             for package in sublist if package not in seen ])
 | 
				
			||||||
        return list(seen)
 | 
					        return seen
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_full_tree(self, pkg, arch, suite):
 | 
					    def get_full_tree(self, pkg, arch, suite):
 | 
				
			||||||
        """Calculate the full dependency tree for the given package
 | 
					        """Calculate the full dependency tree for the given package
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user