<s> """<STR_LIT>""" <EOL> import itertools <EOL> import re <EOL> import os <EOL> import tempfile <EOL> import traceback <EOL> import sys <EOL> from conary import constants <EOL> from conary . callbacks import UpdateCallback <EOL> from conary . conaryclient import cmdline , resolve <EOL> from conary . deps import deps <EOL> from conary . errors import ClientError , ConaryError , InternalConaryError , MissingTrovesError , DecodingError <EOL> from conary . lib import log , util , api <EOL> from conary . lib import cfgtypes <EOL> from conary . local import capsules <EOL> from conary . local import database <EOL> from conary . repository import changeset , trovesource , searchsource <EOL> from conary . repository . errors import TroveMissing , OpenError <EOL> from conary import trove , versions <EOL> class CriticalUpdateInfo ( object ) : <EOL> """<STR_LIT>""" <EOL> criticalTroveRegexps = [ ] <EOL> finalTroveRegexps = [ ] <EOL> def _match ( self , regexpList , jobList ) : <EOL> l = [ ] <EOL> for job in jobList : <EOL> for regexp in regexpList : <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] and re . match ( regexp , job [ <NUM_LIT:0> ] ) : <EOL> l . append ( job ) <EOL> return l <EOL> def findCriticalJobs ( self , jobList ) : <EOL> return self . _match ( self . criticalTroveRegexps , jobList ) <EOL> def setFinalTroveRegexps ( self , regexpList ) : <EOL> self . finalTroveRegexps = regexpList <EOL> @ api . publicApi <EOL> def setCriticalTroveRegexps ( self , regexpList ) : <EOL> """<STR_LIT>""" <EOL> self . criticalTroveRegexps = regexpList <EOL> def findFinalJobs ( self , jobList ) : <EOL> return self . _match ( self . finalTroveRegexps , jobList ) <EOL> def addChangeSet ( self , cs , includesFileContents ) : <EOL> """<STR_LIT>""" <EOL> self . changeSetList . append ( ( cs , includesFileContents ) ) <EOL> def iterChangeSets ( self ) : <EOL> return iter ( self . changeSetList ) <EOL> def isCriticalOnlyUpdate ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . criticalOnly <EOL> @ api . publicApi <EOL> def __init__ ( self , criticalOnly = False ) : <EOL> self . criticalOnly = criticalOnly <EOL> self . changeSetList = [ ] <EOL> class UpdateChangeSet ( changeset . ReadOnlyChangeSet ) : <EOL> def merge ( self , cs , src = None ) : <EOL> changeset . ReadOnlyChangeSet . merge ( self , cs ) <EOL> if isinstance ( cs , UpdateChangeSet ) : <EOL> self . contents += cs . contents <EOL> else : <EOL> self . contents . append ( src ) <EOL> self . empty = False <EOL> def __init__ ( self , * args ) : <EOL> changeset . ReadOnlyChangeSet . __init__ ( self , * args ) <EOL> self . contents = [ ] <EOL> self . empty = True <EOL> class ClientUpdate ( object ) : <EOL> @ staticmethod <EOL> def revertJournal ( cfg ) : <EOL> try : <EOL> database . Database . revertJournal ( cfg . root , cfg . dbPath ) <EOL> except database . OpenError , e : <EOL> log . error ( str ( e ) ) <EOL> def __init__ ( self , callback = None ) : <EOL> self . updateCallback = None <EOL> self . setUpdateCallback ( callback ) <EOL> self . lzCache = util . LazyFileCache ( ) <EOL> @ api . publicApi <EOL> def getUpdateCallback ( self ) : <EOL> return self . updateCallback <EOL> @ api . publicApi <EOL> def setUpdateCallback ( self , callback ) : <EOL> """<STR_LIT>""" <EOL> assert ( callback is None or isinstance ( callback , UpdateCallback ) ) <EOL> self . updateCallback = callback <EOL> return self <EOL> def _resolveDependencies ( self , uJob , jobSet , split = False , <EOL> resolveDeps = True , useRepos = True , <EOL> resolveSource = None , keepRequired = True , <EOL> criticalUpdateInfo = None ) : <EOL> return self . resolver . resolveDependencies ( uJob , jobSet , split = split , <EOL> resolveDeps = resolveDeps , <EOL> useRepos = useRepos , <EOL> resolveSource = resolveSource , <EOL> keepRequired = keepRequired , <EOL> criticalUpdateInfo = criticalUpdateInfo ) <EOL> def _processRedirects ( self , csSource , uJob , jobSet , transitiveClosure , <EOL> recurse ) : <EOL> """<STR_LIT>""" <EOL> redirectHack = { } <EOL> jobsToRemove = [ ] <EOL> jobsToAdd = [ ] <EOL> transitiveClosureToRemove = [ ] <EOL> initialSet = itertools . izip ( itertools . repeat ( True ) , jobSet ) <EOL> while initialSet : <EOL> alreadyHandled = set ( ) <EOL> nextSet = set ( ) <EOL> toDoSet = util . IterableQueue ( ) <EOL> for isPrimary , job in itertools . chain ( initialSet , toDoSet ) : <EOL> ( name , ( oldVersion , oldFlavor ) , ( newVersion , newFlavor ) , <EOL> isAbsolute ) = job <EOL> item = ( name , newVersion , newFlavor ) <EOL> if item in alreadyHandled : <EOL> continue <EOL> alreadyHandled . add ( item ) <EOL> if newVersion is None : <EOL> continue <EOL> trv = uJob . getTroveSource ( ) . getTrove ( name , newVersion , <EOL> newFlavor , <EOL> withFiles = False ) <EOL> if not trv . isRedirect ( ) : <EOL> continue <EOL> if item in redirectHack : <EOL> redirectSourceList = redirectHack [ item ] <EOL> del redirectHack [ item ] <EOL> else : <EOL> redirectSourceList = [ ] <EOL> if isPrimary : <EOL> jobsToRemove . append ( job ) <EOL> else : <EOL> transitiveClosureToRemove . append ( job ) <EOL> if not recurse : <EOL> raise UpdateError , "<STR_LIT>" % item <EOL> allTargets = [ ( x [ <NUM_LIT:0> ] , str ( x [ <NUM_LIT:1> ] . label ( ) ) , x [ <NUM_LIT:2> ] ) <EOL> for x in trv . iterRedirects ( ) ] <EOL> for troveSpec in allTargets : <EOL> if ( troveSpec [ <NUM_LIT:0> ] == trv . getName ( ) <EOL> and troveSpec [ <NUM_LIT:1> ] == str ( trv . getVersion ( ) . trailingLabel ( ) ) <EOL> and troveSpec [ <NUM_LIT:2> ] is None ) : <EOL> allTargets = list ( trv . iterRedirects ( ) ) <EOL> break <EOL> matches = self . repos . findTroves ( [ ] , allTargets , self . cfg . flavor , <EOL> affinityDatabase = self . db ) <EOL> if not matches : <EOL> assert ( not allTargets ) <EOL> l = redirectHack . setdefault ( None , redirectSourceList ) <EOL> l . append ( item ) <EOL> else : <EOL> for matchList in matches . itervalues ( ) : <EOL> for match in matchList : <EOL> if match in redirectSourceList : <EOL> raise UpdateError , "<STR_LIT>" "<STR_LIT>" % ( item [ <NUM_LIT:0> ] , <EOL> "<STR_LIT:U+002CU+0020>" . join ( x [ <NUM_LIT:0> ] for x in redirectSourceList ) ) <EOL> assert ( match not in redirectSourceList ) <EOL> l = redirectHack . setdefault ( match , <EOL> redirectSourceList [ : ] ) <EOL> l . append ( item ) <EOL> redirectJob = ( match [ <NUM_LIT:0> ] , ( None , None ) , <EOL> match [ <NUM_LIT:1> : ] , True ) <EOL> nextSet . add ( ( isPrimary , redirectJob ) ) <EOL> if isPrimary : <EOL> jobsToAdd . append ( redirectJob ) <EOL> for info in trv . iterTroveList ( strongRefs = True ) : <EOL> toDoSet . add ( ( False , <EOL> ( info [ <NUM_LIT:0> ] , ( None , None ) , info [ <NUM_LIT:1> : ] , True ) ) ) <EOL> nextSet = list ( nextSet ) <EOL> hasTroves = uJob . getTroveSource ( ) . hasTroves ( [ <EOL> ( x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in nextSet ] ) <EOL> nextSet = [ x [ <NUM_LIT:0> ] for x in itertools . izip ( nextSet , hasTroves ) if not x [ <NUM_LIT:1> ] ] <EOL> redirectCs , notFound = csSource . createChangeSet ( <EOL> [ x [ <NUM_LIT:1> ] for x in nextSet ] , <EOL> withFiles = False , recurse = True ) <EOL> uJob . getTroveSource ( ) . addChangeSet ( redirectCs ) <EOL> transitiveClosure . update ( redirectCs . getJobSet ( primaries = False ) ) <EOL> initialSet = nextSet <EOL> jobSet . update ( jobsToAdd ) <EOL> jobSet . difference_update ( jobsToRemove ) <EOL> transitiveClosure . difference_update ( transitiveClosureToRemove ) <EOL> transitiveClosure . difference_update ( jobsToRemove ) <EOL> for l in redirectHack . itervalues ( ) : <EOL> outdated = self . db . outdatedTroves ( l ) <EOL> del l [ : ] <EOL> for ( name , newVersion , newFlavor ) , ( oldName , oldVersion , oldFlavor ) in outdated . iteritems ( ) : <EOL> if oldVersion is not None : <EOL> l . append ( ( oldName , oldVersion , oldFlavor ) ) <EOL> return redirectHack <EOL> def _mergeGroupChanges ( self , uJob , primaryJobList , transitiveClosure , <EOL> redirectHack , recurse , ineligible , checkPrimaryPins , <EOL> installedPrimaries , installMissingRefs = False , <EOL> updateOnly = False , respectBranchAffinity = True , <EOL> alwaysFollowLocalChanges = False , <EOL> removeNotByDefault = False ) : <EOL> def lookupPathHashes ( infoList , old = False ) : <EOL> result = [ ] <EOL> if old : <EOL> for s in self . db . getPathHashesForTroveList ( infoList ) : <EOL> if s is None : <EOL> result . append ( set ( ) ) <EOL> else : <EOL> result . append ( s ) <EOL> return result <EOL> else : <EOL> troveSource = uJob . getTroveSource ( ) <EOL> hasTroveList = troveSource . hasTroves ( infoList ) <EOL> for info , hasTrove in itertools . izip ( infoList , hasTroveList ) : <EOL> if hasTrove : <EOL> ph = troveSource . getTrove ( withFiles = False , * info ) . getPathHashes ( ) <EOL> result . append ( ph ) <EOL> else : <EOL> result . append ( set ( ) ) <EOL> return result <EOL> def _findErasures ( primaryErases , newJob , referencedTroves , recurse , <EOL> ineligible ) : <EOL> class ErasureInfoCache : <EOL> def __init__ ( self , db ) : <EOL> self . db = db <EOL> self . hasTrovesCache = { } <EOL> self . pinnedCache = { } <EOL> self . referencesCache = { } <EOL> def hasTrove ( self , info ) : <EOL> return self . hasTrovesCache . get ( info , None ) <EOL> def isPinned ( self , info ) : <EOL> return self . pinnedCache [ info ] <EOL> def getReferences ( self , info ) : <EOL> return self . referencesCache [ info ] <EOL> def populate ( self , jobList ) : <EOL> erasures = [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for job <EOL> in jobList if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None ] <EOL> hasTroveList = self . db . hasTroves ( erasures ) <EOL> self . hasTrovesCache . update ( <EOL> itertools . izip ( erasures , hasTroveList ) ) <EOL> present = [ x [ <NUM_LIT:0> ] for x in <EOL> itertools . izip ( erasures , hasTroveList ) <EOL> if x [ <NUM_LIT:1> ] ] <EOL> pinnedList = self . db . trovesArePinned ( present ) <EOL> self . pinnedCache . update ( <EOL> itertools . izip ( present , pinnedList ) ) <EOL> referenceList = self . db . getTroveTroves ( <EOL> present , weakRefs = False , <EOL> pristineOnly = False ) <EOL> self . referencesCache . update ( <EOL> itertools . izip ( present , referenceList ) ) <EOL> nodeList = [ ] <EOL> nodeIdx = { } <EOL> ERASE = <NUM_LIT:1> <EOL> KEEP = <NUM_LIT:2> <EOL> UNKNOWN = <NUM_LIT:3> <EOL> infoCache = ErasureInfoCache ( self . db ) <EOL> infoCache . populate ( newJob ) <EOL> infoCache . populate ( primaryErases ) <EOL> jobQueue = util . IterableQueue ( ) <EOL> for job , isPrimary in itertools . chain ( <EOL> itertools . izip ( newJob , itertools . repeat ( False ) ) , <EOL> itertools . izip ( primaryErases , itertools . repeat ( True ) ) , <EOL> jobQueue ) : <EOL> oldInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> if oldInfo [ <NUM_LIT:1> ] is None : <EOL> continue <EOL> if oldInfo in nodeIdx : <EOL> continue <EOL> present = infoCache . hasTrove ( oldInfo ) <EOL> if present is None : <EOL> infoCache . populate ( <EOL> [ job ] + [ x [ <NUM_LIT:0> ] for x in jobQueue . peekRemainder ( ) ] ) <EOL> present = infoCache . hasTrove ( oldInfo ) <EOL> if not present : <EOL> continue <EOL> if job in newJob : <EOL> assert ( job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ) <EOL> state = ERASE <EOL> fromUpdate = True <EOL> else : <EOL> if infoCache . isPinned ( oldInfo ) : <EOL> state = KEEP <EOL> if isPrimary and checkPrimaryPins : <EOL> raise UpdatePinnedTroveError ( oldInfo ) <EOL> elif isPrimary : <EOL> state = ERASE <EOL> else : <EOL> state = UNKNOWN <EOL> fromUpdate = False <EOL> assert ( oldInfo not in nodeIdx ) <EOL> nodeIdx [ oldInfo ] = len ( nodeList ) <EOL> nodeList . append ( [ oldInfo , state , [ ] , fromUpdate ] ) <EOL> if not recurse : continue <EOL> if not trove . troveIsCollection ( oldInfo [ <NUM_LIT:0> ] ) : continue <EOL> for inclInfo in infoCache . getReferences ( oldInfo ) : <EOL> if inclInfo in ineligible : <EOL> continue <EOL> jobQueue . add ( ( ( inclInfo [ <NUM_LIT:0> ] , inclInfo [ <NUM_LIT:1> : ] , ( None , None ) , <EOL> False ) , False ) ) <EOL> needParents = [ ( nodeId , info ) for nodeId , ( info , state , edges , <EOL> alreadyHandled ) <EOL> in enumerate ( nodeList ) if state == UNKNOWN ] <EOL> while needParents : <EOL> containers = self . db . getTroveContainers ( <EOL> x [ <NUM_LIT:1> ] for x in needParents ) <EOL> newNeedParents = [ ] <EOL> for ( nodeId , nodeInfo ) , containerList in itertools . izip ( needParents , containers ) : <EOL> for containerInfo in containerList : <EOL> if containerInfo in nodeIdx : <EOL> containerId = nodeIdx [ containerInfo ] <EOL> nodeList [ containerId ] [ <NUM_LIT:2> ] . append ( nodeId ) <EOL> else : <EOL> containerId = len ( nodeList ) <EOL> nodeIdx [ containerInfo ] = containerId <EOL> nodeList . append ( [ containerInfo , KEEP , [ nodeId ] , <EOL> False ] ) <EOL> newNeedParents . append ( ( containerId , containerInfo ) ) <EOL> needParents = newNeedParents <EOL> for info in referencedTroves : <EOL> if info in nodeIdx : <EOL> node = nodeList [ nodeIdx [ info ] ] <EOL> node [ <NUM_LIT:1> ] = KEEP <EOL> seen = [ False ] * len ( nodeList ) <EOL> keepNodes = [ nodeId for nodeId , node in enumerate ( nodeList ) <EOL> if node [ <NUM_LIT:1> ] == KEEP ] <EOL> while keepNodes : <EOL> nodeId = keepNodes . pop ( ) <EOL> if seen [ nodeId ] : continue <EOL> seen [ nodeId ] = True <EOL> nodeList [ nodeId ] [ <NUM_LIT:1> ] = KEEP <EOL> keepNodes += nodeList [ nodeId ] [ <NUM_LIT:2> ] <EOL> eraseList = ( ( x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , ( x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , x [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] ) , ( None , None ) , False ) <EOL> for x in nodeList if x [ <NUM_LIT:1> ] != KEEP and not x [ <NUM_LIT:3> ] ) <EOL> return set ( eraseList ) <EOL> def _troveTransitiveClosure ( db , itemList ) : <EOL> itemQueue = util . IterableQueue ( ) <EOL> fullSet = set ( ) <EOL> for item in itertools . chain ( itemList , itemQueue ) : <EOL> if item in fullSet : continue <EOL> fullSet . add ( item ) <EOL> if not trove . troveIsCollection ( item [ <NUM_LIT:0> ] ) : continue <EOL> trv = db . getTrove ( withFiles = False , pristine = False , * item ) <EOL> for x in trv . iterTroveList ( strongRefs = True , weakRefs = True ) : <EOL> itemQueue . add ( x ) <EOL> return fullSet <EOL> def _filterDoubleRemovesDueToLocalUpdates ( newJob , replacedJobs ) : <EOL> eraseCount = { } <EOL> for job in newJob : <EOL> oldInfo = job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> if oldInfo in replacedJobs : <EOL> if oldInfo in eraseCount : <EOL> eraseCount [ oldInfo ] += <NUM_LIT:1> <EOL> else : <EOL> eraseCount [ oldInfo ] = <NUM_LIT:1> <EOL> doubleErased = [ x [ <NUM_LIT:0> ] for x in eraseCount . iteritems ( ) if x [ <NUM_LIT:1> ] > <NUM_LIT:1> ] <EOL> for oldInfo in doubleErased : <EOL> newJob . remove ( ( oldInfo [ <NUM_LIT:0> ] , ( oldInfo [ <NUM_LIT:1> ] , oldInfo [ <NUM_LIT:2> ] ) , <EOL> replacedJobs [ oldInfo ] , False ) ) <EOL> newJob . add ( ( oldInfo [ <NUM_LIT:0> ] , ( None , None ) , <EOL> replacedJobs [ oldInfo ] , False ) ) <EOL> erasePrimaries = set ( x for x in primaryJobList <EOL> if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None ) <EOL> relativePrimaries = set ( x for x in primaryJobList <EOL> if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None and <EOL> not x [ <NUM_LIT:3> ] ) <EOL> absolutePrimaries = set ( x for x in primaryJobList <EOL> if x [ <NUM_LIT:3> ] ) <EOL> assert ( len ( relativePrimaries ) + len ( absolutePrimaries ) + <EOL> len ( erasePrimaries ) == len ( primaryJobList ) ) <EOL> log . lowlevel ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> recurse , checkPrimaryPins , installMissingRefs , <EOL> updateOnly , respectBranchAffinity , <EOL> alwaysFollowLocalChanges ) <EOL> troveSource = uJob . getTroveSource ( ) <EOL> if recurse : <EOL> ineligible = _troveTransitiveClosure ( self . db , ineligible ) <EOL> for job in erasePrimaries : <EOL> ineligible . add ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> availableTrove = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> names = set ( ) <EOL> for job in transitiveClosure : <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None : continue <EOL> if not job [ <NUM_LIT:3> ] : continue <EOL> if ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) in ineligible : continue <EOL> availableTrove . addTrove ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] , <EOL> presentOkay = True ) <EOL> names . add ( job [ <NUM_LIT:0> ] ) <EOL> avail = set ( availableTrove . iterTroveList ( strongRefs = True ) ) <EOL> relativeUpdateJobs = set ( job for job in transitiveClosure if <EOL> job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None and not job [ <NUM_LIT:3> ] ) <EOL> relativeUpdates = [ ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) , x ) <EOL> for x in relativeUpdateJobs if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None ] <EOL> isPresentList = self . db . hasTroves ( [ x [ <NUM_LIT:0> ] for x in relativeUpdates ] ) <EOL> for ( info , job ) , isPresent in itertools . izip ( relativeUpdates , <EOL> isPresentList ) : <EOL> if not isPresent : <EOL> relativeUpdateJobs . remove ( job ) <EOL> newTrove = job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] <EOL> if newTrove not in avail : <EOL> ineligible . add ( newTrove ) <EOL> relativeInstalls = [ ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , x ) <EOL> for x in relativeUpdateJobs if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None ] <EOL> isPresentList = self . db . hasTroves ( [ x [ <NUM_LIT:0> ] for x in relativeInstalls ] ) <EOL> for ( newTrove , job ) , isPresent in itertools . izip ( relativeInstalls , <EOL> isPresentList ) : <EOL> if isPresent : <EOL> relativeUpdateJobs . remove ( job ) <EOL> ineligible . add ( newTrove ) <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> erasePrimaries . add ( ( job [ <NUM_LIT:0> ] , ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) , <EOL> ( None , None ) , False ) ) <EOL> ( installedNotReferenced , <EOL> installedAndReferenced , <EOL> referencedStrong , <EOL> referencedWeak ) = self . db . db . getCompleteTroveSet ( names ) <EOL> installedTroves = installedNotReferenced | installedAndReferenced <EOL> referencedNotInstalled = referencedStrong | referencedWeak <EOL> log . lowlevel ( '<STR_LIT>' , referencedNotInstalled ) <EOL> log . lowlevel ( '<STR_LIT>' , ineligible ) <EOL> installedTroves . difference_update ( ineligible ) <EOL> installedTroves . difference_update ( <EOL> ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for job in relativeUpdateJobs ) <EOL> referencedNotInstalled . difference_update ( ineligible ) <EOL> referencedNotInstalled . difference_update ( <EOL> ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for job in relativeUpdateJobs ) <EOL> primaryLocalUpdates = self . getPrimaryLocalUpdates ( names ) <EOL> localUpdates = list ( primaryLocalUpdates ) <EOL> if localUpdates : <EOL> localUpdates += self . getChildLocalUpdates ( uJob . getSearchSource ( ) , <EOL> localUpdates , <EOL> installedTroves , <EOL> referencedNotInstalled ) <EOL> localUpdates = [ x for x in localUpdates if x [ <NUM_LIT:0> ] in names ] <EOL> localUpdatesByPresent = dict ( ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , job [ <NUM_LIT:1> ] ) for <EOL> job in localUpdates if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None and <EOL> job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None ) <EOL> localUpdatesByMissing = dict ( ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) , job [ <NUM_LIT:2> ] ) for <EOL> job in localUpdates if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None and <EOL> job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None ) <EOL> primaryLocalUpdates = set ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> for job in primaryLocalUpdates ) <EOL> localErases = set ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> for job in localUpdates if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None ) <EOL> sameBranchLocalUpdates = { } <EOL> for job in sorted ( localUpdates ) : <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None and job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None : <EOL> if ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . branch ( ) == job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . branch ( ) and <EOL> ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) not in avail ) : <EOL> del localUpdatesByPresent [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) ] <EOL> del localUpdatesByMissing [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ] <EOL> referencedNotInstalled . remove ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> log . lowlevel ( '<STR_LIT>' , job ) <EOL> sameBranchLocalUpdates [ job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ] = ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> else : <EOL> log . lowlevel ( '<STR_LIT>' , job ) <EOL> del localUpdates <EOL> alreadyInstalled = ( installedTroves & avail ) | installedPrimaries <EOL> alreadyReferenced = referencedNotInstalled & avail <EOL> del avail <EOL> existsTrv = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> [ existsTrv . addTrove ( * x ) for x in installedTroves ] <EOL> [ existsTrv . addTrove ( * x ) for x in referencedNotInstalled ] <EOL> jobList = availableTrove . diff ( existsTrv , <EOL> getPathHashes = lookupPathHashes ) [ <NUM_LIT:2> ] <EOL> jobList += [ ( x [ <NUM_LIT:0> ] , ( x [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] ) , ( x [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] ) , <NUM_LIT:0> ) for x in alreadyReferenced ] <EOL> installJobs = [ x for x in jobList if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is None and <EOL> x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None ] <EOL> updateJobs = [ x for x in jobList if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None and <EOL> x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is not None ] <EOL> pins = self . db . trovesArePinned ( [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> for x in updateJobs ] ) <EOL> jobByNew = dict ( ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , ( job [ <NUM_LIT:1> ] , pin ) ) for <EOL> ( job , pin ) in itertools . izip ( updateJobs , pins ) ) <EOL> jobByNew . update ( <EOL> dict ( ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , ( job [ <NUM_LIT:1> ] , False ) ) for <EOL> job in installJobs ) ) <EOL> del jobList , installJobs , updateJobs <EOL> jobByNew . update ( <EOL> dict ( ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , ( job [ <NUM_LIT:1> ] , False ) ) for <EOL> job in relativeUpdateJobs ) ) <EOL> respectFlavorAffinity = True <EOL> newTroves = sorted ( ( ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , <EOL> True , { } , False , False , False , False , None , <EOL> respectBranchAffinity , <EOL> respectFlavorAffinity , True , <EOL> True , updateOnly ) <EOL> for x in itertools . chain ( absolutePrimaries , <EOL> relativePrimaries ) ) , <EOL> key = lambda y : ( y [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , str ( y [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) , y [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] ) + y [ <NUM_LIT:1> : ] ) <EOL> newJob = set ( ) <EOL> notByDefaultRemovals = set ( ) <EOL> neverRespectBranchAffinity = not respectBranchAffinity <EOL> replacedJobs = { } <EOL> while newTroves : <EOL> ( newInfo , isPrimary , byDefaultDict , parentInstalled , <EOL> parentReplacedWasPinned , parentUpdated , primaryInstalled , <EOL> branchHint , respectBranchAffinity , respectFlavorAffinity , <EOL> installRedirects , followLocalChanges , <EOL> updateOnly ) = newTroves . pop ( <NUM_LIT:0> ) <EOL> byDefault = isPrimary or byDefaultDict [ newInfo ] <EOL> log . lowlevel ( '''<STR_LIT>''' , <EOL> newInfo [ <NUM_LIT:0> ] , newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] , isPrimary , <EOL> byDefault , parentUpdated , parentInstalled , <EOL> primaryInstalled , updateOnly , branchHint , <EOL> respectBranchAffinity , respectFlavorAffinity , <EOL> installRedirects , followLocalChanges ) <EOL> trv = None <EOL> jobAdded = False <EOL> replaced = ( None , None ) <EOL> recurseThis = True <EOL> childrenFollowLocalChanges = alwaysFollowLocalChanges <EOL> pinned = False <EOL> while True : <EOL> if newInfo in alreadyInstalled : <EOL> jobAdded = True <EOL> job = ( newInfo [ <NUM_LIT:0> ] , ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) , <EOL> ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) , False ) <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif newInfo in ineligible : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif newInfo in alreadyReferenced : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if isPrimary or installMissingRefs or primaryInstalled : <EOL> pass <EOL> elif parentUpdated and newInfo in referencedWeak : <EOL> pass <EOL> else : <EOL> if newInfo in localUpdatesByMissing : <EOL> info = ( ( newInfo [ <NUM_LIT:0> ] , ) <EOL> + localUpdatesByMissing [ newInfo ] ) <EOL> alreadyInstalled . add ( info ) <EOL> log . lowlevel ( '<STR_LIT>' <EOL> '<STR_LIT>' , info ) <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> replaced , pinned = jobByNew [ newInfo ] <EOL> replacedInfo = ( newInfo [ <NUM_LIT:0> ] , replaced [ <NUM_LIT:0> ] , replaced [ <NUM_LIT:1> ] ) <EOL> log . lowlevel ( '<STR_LIT>' , replacedInfo ) <EOL> if replaced [ <NUM_LIT:0> ] is not None : <EOL> if newInfo in alreadyReferenced : <EOL> if replacedInfo in referencedNotInstalled : <EOL> replaced = localUpdatesByMissing . get ( replacedInfo , <EOL> ( None , None ) ) <EOL> replacedInfo = ( replacedInfo [ <NUM_LIT:0> ] , replaced [ <NUM_LIT:0> ] , <EOL> replaced [ <NUM_LIT:1> ] ) <EOL> log . lowlevel ( '<STR_LIT>' , replacedInfo ) <EOL> if replaced [ <NUM_LIT:0> ] : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> childrenFollowLocalChanges = True <EOL> replacedJobs [ replacedInfo ] = ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) <EOL> pinned = self . db . trovesArePinned ( [ replacedInfo ] ) [ <NUM_LIT:0> ] <EOL> elif replacedInfo in referencedNotInstalled : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if followLocalChanges : <EOL> skipLocal = False <EOL> elif installMissingRefs : <EOL> skipLocal = False <EOL> elif ( parentInstalled and not parentReplacedWasPinned ) : <EOL> skipLocal = False <EOL> elif replacedInfo not in localErases and not parentReplacedWasPinned : <EOL> skipLocal = False <EOL> else : <EOL> skipLocal = True <EOL> if skipLocal : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> freshInstallOkay = ( isPrimary or <EOL> ( parentInstalled <EOL> and not parentReplacedWasPinned ) <EOL> or byDefault <EOL> or installMissingRefs ) <EOL> replaced = localUpdatesByMissing . get ( replacedInfo , <EOL> ( None , None ) ) <EOL> if ( replaced [ <NUM_LIT:0> ] is None and not freshInstallOkay ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> childrenFollowLocalChanges = True <EOL> replacedInfo = ( replacedInfo [ <NUM_LIT:0> ] , replaced [ <NUM_LIT:0> ] , <EOL> replaced [ <NUM_LIT:1> ] ) <EOL> replacedJobs [ replacedInfo ] = ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) <EOL> if replaced [ <NUM_LIT:0> ] : <EOL> pinned = self . db . trovesArePinned ( [ replacedInfo ] ) [ <NUM_LIT:0> ] <EOL> log . lowlevel ( '<STR_LIT>' , replacedInfo ) <EOL> elif not installRedirects : <EOL> if not redirectHack . get ( newInfo , True ) : <EOL> log . lowlevel ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> break <EOL> elif redirectHack . get ( newInfo , False ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> installRedirects = False <EOL> if replaced [ <NUM_LIT:0> ] and respectBranchAffinity : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> newBranch = newInfo [ <NUM_LIT:1> ] . branch ( ) <EOL> installedBranch = replacedInfo [ <NUM_LIT:1> ] . branch ( ) <EOL> if replacedInfo in localUpdatesByPresent : <EOL> notInstalledVer = localUpdatesByPresent [ replacedInfo ] [ <NUM_LIT:0> ] <EOL> notInstalledBranch = notInstalledVer . branch ( ) <EOL> alreadyBranchSwitch = True <EOL> else : <EOL> notInstalledBranch = None <EOL> alreadyBranchSwitch = False <EOL> if installedBranch == newBranch : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if ( not isPrimary <EOL> and newInfo [ <NUM_LIT:1> ] < replaced [ <NUM_LIT:0> ] <EOL> and replacedInfo in sameBranchLocalUpdates <EOL> and ( replacedInfo in primaryLocalUpdates <EOL> or not parentUpdated ) ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> alreadyInstalled . add ( replacedInfo ) <EOL> break <EOL> elif notInstalledBranch == installedBranch : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> pass <EOL> else : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if isPrimary : <EOL> if alreadyBranchSwitch : <EOL> respectBranchAffinity = False <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> else : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> elif ( installedBranch , newBranch ) == branchHint : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> pass <EOL> elif ( ( replacedInfo in installedAndReferenced <EOL> or replacedInfo in sameBranchLocalUpdates ) <EOL> and not alreadyBranchSwitch <EOL> and parentUpdated ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> pass <EOL> else : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> recurseThis = False <EOL> alreadyInstalled . add ( replacedInfo ) <EOL> break <EOL> if replaced [ <NUM_LIT:0> ] and respectFlavorAffinity : <EOL> if replacedInfo in localUpdatesByPresent : <EOL> notInstalledFlavor = localUpdatesByPresent [ replacedInfo ] [ <NUM_LIT:1> ] <EOL> pass <EOL> elif replacedInfo in sameBranchLocalUpdates : <EOL> notInstalledFlavor = sameBranchLocalUpdates [ replacedInfo ] [ <NUM_LIT:1> ] <EOL> else : <EOL> notInstalledFlavor = None <EOL> if ( notInstalledFlavor is not None <EOL> and not deps . compatibleFlavors ( notInstalledFlavor , replacedInfo [ <NUM_LIT:2> ] ) <EOL> and not deps . compatibleFlavors ( replacedInfo [ <NUM_LIT:2> ] , newInfo [ <NUM_LIT:2> ] ) ) : <EOL> if isPrimary : <EOL> respectFlavorAffinity = False <EOL> else : <EOL> log . lowlevel ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> recurseThis = False <EOL> alreadyInstalled . add ( replacedInfo ) <EOL> break <EOL> if replaced [ <NUM_LIT:0> ] : <EOL> pass <EOL> elif not byDefault : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif updateOnly : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif not isPrimary and self . cfg . excludeTroves . match ( newInfo [ <NUM_LIT:0> ] ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif not installRedirects : <EOL> if not redirectHack . get ( newInfo , True ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> break <EOL> elif redirectHack . get ( newInfo , False ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> installRedirects = False <EOL> job = ( newInfo [ <NUM_LIT:0> ] , replaced , ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) , False ) <EOL> if pinned and ( not isPrimary or checkPrimaryPins ) : <EOL> job = self . _splitPinnedJob ( uJob , troveSource , job , <EOL> force = not isPrimary ) <EOL> if job is None : <EOL> recurseThis = False <EOL> break <EOL> elif ( not isPrimary <EOL> and self . cfg . excludeTroves . match ( newInfo [ <NUM_LIT:0> ] ) ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> recurseThis = False <EOL> break <EOL> log . lowlevel ( '<STR_LIT>' , job ) <EOL> newJob . add ( job ) <EOL> jobAdded = True <EOL> break <EOL> log . lowlevel ( '<STR_LIT>' , recurseThis , recurse ) <EOL> if jobAdded and removeNotByDefault and not byDefault : <EOL> job = ( newInfo [ <NUM_LIT:0> ] , replaced , ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) , False ) <EOL> newJob . discard ( job ) <EOL> if replaced [ <NUM_LIT:0> ] : <EOL> notByDefaultRemovals . add ( <EOL> ( newInfo [ <NUM_LIT:0> ] , replaced , ( None , None ) , False ) ) <EOL> elif newInfo in alreadyInstalled : <EOL> notByDefaultRemovals . add ( <EOL> ( newInfo [ <NUM_LIT:0> ] , ( newInfo [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) , <EOL> ( None , None ) , False ) ) <EOL> if not recurseThis : continue <EOL> if not recurse : continue <EOL> if not trove . troveIsCollection ( newInfo [ <NUM_LIT:0> ] ) : continue <EOL> branchHint = None <EOL> if replaced [ <NUM_LIT:0> ] and replaced [ <NUM_LIT:0> ] . branch ( ) == newInfo [ <NUM_LIT:1> ] . branch ( ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if not neverRespectBranchAffinity : <EOL> respectBranchAffinity = True <EOL> elif replaced [ <NUM_LIT:0> ] : <EOL> branchHint = ( replaced [ <NUM_LIT:0> ] . branch ( ) , newInfo [ <NUM_LIT:1> ] . branch ( ) ) <EOL> if replaced [ <NUM_LIT:0> ] and deps . compatibleFlavors ( replaced [ <NUM_LIT:1> ] , newInfo [ <NUM_LIT:2> ] ) : <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> respectFlavorAffinity = True <EOL> if trv is None : <EOL> try : <EOL> trv = troveSource . getTrove ( withFiles = False , * newInfo ) <EOL> except TroveMissing : <EOL> if self . db . hasTrove ( * newInfo ) : <EOL> trv = self . db . getTrove ( withFiles = False , * newInfo ) <EOL> else : <EOL> if jobAdded : <EOL> raise <EOL> else : <EOL> continue <EOL> if isPrimary : <EOL> byDefaultDict = dict ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] ) for x in trv . iterTroveListInfo ( ) ) <EOL> updateOnly = updateOnly or not jobAdded <EOL> if isPrimary : <EOL> primaryInstalled = jobAdded and not job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] <EOL> jobInstall = primaryInstalled or ( jobAdded and not job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ) <EOL> for info in sorted ( trv . iterTroveList ( strongRefs = True ) ) : <EOL> if not isPrimary : <EOL> if not jobAdded and info not in byDefaultDict : <EOL> continue <EOL> childByDefault = ( trv . includeTroveByDefault ( * info ) <EOL> and jobAdded ) <EOL> byDefaultDict . setdefault ( info , childByDefault ) <EOL> newTroves . append ( ( info , False , <EOL> byDefaultDict , jobInstall , pinned , jobAdded , <EOL> primaryInstalled , <EOL> branchHint , respectBranchAffinity , <EOL> respectFlavorAffinity , installRedirects , <EOL> childrenFollowLocalChanges , <EOL> updateOnly ) ) <EOL> _filterDoubleRemovesDueToLocalUpdates ( newJob , replacedJobs ) <EOL> for job in notByDefaultRemovals : <EOL> if job not in newJob : <EOL> erasePrimaries . add ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] , ( None , None ) , False ) ) <EOL> alreadyInstalled . discard ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> for info in set ( itertools . chain ( * redirectHack . values ( ) ) ) : <EOL> erasePrimaries . add ( ( info [ <NUM_LIT:0> ] , ( info [ <NUM_LIT:1> ] , info [ <NUM_LIT:2> ] ) , ( None , None ) , False ) ) <EOL> eraseSet = _findErasures ( erasePrimaries , newJob , alreadyInstalled , <EOL> recurse , ineligible ) <EOL> assert ( not [ x for x in newJob if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None ] ) <EOL> newJob . update ( eraseSet ) <EOL> return newJob <EOL> def _splitPinnedJob ( self , uJob , troveSource , job , force = False ) : <EOL> def _getPathHashes ( trvSrc , db , trv , inDb = False ) : <EOL> if not trv . isCollection ( ) : return trv . getPathHashes ( ) <EOL> ph = None <EOL> for info in trv . iterTroveList ( strongRefs = True ) : <EOL> if inDb : <EOL> otherTrv = db . getTrove ( withFiles = False , * info ) <EOL> elif trvSrc . hasTrove ( * info ) : <EOL> otherTrv = trvSrc . getTrove ( withFiles = False , * info ) <EOL> else : <EOL> continue <EOL> if ph is None : <EOL> ph = otherTrv . getPathHashes ( ) <EOL> else : <EOL> ph . update ( otherTrv . getPathHashes ( ) ) <EOL> if ph is None : <EOL> ph = trv . getPathHashes ( ) <EOL> return ph <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is None : <EOL> return job <EOL> newInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> replacedInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> try : <EOL> trv = troveSource . getTrove ( withFiles = False , * newInfo ) <EOL> except TroveMissing : <EOL> log . lowlevel ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> return None <EOL> oldTrv = self . db . getTrove ( withFiles = False , <EOL> pristine = False , <EOL> * replacedInfo ) <EOL> if not ( oldTrv . troveInfo . capsule . type ( ) == <EOL> trove . _TROVECAPSULE_TYPE_RPM and <EOL> trv . troveInfo . capsule . type ( ) == <EOL> trove . _TROVECAPSULE_TYPE_RPM ) : <EOL> oldHashes = _getPathHashes ( troveSource , self . db , <EOL> oldTrv , inDb = True ) <EOL> newHashes = _getPathHashes ( uJob . getTroveSource ( ) , <EOL> self . db , trv , inDb = False ) <EOL> if not newHashes . compatibleWith ( oldHashes ) : <EOL> if force : <EOL> return None <EOL> else : <EOL> raise UpdatePinnedTroveError ( replacedInfo , <EOL> newInfo ) <EOL> log . lowlevel ( '<STR_LIT>' ) <EOL> if not force : <EOL> name = replacedInfo [ <NUM_LIT:0> ] <EOL> self . updateCallback . warning ( <EOL> """<STR_LIT>""" , * ( ( name , name , name ) + replacedInfo + replacedInfo ) ) <EOL> return ( job [ <NUM_LIT:0> ] , ( None , None ) , job [ <NUM_LIT:2> ] , False ) <EOL> def _findOverlappingJobs ( self , jobSet , troveSource , pathHashCache = None ) : <EOL> """<STR_LIT>""" <EOL> if pathHashCache is None : <EOL> pathHashCache = { } <EOL> overlapping = { } <EOL> d = { } <EOL> jobSet = list ( enumerate ( jobSet ) ) <EOL> oldTroves = [ ( idx , ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> for idx , x in jobSet if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ] <EOL> pathHashesNeeded = [ x for ( idx , x ) in oldTroves <EOL> if x not in pathHashCache and <EOL> not trove . troveIsCollection ( x [ <NUM_LIT:0> ] ) ] <EOL> oldPathHashes = self . db . getPathHashesForTroveList ( pathHashesNeeded ) <EOL> pathHashCache . update ( itertools . izip ( pathHashesNeeded , oldPathHashes ) ) <EOL> oldJobs = [ ( jobSet [ idx ] , pathHashCache . get ( info , None ) ) <EOL> for ( idx , info ) in oldTroves ] <EOL> getHashes = troveSource . getPathHashesForTroveList <EOL> justNewJobs = [ x for x in jobSet if x [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ] <EOL> newTroves = [ ( x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in justNewJobs ] <EOL> newJobs = ( ( x , hashes ) for x , hashes in <EOL> itertools . izip ( justNewJobs , getHashes ( newTroves ) ) ) <EOL> for ( ( idx , job ) , pathHashes ) in itertools . chain ( oldJobs , newJobs ) : <EOL> if pathHashes is None : <EOL> continue <EOL> for pathHash in pathHashes : <EOL> if pathHash not in d : <EOL> d [ pathHash ] = idx <EOL> else : <EOL> if d [ pathHash ] == idx : <EOL> continue <EOL> newIdx = d [ pathHash ] <EOL> if idx in overlapping : <EOL> while isinstance ( overlapping [ idx ] , int ) : <EOL> idx = overlapping [ idx ] <EOL> if newIdx in overlapping and overlapping [ newIdx ] == idx : <EOL> continue <EOL> overlapping [ idx ] . append ( newIdx ) <EOL> else : <EOL> overlapping [ idx ] = [ idx , newIdx ] <EOL> if newIdx in overlapping : <EOL> while isinstance ( overlapping [ newIdx ] , int ) : <EOL> oldIdx = overlapping [ newIdx ] <EOL> overlapping [ newIdx ] = idx <EOL> newIdx = oldIdx <EOL> if newIdx == idx : <EOL> continue <EOL> overlapping [ idx ] . extend ( overlapping [ newIdx ] ) <EOL> overlapping [ newIdx ] = idx <EOL> sets = [ ] <EOL> for val in overlapping . itervalues ( ) : <EOL> if isinstance ( val , int ) : <EOL> continue <EOL> sets . append ( [ jobSet [ x ] [ <NUM_LIT:1> ] for x in set ( val ) ] ) <EOL> return sets <EOL> def _trovesNotFound ( self , notFound ) : <EOL> """<STR_LIT>""" <EOL> nonLocal = [ x for x in notFound if not x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . isOnLocalHost ( ) ] <EOL> if nonLocal : <EOL> troveList = '<STR_LIT>' . join ( [ '<STR_LIT>' % ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> for x in nonLocal ] ) <EOL> raise UpdateError ( <EOL> '<STR_LIT>' <EOL> % troveList ) <EOL> def _confirmLaterPackages ( self , findTroveResults ) : <EOL> relevantPackages = [ x for x in findTroveResults <EOL> if ( not x [ <NUM_LIT:1> ] <EOL> and ( x [ <NUM_LIT:2> ] is None or x [ <NUM_LIT:2> ] . isEmpty ( ) ) ) ] <EOL> localResults = self . db . findTroves ( None , relevantPackages , <EOL> allowMissing = True ) <EOL> downgrades = { } <EOL> for troveSpec , localVersions in localResults . iteritems ( ) : <EOL> reposVersions = findTroveResults [ troveSpec ] <EOL> reposVersionsByLabel = { } <EOL> localVersionsByLabel = { } <EOL> for troveTup in reposVersions : <EOL> label = troveTup [ <NUM_LIT:1> ] . trailingLabel ( ) <EOL> reposVersionsByLabel . setdefault ( label , set ( ) ) . add ( troveTup ) <EOL> for troveTup in localVersions : <EOL> label = troveTup [ <NUM_LIT:1> ] . trailingLabel ( ) <EOL> localVersionsByLabel . setdefault ( label , set ( ) ) . add ( troveTup ) <EOL> for name , localVersion , localFlavor in localVersions : <EOL> label = localVersion . trailingLabel ( ) <EOL> if label not in reposVersionsByLabel : <EOL> continue <EOL> repoTups = reposVersionsByLabel [ label ] <EOL> found = False <EOL> for name , repoVersion , repoFlavor in repoTups : <EOL> if localVersion <= repoVersion : <EOL> found = True <EOL> break <EOL> if not found : <EOL> downgrades [ troveSpec , label ] = ( localVersionsByLabel [ label ] , <EOL> reposVersionsByLabel [ label ] ) <EOL> if not downgrades : <EOL> return <EOL> raise DowngradeError ( downgrades ) <EOL> def _updateChangeSet ( self , itemList , uJob , keepExisting = None , <EOL> recurse = True , updateMode = True , sync = False , <EOL> useAffinity = True , checkPrimaryPins = True , <EOL> forceJobClosure = False , ineligible = set ( ) , <EOL> syncChildren = False , updateOnly = False , <EOL> installMissing = False , removeNotByDefault = False , <EOL> exactFlavors = False ) : <EOL> """<STR_LIT>""" <EOL> searchSource = uJob . getSearchSource ( ) <EOL> if not isinstance ( searchSource , searchsource . AbstractSearchSource ) : <EOL> if searchSource . isSearchAsDatabase ( ) : <EOL> searchSource = searchsource . SearchSource ( <EOL> uJob . getSearchSource ( ) , <EOL> self . cfg . flavor , self . db ) <EOL> else : <EOL> searchSource = searchsource . NetworkSearchSource ( <EOL> uJob . getSearchSource ( ) , <EOL> self . cfg . installLabelPath , <EOL> self . cfg . flavor , self . db ) <EOL> uJob . setSearchSource ( searchSource ) <EOL> def _separateInstalledItems ( jobSet ) : <EOL> present = self . db . hasTroves ( [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in <EOL> jobSet ] ) <EOL> oldItems = set ( [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for job , isPresent <EOL> in itertools . izip ( jobSet , present ) <EOL> if isPresent ] ) <EOL> newItems = set ( [ job for job , isPresent <EOL> in itertools . izip ( jobSet , present ) <EOL> if not isPresent ] ) <EOL> return newItems , oldItems <EOL> def _jobTransitiveClosure ( db , troveSource , jobSet ) : <EOL> jobQueue = util . IterableQueue ( ) <EOL> jobClosure = set ( ) <EOL> for job in itertools . chain ( jobSet , jobQueue ) : <EOL> if job in jobClosure : <EOL> continue <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None : <EOL> continue <EOL> jobClosure . add ( job ) <EOL> if not trove . troveIsCollection ( job [ <NUM_LIT:0> ] ) : continue <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is None : <EOL> oldTrv = None <EOL> else : <EOL> oldTrv = db . getTroves ( [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ] , <EOL> withFiles = False , pristine = False ) [ <NUM_LIT:0> ] <EOL> if oldTrv is None : <EOL> oldTrv = troveSource . getTrove ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , <EOL> job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , <EOL> withFiles = False ) <EOL> try : <EOL> newTrv = troveSource . getTrove ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] , <EOL> withFiles = False ) <EOL> except ( TroveMissing , OpenError ) : <EOL> newTrv = db . getTroves ( [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) ] , <EOL> withFiles = False , <EOL> pristine = True ) [ <NUM_LIT:0> ] <EOL> if newTrv is None : <EOL> continue <EOL> recursiveJob = newTrv . diff ( oldTrv , absolute = job [ <NUM_LIT:3> ] ) [ <NUM_LIT:2> ] <EOL> for x in recursiveJob : <EOL> jobQueue . add ( x ) <EOL> return jobClosure <EOL> if syncChildren : <EOL> installMissing = True <EOL> newJob = set ( ) <EOL> removeJob = set ( ) <EOL> transitiveClosure = set ( ) <EOL> toFind = { } <EOL> toFindNoDb = { } <EOL> for item in itemList : <EOL> ( troveName , ( oldVersionStr , oldFlavorStr ) , <EOL> ( newVersionStr , newFlavorStr ) , isAbsolute ) = item <EOL> assert ( oldVersionStr is None or not isAbsolute ) <EOL> if troveName [ <NUM_LIT:0> ] == '<STR_LIT:->' : <EOL> needsOld = True <EOL> needsNew = newVersionStr or ( newFlavorStr is not None ) <EOL> troveName = troveName [ <NUM_LIT:1> : ] <EOL> elif troveName [ <NUM_LIT:0> ] == '<STR_LIT:+>' : <EOL> needsNew = True <EOL> needsOld = oldVersionStr or ( oldFlavorStr is not None ) <EOL> troveName = troveName [ <NUM_LIT:1> : ] <EOL> else : <EOL> needsOld = oldVersionStr or ( oldFlavorStr is not None ) <EOL> needsNew = newVersionStr or ( newFlavorStr is not None ) <EOL> if not ( needsOld or needsNew ) : <EOL> if updateMode : <EOL> needsNew = True <EOL> else : <EOL> needsOld = True <EOL> if needsOld : <EOL> oldTroves = self . db . findTrove ( None , <EOL> ( troveName , oldVersionStr , oldFlavorStr ) ) <EOL> else : <EOL> oldTroves = [ ] <EOL> if not needsNew : <EOL> assert ( newFlavorStr is None ) <EOL> assert ( not isAbsolute ) <EOL> for troveInfo in oldTroves : <EOL> log . lowlevel ( "<STR_LIT>" , troveInfo ) <EOL> removeJob . add ( ( troveInfo [ <NUM_LIT:0> ] , ( troveInfo [ <NUM_LIT:1> ] , troveInfo [ <NUM_LIT:2> ] ) , <EOL> ( None , None ) , False ) ) <EOL> continue <EOL> if len ( oldTroves ) > <NUM_LIT:2> : <EOL> raise UpdateError , "<STR_LIT>" "<STR_LIT>" % troveName <EOL> elif oldTroves : <EOL> oldTrove = ( oldTroves [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , oldTroves [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] ) <EOL> else : <EOL> oldTrove = ( None , None ) <EOL> del oldTroves <EOL> if isinstance ( newVersionStr , versions . Version ) : <EOL> assert ( isinstance ( newFlavorStr , deps . Flavor ) ) <EOL> jobToAdd = ( troveName , oldTrove , <EOL> ( newVersionStr , newFlavorStr ) , isAbsolute ) <EOL> newJob . add ( jobToAdd ) <EOL> log . lowlevel ( "<STR_LIT>" , jobToAdd ) <EOL> del jobToAdd <EOL> elif isinstance ( newVersionStr , versions . Branch ) : <EOL> toFind [ ( troveName , newVersionStr . asString ( ) , <EOL> newFlavorStr ) ] = oldTrove , isAbsolute <EOL> elif ( newVersionStr and newVersionStr [ <NUM_LIT:0> ] == '<STR_LIT:/>' ) : <EOL> toFind [ ( troveName , newVersionStr , newFlavorStr ) ] = oldTrove , isAbsolute <EOL> else : <EOL> if not ( isAbsolute or not useAffinity ) : <EOL> toFindNoDb [ ( troveName , newVersionStr , newFlavorStr ) ] = oldTrove , isAbsolute <EOL> else : <EOL> toFind [ ( troveName , newVersionStr , newFlavorStr ) ] = oldTrove , isAbsolute <EOL> searchSource = uJob . getSearchSource ( ) <EOL> if not useAffinity : <EOL> results = searchSource . findTroves ( toFind , useAffinity = False , <EOL> exactFlavors = exactFlavors ) <EOL> else : <EOL> results = { } <EOL> if toFind : <EOL> log . lowlevel ( "<STR_LIT>" ) <EOL> results = searchSource . findTroves ( toFind , <EOL> useAffinity = True , <EOL> exactFlavors = exactFlavors ) <EOL> self . _confirmLaterPackages ( results ) <EOL> if toFindNoDb : <EOL> log . lowlevel ( "<STR_LIT>" ) <EOL> results . update ( searchSource . findTroves ( toFindNoDb , <EOL> useAffinity = False , <EOL> exactFlavors = exactFlavors ) ) <EOL> for troveSpec , ( oldTroveInfo , isAbsolute ) in itertools . chain ( toFind . iteritems ( ) , toFindNoDb . iteritems ( ) ) : <EOL> resultList = results [ troveSpec ] <EOL> if len ( resultList ) > <NUM_LIT:1> and oldTroveInfo [ <NUM_LIT:0> ] is not None : <EOL> raise UpdateError , "<STR_LIT>" "<STR_LIT>" % troveName <EOL> newJobList = [ ( x [ <NUM_LIT:0> ] , oldTroveInfo , x [ <NUM_LIT:1> : ] , isAbsolute ) for x in <EOL> resultList ] <EOL> newJob . update ( newJobList ) <EOL> log . lowlevel ( "<STR_LIT>" , newJobList ) <EOL> if not installMissing : <EOL> jobSet , oldItems = _separateInstalledItems ( newJob ) <EOL> else : <EOL> jobSet , oldItems = newJob , _separateInstalledItems ( newJob ) [ <NUM_LIT:1> ] <EOL> log . lowlevel ( "<STR_LIT>" , oldItems ) <EOL> jobSet . update ( removeJob ) <EOL> del newJob , removeJob <EOL> if not jobSet : <EOL> raise NoNewTrovesError <EOL> hasTroves = uJob . getTroveSource ( ) . hasTroves ( <EOL> [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in jobSet ] ) <EOL> reposChangeSetList = set ( [ x [ <NUM_LIT:1> ] for x in <EOL> itertools . izip ( hasTroves , jobSet ) <EOL> if x [ <NUM_LIT:0> ] is not True ] ) <EOL> if reposChangeSetList != jobSet : <EOL> forceJobClosure = True <EOL> csSource = trovesource . stack ( uJob . getSearchSource ( ) , <EOL> self . repos ) <EOL> cs , notFound = csSource . createChangeSet ( reposChangeSetList , <EOL> withFiles = False , <EOL> recurse = recurse , <EOL> callback = self . updateCallback ) <EOL> self . _replaceIncomplete ( cs , csSource , <EOL> self . db , self . repos ) <EOL> if notFound : <EOL> self . _trovesNotFound ( notFound ) <EOL> jobSet . difference_update ( notFound ) <EOL> if not jobSet : <EOL> raise NoNewTrovesError <EOL> assert ( not notFound ) <EOL> uJob . getTroveSource ( ) . addChangeSet ( cs ) <EOL> transitiveClosure = set ( cs . getJobSet ( primaries = False ) ) <EOL> del cs <EOL> redirectHack = self . _processRedirects ( csSource , uJob , jobSet , <EOL> transitiveClosure , recurse ) <EOL> if forceJobClosure and recurse : <EOL> transitiveClosure = _jobTransitiveClosure ( self . db , <EOL> trovesource . stack ( <EOL> uJob . getTroveSource ( ) , <EOL> self . repos ) , jobSet ) <EOL> transitiveJobs = list ( transitiveClosure ) <EOL> hasTroves = uJob . getTroveSource ( ) . hasTroves ( <EOL> ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in transitiveJobs ) <EOL> reposChangeSetList = set ( [ x [ <NUM_LIT:1> ] for x in <EOL> itertools . izip ( hasTroves , transitiveJobs ) <EOL> if x [ <NUM_LIT:0> ] is not True ] ) <EOL> csSource = trovesource . stack ( uJob . getSearchSource ( ) , <EOL> self . repos ) <EOL> trovesExist = csSource . hasTroves ( <EOL> [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in reposChangeSetList ] ) <EOL> reposChangeSetList = [ x [ <NUM_LIT:1> ] for x in <EOL> itertools . izip ( trovesExist , reposChangeSetList ) <EOL> if x [ <NUM_LIT:0> ] is True ] <EOL> cs , notFound = csSource . createChangeSet ( reposChangeSetList , <EOL> withFiles = False , <EOL> recurse = recurse , <EOL> callback = self . updateCallback ) <EOL> self . _replaceIncomplete ( cs , csSource , self . db , self . repos ) <EOL> uJob . getTroveSource ( ) . addChangeSet ( cs ) <EOL> elif forceJobClosure : <EOL> transitiveClosure = jobSet <EOL> if not installMissing : <EOL> ineligible = ineligible | oldItems <EOL> newJob = self . _mergeGroupChanges ( uJob , jobSet , transitiveClosure , <EOL> redirectHack , recurse , ineligible , <EOL> checkPrimaryPins , <EOL> installedPrimaries = oldItems , <EOL> installMissingRefs = installMissing , <EOL> updateOnly = updateOnly , <EOL> respectBranchAffinity = not installMissing , <EOL> alwaysFollowLocalChanges = installMissing , <EOL> removeNotByDefault = removeNotByDefault ) <EOL> if not newJob : <EOL> raise NoNewTrovesError <EOL> troveSource = uJob . getTroveSource ( ) <EOL> missingTroves , removedTroves = self . _processJobList ( newJob , uJob , <EOL> troveSource . getChangeSet ) <EOL> if removedTroves or missingTroves : <EOL> removed = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in removedTroves ] <EOL> removed . sort ( ) <EOL> missing = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in missingTroves ] <EOL> missing . sort ( ) <EOL> raise MissingTrovesError ( missing , removed ) <EOL> uJob . setPrimaryJobs ( jobSet ) <EOL> return newJob <EOL> def _addJobPreEraseScripts ( self , jobList , updJob ) : <EOL> removeList = [ job for job in jobList <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None ] <EOL> troveList = [ ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for job in removeList ] <EOL> scripts = self . db . getTroveScripts ( troveList ) <EOL> troves = self . db . getTroves ( troveList , withFiles = False , <EOL> withDeps = False ) <EOL> for job , scriptObj , troveObj in itertools . izip ( removeList , scripts , troves ) : <EOL> capsuleType = troveObj . getTroveInfo ( ) . capsule . type ( ) <EOL> if capsuleType : <EOL> updJob . addCapsuleType ( capsuleType ) <EOL> if scriptObj is None : continue <EOL> if not scriptObj . preErase . script ( ) : continue <EOL> compatClass = self . db . getTroveCompatibilityClass ( <EOL> job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> updJob . addJobPreScript ( job , scriptObj . preErase . script ( ) , <EOL> compatClass , None , action = "<STR_LIT>" , <EOL> troveObj = troveObj ) <EOL> def _processJobList ( self , jobList , updJob , troveSourceCallback ) : <EOL> missingTroves = list ( ) <EOL> removedTroves = list ( ) <EOL> rollbackFence = False <EOL> self . _addJobPreEraseScripts ( jobList , updJob ) <EOL> for job in jobList : <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] is None : <EOL> continue <EOL> cs = troveSourceCallback ( job ) <EOL> troveCs = cs . getNewTroveVersion ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> if troveCs . troveType ( ) == trove . TROVE_TYPE_REMOVED : <EOL> ti = trove . TroveInfo ( troveCs . troveInfoDiff . freeze ( ) ) <EOL> if ti . flags . isMissing ( ) : <EOL> missingTroves . append ( job ) <EOL> else : <EOL> removedTroves . append ( job ) <EOL> preScript = None <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None : <EOL> action = "<STR_LIT>" <EOL> troveTup = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> oldCompatClass = self . db . getTroveCompatibilityClass ( * troveTup ) <EOL> preScript = troveCs . getPreUpdateScript ( ) <EOL> if preScript : <EOL> if troveCs . isAbsolute ( ) : <EOL> troveObj = trove . Trove ( troveCs ) <EOL> else : <EOL> troveObj = self . db . getTrove ( * troveTup , <EOL> ** dict ( withFiles = False , withDeps = False ) ) <EOL> troveObj . applyChangeSet ( troveCs ) <EOL> else : <EOL> action = "<STR_LIT>" <EOL> oldCompatClass = None <EOL> preScript = troveCs . _getPreInstallScript ( ) <EOL> if preScript : <EOL> troveObj = trove . Trove ( troveCs ) <EOL> if preScript : <EOL> updJob . addJobPreScript ( job , preScript , oldCompatClass , <EOL> troveCs . getNewCompatibilityClass ( ) , <EOL> action = action , troveObj = troveObj ) <EOL> postRollbackScript = troveCs . getPostRollbackScript ( ) <EOL> if postRollbackScript and job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None : <EOL> updJob . addJobPostRollbackScript ( job , postRollbackScript , <EOL> troveCs . getNewCompatibilityClass ( ) , oldCompatClass ) <EOL> rollbackFence = rollbackFence or troveCs . isRollbackFence ( update = ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None ) , <EOL> oldCompatibilityClass = oldCompatClass ) <EOL> capsuleType = troveCs . getCapsuleType ( ) <EOL> if capsuleType : <EOL> updJob . addCapsuleType ( capsuleType ) <EOL> updJob . setInvalidateRollbacksFlag ( rollbackFence ) <EOL> return missingTroves , removedTroves <EOL> def _fullMigrate ( self , itemList , uJob , recurse = True ) : <EOL> def _convertRedirects ( searchSource , newTroves ) : <EOL> troveNames = set ( x . getName ( ) for x in newTroves ) <EOL> redirects = [ x for x in newTroves if x . isRedirect ( ) ] <EOL> nonRedirects = [ x for x in newTroves if not x . isRedirect ( ) ] <EOL> if not redirects : <EOL> return newTroves , troveNames <EOL> redirectMap = { } <EOL> toFind = { } <EOL> for trv in redirects : <EOL> redirTup = trv . getNameVersionFlavor ( ) <EOL> redirectMap [ redirTup ] = [ redirTup ] <EOL> for troveName , branch , flavor in trv . iterRedirects ( ) : <EOL> troveSpec = ( troveName , str ( branch ) , flavor ) <EOL> toFind . setdefault ( troveSpec , [ ] ) . append ( redirTup ) <EOL> if not toFind : <EOL> if not nonRedirects : <EOL> err = ( "<STR_LIT>" <EOL> "<STR_LIT>" % "<STR_LIT:\n>" . join ( "<STR_LIT>" % x . getNameVersionFlavor ( ) <EOL> for x in redirects ) ) <EOL> raise UpdateError ( err ) <EOL> else : <EOL> return nonRedirects , troveNames <EOL> while toFind : <EOL> matches = searchSource . findTroves ( toFind , useAffinity = True ) <EOL> allTroveTups = list ( set ( itertools . chain ( * matches . itervalues ( ) ) ) ) <EOL> allTroves = searchSource . getTroves ( allTroveTups ) <EOL> allTroves = dict ( itertools . izip ( allTroveTups , allTroves ) ) <EOL> newToFind = { } <EOL> for troveSpec , troveTupList in matches . iteritems ( ) : <EOL> for troveTup in troveTupList : <EOL> redirTups = toFind [ troveSpec ] <EOL> for redirTup in redirTups : <EOL> if redirTup == troveTup : <EOL> err = "<STR_LIT>" % redirTup <EOL> raise UpdateError ( err ) <EOL> elif redirTup in redirectMap . get ( troveTup , [ ] ) : <EOL> err = "<STR_LIT>" <EOL> err += "<STR_LIT>" % ( redirTup + troveTup ) <EOL> raise UpdateError ( err ) <EOL> else : <EOL> redirectMap . setdefault ( troveTup , [ ] ) . append ( redirTup ) <EOL> trv = allTroves [ troveTup ] <EOL> if trv . isRedirect ( ) : <EOL> for troveName , branch , flavor in trv . iterRedirects ( ) : <EOL> newTroveSpec = ( troveName , str ( branch ) , flavor ) <EOL> newToFind . setdefault ( newTroveSpec , [ ] ) . append ( troveTup ) <EOL> else : <EOL> nonRedirects . append ( trv ) <EOL> troveNames . add ( trv . getName ( ) ) <EOL> toFind = newToFind <EOL> return set ( nonRedirects ) , troveNames <EOL> def _getTrovesToBeMigrated ( db , troves , troveNames ) : <EOL> """<STR_LIT>""" <EOL> existsTrv = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> availableTrv = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> existsTups = [ ] <EOL> availTups = [ ] <EOL> for troveNVF in db . findByNames ( troveNames ) : <EOL> existsTups . append ( troveNVF ) <EOL> existsTrv . addTrove ( * troveNVF ) <EOL> for trv in troves : <EOL> availTups . append ( trv . getNameVersionFlavor ( ) ) <EOL> availableTrv . addTrove ( * trv . getNameVersionFlavor ( ) ) <EOL> oldTroves = set ( existsTups ) & set ( availTups ) <EOL> jobs = availableTrv . diff ( existsTrv ) [ <NUM_LIT:2> ] <EOL> oldTroves . update ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for x in jobs if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ) <EOL> return db . getTroves ( oldTroves , withFiles = False ) <EOL> def _updateByDefaultFromIncludedGroups ( potentialJobs , byDefaultFalseSet , <EOL> availByDefaultInfo , searchSource ) : <EOL> groupJobs = [ x for x in potentialJobs if trove . troveIsGroup ( x [ <NUM_LIT:0> ] ) ] <EOL> if not groupJobs : <EOL> return <EOL> oldGroups = [ ] <EOL> newGroups = [ ] <EOL> for job in groupJobs : <EOL> newInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> oldInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> if not job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] or not job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> continue <EOL> if availByDefaultInfo [ newInfo ] : <EOL> continue <EOL> if ( oldInfo in byDefaultFalse <EOL> and trove . troveIsGroup ( job [ <NUM_LIT:0> ] ) ) : <EOL> oldGroups . append ( oldInfo ) <EOL> newGroups . append ( newInfo ) <EOL> availByDefaultInfo [ newInfo ] = True <EOL> newGroups = searchSource . getTroves ( newGroups , withFiles = False ) <EOL> oldGroups = self . db . getTroves ( oldGroups , withFiles = False ) <EOL> for trv in newGroups : <EOL> for ( troveNVF , byDefault , isWeak ) in trv . iterTroveListInfo ( ) : <EOL> availByDefaultInfo . update ( dict . fromkeys ( ( x [ <NUM_LIT:0> ] for x in trv . iterTroveListInfo ( ) if x [ <NUM_LIT:1> ] ) , True ) ) <EOL> byDefaultTrue = [ ] <EOL> for trv in oldGroups : <EOL> troveList = list ( trv . iterTroveListInfo ( ) ) <EOL> troveTups = [ x [ <NUM_LIT:0> ] for x in troveList ] <EOL> hasTroves = self . db . hasTroves ( troveTups ) <EOL> troveList = ( x [ <NUM_LIT:0> ] for x in itertools . izip ( troveList , hasTroves ) if x [ <NUM_LIT:1> ] ) <EOL> byDefaultTrue . extend ( x [ <NUM_LIT:0> ] for x in troveList if x [ <NUM_LIT:1> ] ) <EOL> byDefaultFalse . difference_update ( byDefaultTrue ) <EOL> toFind = [ ] <EOL> for item in itemList : <EOL> ( troveName , ( oldVersionStr , oldFlavorStr ) , <EOL> ( newVersionStr , newFlavorStr ) , isAbsolute ) = item <EOL> if ( not isAbsolute and oldVersionStr ) or troveName [ <NUM_LIT:0> ] == '<STR_LIT:->' : <EOL> raise UpdateError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> toFind . append ( ( troveName , newVersionStr , newFlavorStr ) ) <EOL> searchSource = uJob . getSearchSource ( ) <EOL> results = searchSource . findTroves ( toFind , useAffinity = True ) <EOL> newTroves = list ( set ( itertools . chain ( * results . itervalues ( ) ) ) ) <EOL> newTroves = searchSource . getTroves ( newTroves , withFiles = False ) <EOL> newTroves , troveNames = _convertRedirects ( searchSource , newTroves ) <EOL> updateSet = [ ] <EOL> availByDefaultInfo = { } <EOL> for trv in newTroves : <EOL> updateSet . append ( trv . getNameVersionFlavor ( ) ) <EOL> availByDefaultInfo [ trv . getNameVersionFlavor ( ) ] = True <EOL> if not recurse : <EOL> continue <EOL> for ( troveNVF , byDefault , isWeak ) in trv . iterTroveListInfo ( ) : <EOL> updateSet . append ( troveNVF ) <EOL> if byDefault : <EOL> availByDefaultInfo [ troveNVF ] = True <EOL> else : <EOL> availByDefaultInfo . setdefault ( troveNVF , False ) <EOL> toBeMigrated = _getTrovesToBeMigrated ( self . db , newTroves , troveNames ) <EOL> byDefaultFalse = [ ] <EOL> byDefaultTrue = [ ] <EOL> count = <NUM_LIT:0> <EOL> for trv in toBeMigrated : <EOL> if not recurse : <EOL> continue <EOL> troveList = list ( trv . iterTroveListInfo ( ) ) <EOL> troveTups = [ x [ <NUM_LIT:0> ] for x in troveList ] <EOL> hasTroves = self . db . hasTroves ( troveTups ) <EOL> troveList = ( x [ <NUM_LIT:0> ] for x in itertools . izip ( troveList , hasTroves ) if x [ <NUM_LIT:1> ] ) <EOL> for ( troveNVF , byDefault , isWeak ) in troveList : <EOL> count += <NUM_LIT:1> <EOL> if not byDefault : <EOL> byDefaultFalse . append ( troveNVF ) <EOL> else : <EOL> byDefaultTrue . append ( troveNVF ) <EOL> byDefaultFalse = set ( byDefaultFalse ) <EOL> byDefaultFalse . difference_update ( byDefaultTrue ) <EOL> del byDefaultTrue <EOL> updateSet = set ( updateSet ) <EOL> eraseSet = set ( self . db . iterAllTroves ( ) ) <EOL> toKeep = eraseSet & updateSet <EOL> updateSet . difference_update ( toKeep ) <EOL> eraseSet . difference_update ( toKeep ) <EOL> existsTrv = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> availableTrv = trove . Trove ( "<STR_LIT>" , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> for troveNVF in updateSet : <EOL> availableTrv . addTrove ( * troveNVF ) <EOL> for troveNVF in eraseSet : <EOL> existsTrv . addTrove ( * troveNVF ) <EOL> potentialJobs = availableTrv . diff ( existsTrv ) [ <NUM_LIT:2> ] <EOL> potentialJobs += [ ( x [ <NUM_LIT:0> ] , ( x [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] ) , ( x [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] ) , False ) for x in toKeep ] <EOL> if recurse : <EOL> _updateByDefaultFromIncludedGroups ( potentialJobs , <EOL> byDefaultFalse , <EOL> availByDefaultInfo , <EOL> searchSource ) <EOL> finalJobs = [ ] <EOL> for job in potentialJobs : <EOL> newInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> oldInfo = ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> if not job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> if not availByDefaultInfo [ newInfo ] : <EOL> continue <EOL> elif job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> if availByDefaultInfo [ newInfo ] : <EOL> pass <EOL> elif ( oldInfo in byDefaultFalse and <EOL> ( job [ <NUM_LIT:0> ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] == '<STR_LIT>' <EOL> or trove . troveIsGroup ( job [ <NUM_LIT:0> ] ) ) ) : <EOL> pass <EOL> else : <EOL> finalJobs . append ( ( job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] , ( None , None ) , False ) ) <EOL> continue <EOL> if job [ <NUM_LIT:1> ] != job [ <NUM_LIT:2> ] : <EOL> finalJobs . append ( job ) <EOL> for troveNVF in toKeep : <EOL> if ( not availByDefaultInfo [ troveNVF ] <EOL> and troveNVF not in byDefaultFalse ) : <EOL> finalJobs . append ( ( troveNVF [ <NUM_LIT:0> ] , ( troveNVF [ <NUM_LIT:1> ] , troveNVF [ <NUM_LIT:2> ] ) , <EOL> ( None , None ) , False ) ) <EOL> finalJobs = set ( finalJobs ) <EOL> if not finalJobs : <EOL> raise NoNewTrovesError <EOL> updateJobs = set ( x for x in finalJobs if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ) <EOL> removalJobs = [ x for x in finalJobs if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ] <EOL> pins = self . db . trovesArePinned ( [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> for x in removalJobs ] ) <EOL> csSource = trovesource . stack ( uJob . getSearchSource ( ) , self . repos ) <EOL> for job , isPinned in itertools . izip ( removalJobs , pins ) : <EOL> if isPinned : <EOL> if not job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> finalJobs . remove ( job ) <EOL> continue <EOL> newJob = self . _splitPinnedJob ( uJob , csSource , job , force = True ) <EOL> if newJob is not None : <EOL> finalJobs . remove ( job ) <EOL> updateJobs . remove ( job ) <EOL> finalJobs . add ( newJob ) <EOL> updateJobs . add ( newJob ) <EOL> else : <EOL> finalJobs . remove ( job ) <EOL> updateJobs . remove ( job ) <EOL> updateJobs = list ( updateJobs ) <EOL> hasTroves = uJob . getTroveSource ( ) . hasTroves ( <EOL> [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in updateJobs ] ) <EOL> reposChangeSetList = set ( [ x [ <NUM_LIT:1> ] for x in <EOL> itertools . izip ( hasTroves , updateJobs ) <EOL> if x [ <NUM_LIT:0> ] is not True ] ) <EOL> cs , notFound = csSource . createChangeSet ( reposChangeSetList , <EOL> withFiles = False , <EOL> recurse = False , <EOL> callback = self . updateCallback ) <EOL> if notFound : <EOL> self . _trovesNotFound ( notFound ) <EOL> reposChangeSetList . difference_update ( notFound ) <EOL> if not reposChangeSetList : <EOL> raise NoNewTrovesError <EOL> troveSource = uJob . getTroveSource ( ) <EOL> self . _replaceIncomplete ( cs , csSource , self . db , self . repos ) <EOL> troveSource . addChangeSet ( cs ) <EOL> infoCs = troveSource . createChangeSet ( finalJobs , withFiles = False ) <EOL> assert ( not infoCs [ <NUM_LIT:1> ] ) <EOL> infoCs = infoCs [ <NUM_LIT:0> ] <EOL> troveSourceCallback = lambda x : infoCs <EOL> self . _processJobList ( finalJobs , uJob , troveSourceCallback ) <EOL> return finalJobs <EOL> @ api . publicApi <EOL> def getUpdateItemList ( self ) : <EOL> """<STR_LIT>""" <EOL> items = ( x for x in self . getPrimaryLocalUpdates ( ) <EOL> if ( x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is None <EOL> or not deps . compatibleFlavors ( x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> or x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . branch ( ) != x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . branch ( ) ) ) <EOL> items = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in items <EOL> if not x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . isOnLocalHost ( ) and <EOL> not x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . isInLocalNamespace ( ) ] <EOL> items = [ x [ <NUM_LIT:0> ] for x in itertools . izip ( items , <EOL> self . db . trovesArePinned ( items ) ) <EOL> if not x [ <NUM_LIT:1> ] ] <EOL> return items <EOL> def fullUpdateItemList ( self ) : <EOL> items = self . getUpdateItemList ( ) <EOL> installed = self . db . findByNames ( x [ <NUM_LIT:0> ] for x in items ) <EOL> installedDict = { } <EOL> for ( name , version , release ) in installed : <EOL> branchDict = installedDict . setdefault ( name , { } ) <EOL> l = branchDict . setdefault ( version . branch ( ) , [ ] ) <EOL> l . append ( ( version , release ) ) <EOL> updateItems = [ ] <EOL> for name , version , flavor in items : <EOL> branch = version . branch ( ) <EOL> verInfo = installedDict [ name ] [ branch ] <EOL> if len ( installedDict [ name ] ) == <NUM_LIT:1> and len ( verInfo ) == <NUM_LIT:1> : <EOL> updateItems . append ( ( name , None , None ) ) <EOL> continue <EOL> elif len ( verInfo ) == <NUM_LIT:1> : <EOL> updateItems . append ( ( name , branch , None ) ) <EOL> continue <EOL> score = None <EOL> for instFlavor in self . cfg . flavor : <EOL> newScore = instFlavor . score ( flavor ) <EOL> if newScore is False : <EOL> continue <EOL> if score is None or newScore > score : <EOL> score = newScore <EOL> finalFlavor = instFlavor <EOL> if score is not None : <EOL> flavor = deps . overrideFlavor ( finalFlavor , flavor ) <EOL> if len ( installedDict [ name ] ) == <NUM_LIT:1> : <EOL> updateItems . append ( ( name , None , flavor ) ) <EOL> else : <EOL> updateItems . append ( ( name , branch , flavor ) ) <EOL> return updateItems <EOL> def getPrimaryLocalUpdates ( self , troveNames = None ) : <EOL> """<STR_LIT>""" <EOL> if troveNames is not None and not troveNames : <EOL> return [ ] <EOL> allJobs = [ ] <EOL> noParents = [ ] <EOL> troves = [ ] <EOL> maxId = <NUM_LIT:0> <EOL> troveIdsByInfo = { } <EOL> parentIds = { } <EOL> childIds = { } <EOL> ISPRESENT = <NUM_LIT:1> <EOL> HASPARENT = <NUM_LIT:2> <EOL> ISWEAK = <NUM_LIT:3> <EOL> for ( troveInfo , parentInfo , isPresent , weakRef ) in self . db . iterUpdateContainerInfo ( troveNames ) : <EOL> troveId = troveIdsByInfo . setdefault ( troveInfo , maxId ) <EOL> if troveId == maxId : <EOL> maxId += <NUM_LIT:1> <EOL> troves . append ( [ troveInfo , isPresent , bool ( parentInfo ) , weakRef ] ) <EOL> else : <EOL> if isPresent : <EOL> troves [ troveId ] [ ISPRESENT ] = True <EOL> if parentInfo : <EOL> troves [ troveId ] [ HASPARENT ] = True <EOL> if not weakRef : <EOL> troves [ troveId ] [ ISWEAK ] = False <EOL> if parentInfo : <EOL> parentId = troveIdsByInfo . setdefault ( parentInfo , maxId ) <EOL> if parentId == maxId : <EOL> maxId += <NUM_LIT:1> <EOL> troves . append ( [ parentInfo , False , False , True ] ) <EOL> l = parentIds . setdefault ( troveInfo [ <NUM_LIT:0> ] , [ set ( ) , [ ] ] ) <EOL> l [ <NUM_LIT:1> ] . append ( troveId ) <EOL> if parentInfo : <EOL> childIds . setdefault ( parentId , [ ] ) . append ( troveId ) <EOL> l [ <NUM_LIT:0> ] . add ( parentId ) <EOL> del maxId <EOL> allTroves = set ( x [ <NUM_LIT:0> ] for x in enumerate ( troves ) <EOL> if ( x [ <NUM_LIT:1> ] [ ISPRESENT ] or x [ <NUM_LIT:1> ] [ HASPARENT ] ) <EOL> and not ( x [ <NUM_LIT:1> ] [ ISPRESENT ] and x [ <NUM_LIT:1> ] [ HASPARENT ] and not x [ <NUM_LIT:1> ] [ ISWEAK ] ) ) <EOL> for name , ( parents , troveIds ) in parentIds . items ( ) : <EOL> parents . intersection_update ( allTroves ) <EOL> parentIds [ name ] [ <NUM_LIT:1> ] = set ( troveIds ) <EOL> parentIds [ name ] [ <NUM_LIT:1> ] . intersection_update ( allTroves ) <EOL> del allTroves <EOL> noParents = ( x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] for x in parentIds . iteritems ( ) if not x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ) <EOL> noParents = set ( itertools . chain ( * noParents ) ) <EOL> while noParents : <EOL> exists = trove . Trove ( '<STR_LIT>' , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> refd = trove . Trove ( '<STR_LIT>' , versions . NewVersion ( ) , <EOL> deps . Flavor ( ) , None ) <EOL> for troveId in noParents : <EOL> info , isPresent , hasParent , isWeak = troves [ troveId ] <EOL> if isPresent : <EOL> exists . addTrove ( presentOkay = True , * info ) <EOL> else : <EOL> refd . addTrove ( presentOkay = True , * info ) <EOL> for job in exists . diff ( refd ) [ <NUM_LIT:2> ] : <EOL> if not job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> continue <EOL> newInfo = troves [ troveIdsByInfo [ job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ] ] <EOL> if not job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] and newInfo [ HASPARENT ] : <EOL> continue <EOL> elif newInfo [ HASPARENT ] and newInfo [ ISWEAK ] : <EOL> oldInfo = troves [ troveIdsByInfo [ job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ] ] <EOL> if oldInfo [ ISWEAK ] : <EOL> continue <EOL> allJobs . append ( job ) <EOL> toDiscard = { } <EOL> for troveId in noParents : <EOL> for childId in childIds . get ( troveId , [ ] ) : <EOL> toDiscard . setdefault ( troves [ childId ] [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , <EOL> [ ] ) . append ( troveId ) <EOL> newNoParents = [ ] <EOL> for name , troveIds in toDiscard . iteritems ( ) : <EOL> parentIds [ name ] [ <NUM_LIT:0> ] . difference_update ( troveIds ) <EOL> if not parentIds [ name ] [ <NUM_LIT:0> ] : <EOL> newNoParents . extend ( parentIds [ name ] [ <NUM_LIT:1> ] ) <EOL> del toDiscard <EOL> noParents = set ( newNoParents ) - noParents <EOL> return allJobs <EOL> def getChildLocalUpdates ( self , searchSource , localUpdates , <EOL> installedTroves = None , missingTroves = None ) : <EOL> """<STR_LIT>""" <EOL> localUpdates = [ x for x in localUpdates <EOL> if not ( x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] and x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isOnLocalHost ( ) ) ] <EOL> oldTroveTups = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) for x in localUpdates ] <EOL> newTroveTups = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in localUpdates ] <EOL> toGet = [ x for x in oldTroveTups if x [ <NUM_LIT:1> ] and trove . troveIsGroup ( x [ <NUM_LIT:0> ] ) ] <EOL> oldTroveSource = trovesource . stack ( searchSource , self . repos ) <EOL> oldTroves = oldTroveSource . getTroves ( toGet , withFiles = False ) <EOL> troveDict = dict ( zip ( toGet , oldTroves ) ) <EOL> toGet = [ x for x in newTroveTups if x [ <NUM_LIT:1> ] ] <EOL> newTroves = self . db . getTroves ( toGet , withFiles = False ) <EOL> troveDict . update ( zip ( toGet , newTroves ) ) <EOL> isComponent = trove . troveIsComponent <EOL> for trv in newTroves : <EOL> if not trove . troveIsGroup ( trv . getName ( ) ) : <EOL> continue <EOL> for troveTup in trv . iterTroveList ( strongRefs = True , weakRefs = True ) : <EOL> if isComponent ( troveTup [ <NUM_LIT:0> ] ) : <EOL> packageName = troveTup [ <NUM_LIT:0> ] . split ( '<STR_LIT::>' , <NUM_LIT:1> ) [ <NUM_LIT:0> ] <EOL> packageTup = packageName , troveTup [ <NUM_LIT:1> ] , troveTup [ <NUM_LIT:2> ] <EOL> l = troveDict . setdefault ( packageTup , [ ] ) <EOL> if isinstance ( l , list ) : <EOL> l . append ( troveTup ) <EOL> troveDict . setdefault ( troveTup , [ ] ) <EOL> toGet = [ x for x in oldTroveTups if x [ <NUM_LIT:1> ] and x not in troveDict ] <EOL> if toGet : <EOL> moreOldTroves = oldTroveSource . getTroves ( toGet , withFiles = False ) <EOL> troveDict . update ( zip ( toGet , moreOldTroves ) ) <EOL> oldTroves += moreOldTroves <EOL> if installedTroves is None : <EOL> assert ( missingTroves is None ) <EOL> chain = itertools . chain <EOL> izip = itertools . izip <EOL> childNew = list ( set ( chain ( * ( x . iterTroveList ( strongRefs = True , <EOL> weakRefs = True ) <EOL> for x in newTroves ) ) ) ) <EOL> childOld = list ( set ( chain ( * ( x . iterTroveList ( strongRefs = True , <EOL> weakRefs = True ) <EOL> for x in oldTroves ) ) ) ) <EOL> childOld += [ x [ <NUM_LIT:0> ] for x in troveDict . items ( ) <EOL> if isinstance ( x [ <NUM_LIT:1> ] , list ) ] <EOL> hasTroves = self . db . hasTroves ( childNew + childOld ) <EOL> installedTroves = set ( x [ <NUM_LIT:0> ] for x in izip ( childNew , hasTroves ) <EOL> if x [ <NUM_LIT:1> ] ) <EOL> installedTroves . update ( newTroveTups ) <EOL> hasTroves = hasTroves [ len ( childNew ) : ] <EOL> missingTroves = set ( x [ <NUM_LIT:0> ] for x in izip ( childOld , hasTroves ) <EOL> if not x [ <NUM_LIT:1> ] ) <EOL> missingTroves . update ( oldTroveTups ) <EOL> del childNew , childOld , hasTroves <EOL> else : <EOL> assert ( missingTroves is not None ) <EOL> installedTroves = installedTroves . copy ( ) <EOL> missingTroves = missingTroves . copy ( ) <EOL> erases = set ( ) <EOL> allJobs = [ ] <EOL> for oldTroveTup , newTroveTup in itertools . izip ( oldTroveTups , newTroveTups ) : <EOL> erases . discard ( oldTroveTup ) <EOL> if oldTroveTup [ <NUM_LIT:1> ] : <EOL> oldTrove = troveDict [ oldTroveTup ] <EOL> else : <EOL> oldTrove = None <EOL> if newTroveTup [ <NUM_LIT:1> ] : <EOL> newTrove = troveDict [ newTroveTup ] <EOL> else : <EOL> newTrove = None <EOL> notExistsOldTrove = trove . Trove ( '<STR_LIT>' , versions . NewVersion ( ) , deps . Flavor ( ) ) <EOL> existsNewTrove = trove . Trove ( '<STR_LIT>' , versions . NewVersion ( ) , deps . Flavor ( ) ) <EOL> if oldTrove is not None : <EOL> if isinstance ( oldTrove , list ) : <EOL> oldTroveChildren = set ( oldTrove ) <EOL> else : <EOL> oldTroveChildren = [ x for x in oldTrove . iterTroveList ( <EOL> strongRefs = True , <EOL> weakRefs = True ) ] <EOL> for tup in oldTroveChildren : <EOL> if ( tup in missingTroves and tup not in oldTroveTups <EOL> and not newTrove . hasTrove ( * tup ) ) : <EOL> notExistsOldTrove . addTrove ( * tup ) <EOL> for tup , byDefault , isStrong in newTrove . iterTroveListInfo ( ) : <EOL> if ( tup in installedTroves and tup not in newTroveTups <EOL> and tup not in oldTroveChildren ) : <EOL> existsNewTrove . addTrove ( * tup ) <EOL> elif not byDefault and tup in installedTroves : <EOL> existsNewTrove . addTrove ( * tup ) <EOL> if byDefault and tup in missingTroves : <EOL> notExistsOldTrove . addTrove ( * tup ) <EOL> else : <EOL> for tup , byDefault , isStrong in newTrove . iterTroveListInfo ( ) : <EOL> if byDefault : <EOL> if tup in missingTroves : <EOL> notExistsOldTrove . addTrove ( * tup ) <EOL> else : <EOL> if tup in installedTroves : <EOL> existsNewTrove . addTrove ( * tup ) <EOL> newUpdateJobs = existsNewTrove . diff ( notExistsOldTrove ) [ <NUM_LIT:2> ] <EOL> for newJob in newUpdateJobs : <EOL> oldInfo = ( newJob [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> if not newJob [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> continue <EOL> if not newJob [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> erases . add ( oldInfo ) <EOL> else : <EOL> erases . discard ( oldInfo ) <EOL> if newJob not in allJobs : <EOL> allJobs . append ( newJob ) <EOL> if oldTrove is None : <EOL> continue <EOL> if newJob [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> installedTroves . remove ( ( newJob [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) ) <EOL> missingTroves . remove ( ( newJob [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , newJob [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> return allJobs + [ ( x [ <NUM_LIT:0> ] , ( x [ <NUM_LIT:1> ] , x [ <NUM_LIT:2> ] ) , ( None , None ) , False ) for x in erases ] <EOL> def _replaceIncomplete ( self , cs , localSource , db , repos ) : <EOL> jobSet = [ ( x . getName ( ) , ( x . getOldVersion ( ) , x . getOldFlavor ( ) ) , <EOL> ( x . getNewVersion ( ) , x . getNewFlavor ( ) ) ) <EOL> for x in cs . iterNewTroveList ( ) ] <EOL> incompleteJobs = [ x for x in jobSet <EOL> if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] and x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] <EOL> and not x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . isOnLocalHost ( ) <EOL> and db . hasTrove ( x [ <NUM_LIT:0> ] , * x [ <NUM_LIT:1> ] ) <EOL> and db . troveIsIncomplete ( x [ <NUM_LIT:0> ] , * x [ <NUM_LIT:1> ] ) ] <EOL> if incompleteJobs : <EOL> newTroves = repos . getTroves ( [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) <EOL> for x in incompleteJobs ] ) <EOL> oldTroves = localSource . getTroves ( [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> for x in incompleteJobs ] ) <EOL> newCs = changeset . ChangeSet ( ) <EOL> for newT , oldT in itertools . izip ( newTroves , oldTroves ) : <EOL> oldT . troveInfo . incomplete . set ( <NUM_LIT:1> ) <EOL> newT . troveInfo . incomplete . set ( <NUM_LIT:1> ) <EOL> newT . troveInfo . completeFixup . set ( <NUM_LIT:1> ) <EOL> newCs . newTrove ( newT . diff ( oldT ) [ <NUM_LIT:0> ] ) <EOL> cs . merge ( newCs ) <EOL> def loadRestartInfo ( self , restartInfo , updJob ) : <EOL> """<STR_LIT>""" <EOL> return _loadRestartInfo ( restartInfo , updJob ) <EOL> def saveRestartInfo ( self , updJob , remainingJobs ) : <EOL> """<STR_LIT>""" <EOL> return _storeJobInfo ( remainingJobs , updJob ) <EOL> def cleanRestartInfo ( self , restartInfo ) : <EOL> """<STR_LIT>""" <EOL> if not restartInfo : <EOL> return <EOL> util . rmtree ( restartInfo , ignore_errors = True ) <EOL> @ api . publicApi <EOL> def newUpdateJob ( self , closeDatabase = True ) : <EOL> """<STR_LIT>""" <EOL> updJob = database . UpdateJob ( self . db , lazyCache = self . lzCache , <EOL> closeDatabase = closeDatabase ) <EOL> return updJob <EOL> @ api . publicApi <EOL> def prepareUpdateJob ( self , updJob , itemList , keepExisting = False , <EOL> recurse = True , <EOL> resolveDeps = True , test = False , <EOL> updateByDefault = True , <EOL> split = True , sync = False , fromChangesets = [ ] , <EOL> checkPathConflicts = True , checkPrimaryPins = True , <EOL> resolveRepos = True , syncChildren = False , <EOL> updateOnly = False , resolveGroupList = None , <EOL> installMissing = False , removeNotByDefault = False , <EOL> keepRequired = None , migrate = False , <EOL> criticalUpdateInfo = None , resolveSource = None , <EOL> applyCriticalOnly = False , restartInfo = None , <EOL> exactFlavors = False ) : <EOL> """<STR_LIT>""" <EOL> if keepRequired is None : <EOL> keepRequired = self . cfg . keepRequired <EOL> if self . updateCallback is None : <EOL> self . setUpdateCallback ( UpdateCallback ( ) ) <EOL> if not criticalUpdateInfo : <EOL> criticalUpdateInfo = CriticalUpdateInfo ( applyCriticalOnly ) <EOL> restartChangeSets = [ ] <EOL> if restartInfo : <EOL> itemList , restartChangeSets = self . loadRestartInfo ( restartInfo , <EOL> updJob ) <EOL> recurse = False <EOL> syncChildren = False <EOL> migrate = False <EOL> updJob . setRestartedFlag ( True ) <EOL> if syncChildren : <EOL> for name , oldInf , newInfo , isAbs in itemList : <EOL> if not isAbs : <EOL> raise ConaryError ( <EOL> '<STR_LIT>' ) <EOL> for cs , includesFileContents in restartChangeSets : <EOL> criticalUpdateInfo . addChangeSet ( cs , includesFileContents ) <EOL> try : <EOL> ( updJob , suggMap ) = self . updateChangeSet ( itemList , <EOL> keepExisting = keepExisting , <EOL> recurse = recurse , <EOL> resolveDeps = resolveDeps , <EOL> test = test , <EOL> updateByDefault = updateByDefault , <EOL> split = split , <EOL> sync = sync , <EOL> fromChangesets = fromChangesets , <EOL> checkPathConflicts = checkPathConflicts , <EOL> checkPrimaryPins = checkPrimaryPins , <EOL> resolveRepos = resolveRepos , <EOL> syncChildren = syncChildren , <EOL> updateOnly = updateOnly , <EOL> resolveGroupList = resolveGroupList , <EOL> installMissing = installMissing , <EOL> removeNotByDefault = removeNotByDefault , <EOL> keepRequired = keepRequired , <EOL> migrate = migrate , <EOL> criticalUpdateInfo = criticalUpdateInfo , <EOL> resolveSource = resolveSource , <EOL> updateJob = updJob , exactFlavors = exactFlavors ) <EOL> except DependencyFailure : <EOL> raise <EOL> except : <EOL> if restartChangeSets : <EOL> log . error ( '<STR_LIT>' ) <EOL> raise <EOL> return suggMap <EOL> @ api . publicApi <EOL> def applyUpdateJob ( self , updJob , replaceFiles = None , tagScript = None , <EOL> test = False , justDatabase = False , journal = None , <EOL> localRollbacks = None , autoPinList = None , <EOL> keepJournal = False , noRestart = False , <EOL> skipCapsuleOps = False , noScripts = False , <EOL> replaceManagedFiles = False , <EOL> replaceUnmanagedFiles = False , <EOL> replaceModifiedFiles = False , <EOL> replaceModifiedConfigFiles = False ) : <EOL> """<STR_LIT>""" <EOL> assert ( self . updateCallback is not None ) <EOL> if localRollbacks is None : <EOL> localRollbacks = self . cfg . localRollbacks <EOL> if updJob . getRestartedFlag ( ) : <EOL> commitFlags = updJob . getCommitChangesetFlags ( ) <EOL> else : <EOL> commitFlags = database . CommitChangeSetFlags ( ) <EOL> if updJob . getKeywordArguments ( ) . get ( '<STR_LIT>' , False ) : <EOL> commitFlags . replaceModifiedFiles = replaceModifiedFiles = True <EOL> commitFlags . replaceUnmanagedFiles = replaceUnmanagedFiles = True <EOL> if not updJob . getRestartedFlag ( ) : <EOL> if replaceFiles is not None : <EOL> replaceManagedFiles = replaceFiles <EOL> replaceUnmanagedFiles = replaceFiles <EOL> replaceModifiedFiles = replaceFiles <EOL> replaceModifiedConfigFiles = replaceFiles <EOL> commitFlags . replaceManagedFiles = replaceManagedFiles <EOL> commitFlags . replaceUnmanagedFiles = replaceUnmanagedFiles <EOL> commitFlags . replaceModifiedFiles = replaceModifiedFiles <EOL> commitFlags . replaceModifiedConfigFiles = replaceModifiedConfigFiles <EOL> commitFlags . justDatabase = justDatabase <EOL> commitFlags . localRollbacks = localRollbacks <EOL> commitFlags . test = test <EOL> commitFlags . keepJournal = keepJournal <EOL> commitFlags . skipCapsuleOps = skipCapsuleOps <EOL> commitFlags . noScripts = noScripts <EOL> if autoPinList is None : <EOL> autoPinList = self . cfg . pinTroves <EOL> if noRestart : <EOL> remainingJobs = [ ] <EOL> else : <EOL> remainingJobs = updJob . loadCriticalJobsOnly ( ) <EOL> log . syslog . command ( ) <EOL> self . _applyUpdate ( updJob , tagScript = tagScript , journal = journal , <EOL> autoPinList = autoPinList , commitFlags = commitFlags ) <EOL> log . syslog . commandComplete ( ) <EOL> self . recordManifest ( ) <EOL> if remainingJobs : <EOL> updJob . setCommitChangesetFlags ( commitFlags ) <EOL> restartDir = self . saveRestartInfo ( updJob , remainingJobs ) <EOL> return restartDir <EOL> return None <EOL> def recordManifest ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . cfg . root == '<STR_LIT>' or self . cfg . dbPath == '<STR_LIT>' : <EOL> return <EOL> manifest = sorted ( '<STR_LIT>' % x for x in self . db . iterAllTroves ( ) ) <EOL> manifestPath = util . joinPaths ( self . cfg . root , self . cfg . dbPath , '<STR_LIT>' ) <EOL> fd , tmpfile = tempfile . mkstemp ( dir = os . path . dirname ( manifestPath ) , <EOL> prefix = '<STR_LIT>' ) <EOL> try : <EOL> os . write ( fd , '<STR_LIT>' . join ( manifest ) ) <EOL> os . close ( fd ) <EOL> os . rename ( tmpfile , manifestPath ) <EOL> except Exception : <EOL> if os . path . exists ( tmpfile ) : <EOL> os . remove ( tmpfile ) <EOL> raise <EOL> def _combineJobs ( self , uJob , splitJob , criticalJobs ) : <EOL> """<STR_LIT>""" <EOL> combinedJobs = [ ] <EOL> i = <NUM_LIT:0> <EOL> while i < len ( splitJob ) : <EOL> newJob = [ ] <EOL> combinedJobs . append ( newJob ) <EOL> lastName = None <EOL> while i < len ( splitJob ) : <EOL> thisJob = splitJob [ i ] <EOL> if thisJob in criticalJobs : <EOL> if not newJob : <EOL> newJob . extend ( thisJob ) <EOL> i += <NUM_LIT:1> <EOL> break <EOL> names = set ( [ x [ <NUM_LIT:0> ] . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] for x in thisJob ] ) <EOL> firstName = list ( names ) [ <NUM_LIT:0> ] <EOL> if len ( names ) != <NUM_LIT:1> : <EOL> if lastName is None : <EOL> newJob . extend ( thisJob ) <EOL> i += <NUM_LIT:1> <EOL> break <EOL> elif lastName is not None and lastName != firstName : <EOL> break <EOL> lastName = firstName <EOL> newJob . extend ( thisJob ) <EOL> i += <NUM_LIT:1> <EOL> newJobs = [ ] <EOL> curJob = None <EOL> for jobList in combinedJobs : <EOL> if [ x for x in jobList if ( not '<STR_LIT>' in x [ <NUM_LIT:0> ] and '<STR_LIT::>' in x [ <NUM_LIT:0> ] ) or <EOL> x [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) or x [ <NUM_LIT:0> ] . startswith ( '<STR_LIT>' ) ] : <EOL> curJob = None <EOL> newJobs . append ( jobList ) <EOL> elif not curJob : <EOL> curJob = jobList <EOL> newJobs . append ( jobList ) <EOL> else : <EOL> curJob . extend ( jobList ) <EOL> combinedJobs = newJobs <EOL> newJob = [ ] <EOL> inGroup = None <EOL> updateMax = self . cfg . updateThreshold <EOL> finalCriticalJobs = [ ] <EOL> for jobList in combinedJobs : <EOL> isCritical = jobList in criticalJobs <EOL> foundGroup = None <EOL> infosAdded = set ( ) <EOL> infosRemoved = set ( ) <EOL> hasNonInfo = False <EOL> for job in jobList : <EOL> ( name , ( oldVersion , oldFlavor ) , <EOL> ( newVersion , newFlavor ) , absolute ) = job <EOL> if trove . troveIsGroup ( name ) : <EOL> foundGroup = True <EOL> if name . startswith ( '<STR_LIT>' ) : <EOL> if '<STR_LIT::>' in name : <EOL> pkg = name . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] <EOL> if oldVersion : <EOL> infosRemoved . add ( pkg ) <EOL> if newVersion : <EOL> infosAdded . add ( pkg ) <EOL> else : <EOL> hasNonInfo = True <EOL> infosAdded -= infosRemoved <EOL> if infosAdded and hasNonInfo : <EOL> raise AssertionError ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> % "<STR_LIT:U+002CU+0020>" . join ( sorted ( infosAdded ) ) ) <EOL> addJob = uJob . addJob <EOL> if isCritical : <EOL> if newJob : <EOL> addJob ( newJob ) <EOL> newJob = [ ] <EOL> inGroup = None <EOL> finalCriticalJobs . append ( len ( uJob . getJobs ( ) ) ) <EOL> addJob ( jobList ) <EOL> elif infosAdded and not hasNonInfo : <EOL> if newJob : <EOL> addJob ( newJob ) <EOL> newJob = [ ] <EOL> addJob ( jobList ) <EOL> elif foundGroup != inGroup : <EOL> if newJob : <EOL> addJob ( newJob ) <EOL> newJob = [ ] <EOL> newJob . extend ( jobList ) <EOL> inGroup = foundGroup <EOL> else : <EOL> if ( updateMax and newJob and <EOL> ( len ( newJob ) + len ( jobList ) ) > updateMax ) : <EOL> addJob ( newJob ) <EOL> newJob = [ ] <EOL> if [ x for x in jobList if '<STR_LIT>' in x [ <NUM_LIT:0> ] ] : <EOL> if newJob : <EOL> addJob ( newJob ) <EOL> addJob ( jobList ) <EOL> newJob = [ ] <EOL> else : <EOL> newJob . extend ( jobList ) <EOL> if newJob : <EOL> uJob . addJob ( newJob ) <EOL> uJob . setCriticalJobs ( finalCriticalJobs ) <EOL> @ api . publicApi <EOL> def updateChangeSet ( self , itemList , keepExisting = False , recurse = True , <EOL> resolveDeps = True , test = False , <EOL> updateByDefault = True , callback = None , <EOL> split = True , sync = False , fromChangesets = [ ] , <EOL> checkPathConflicts = True , checkPrimaryPins = True , <EOL> resolveRepos = True , syncChildren = False , <EOL> updateOnly = False , resolveGroupList = None , <EOL> installMissing = False , removeNotByDefault = False , <EOL> keepRequired = None , migrate = False , <EOL> criticalUpdateInfo = None , resolveSource = None , <EOL> updateJob = None , exactFlavors = False ) : <EOL> """<STR_LIT>""" <EOL> if keepRequired is None : <EOL> keepRequired = self . cfg . keepRequired <EOL> if callback : <EOL> import warnings <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . setUpdateCallback ( callback ) <EOL> if self . updateCallback is None : <EOL> self . setUpdateCallback ( UpdateCallback ( ) ) <EOL> self . updateCallback . preparingChangeSet ( ) <EOL> if criticalUpdateInfo is None : <EOL> criticalUpdateInfo = CriticalUpdateInfo ( ) <EOL> if updateJob : <EOL> uJob = updateJob <EOL> else : <EOL> uJob = database . UpdateJob ( self . db ) <EOL> hasCriticalUpdateInfo = False <EOL> troveSource = uJob . getTroveSource ( ) <EOL> first = True <EOL> for changeSet , incFConts in criticalUpdateInfo . iterChangeSets ( ) : <EOL> if first : <EOL> troveSource = trovesource . ChangesetFilesTroveSource ( self . db , <EOL> storeDeps = True ) <EOL> uJob . troveSource = troveSource <EOL> first = False <EOL> troveSource . addChangeSet ( changeSet , includesFileContents = incFConts ) <EOL> hasCriticalUpdateInfo = True <EOL> forceJobClosure = False <EOL> useAffinity = False <EOL> if fromChangesets : <EOL> forceJobClosure = True <EOL> csSource = trovesource . ChangesetFilesTroveSource ( self . db , <EOL> storeDeps = True ) <EOL> csSource . searchAsRepository ( ) <EOL> for cs in fromChangesets : <EOL> self . _replaceIncomplete ( cs , self . db , self . db , self . repos ) <EOL> csSource . addChangeSet ( cs , includesFileContents = True ) <EOL> uJob . getTroveSource ( ) . addChangeSet ( cs , <EOL> includesFileContents = True ) <EOL> mainSearchSource = None <EOL> troveSource = None <EOL> searchSource = None <EOL> if sync : <EOL> troveSource = trovesource . ReferencedTrovesSource ( self . db ) <EOL> elif syncChildren : <EOL> troveSource = self . db <EOL> elif fromChangesets : <EOL> troveSource = trovesource . stack ( csSource , self . repos ) <EOL> mainSearchSource = self . getSearchSource ( troveSource = troveSource ) <EOL> searchSource = mainSearchSource <EOL> elif hasCriticalUpdateInfo : <EOL> searchSource = uJob . getTroveSource ( ) <EOL> else : <EOL> mainSearchSource = self . getSearchSource ( ) <EOL> searchSource = mainSearchSource <EOL> uJob . setSearchSource ( mainSearchSource ) <EOL> useAffinity = True <EOL> if not searchSource and troveSource : <EOL> searchSource = searchsource . SearchSource ( troveSource , <EOL> self . cfg . flavor ) <EOL> uJob . setSearchSource ( searchSource ) <EOL> if resolveGroupList : <EOL> if not mainSearchSource : <EOL> mainSearchSource = self . getSearchSource ( ) <EOL> result = mainSearchSource . findTroves ( resolveGroupList , <EOL> useAffinity = useAffinity , <EOL> exactFlavors = exactFlavors ) <EOL> groupTups = list ( itertools . chain ( * result . itervalues ( ) ) ) <EOL> groupTroves = self . repos . getTroves ( groupTups , withFiles = False ) <EOL> resolveSource = resolve . DepResolutionByTroveList ( self . cfg , self . db , <EOL> groupTroves ) <EOL> if resolveSource : <EOL> resolveRepos = False <EOL> if migrate : <EOL> jobSet = self . _fullMigrate ( itemList , uJob , recurse = recurse ) <EOL> else : <EOL> jobSet = self . _updateChangeSet ( itemList , uJob , <EOL> keepExisting = keepExisting , <EOL> recurse = recurse , <EOL> updateMode = updateByDefault , <EOL> useAffinity = useAffinity , <EOL> checkPrimaryPins = checkPrimaryPins , <EOL> forceJobClosure = forceJobClosure , <EOL> syncChildren = syncChildren , <EOL> updateOnly = updateOnly , <EOL> installMissing = installMissing , <EOL> removeNotByDefault = removeNotByDefault , <EOL> exactFlavors = exactFlavors ) <EOL> self . _validateJob ( jobSet ) <EOL> if keepExisting : <EOL> for job in jobSet : <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None : <EOL> raise UpdateError , '<STR_LIT>' '<STR_LIT>' <EOL> self . updateCallback . resolvingDependencies ( ) <EOL> if resolveDeps or split : <EOL> ( depList , suggMap , cannotResolve , splitJob , keepList , <EOL> criticalUpdates ) = self . _resolveDependencies ( uJob , jobSet , split = split , <EOL> resolveDeps = resolveDeps , <EOL> useRepos = resolveRepos , <EOL> resolveSource = resolveSource , <EOL> keepRequired = keepRequired , <EOL> criticalUpdateInfo = criticalUpdateInfo ) <EOL> if not split : <EOL> splitJob = [ list ( jobSet ) ] <EOL> criticalUpdates = [ ] <EOL> else : <EOL> ( depList , suggMap , cannotResolve , splitJob , keepList , <EOL> criticalUpdates ) = ( [ ] , { } , [ ] , [ list ( jobSet ) ] , [ ] , [ ] ) <EOL> if keepList : <EOL> self . updateCallback . done ( ) <EOL> for job , depSet , reqInfo in sorted ( keepList ) : <EOL> self . updateCallback . warning ( '<STR_LIT>' , <EOL> job [ <NUM_LIT:0> ] , reqInfo [ <NUM_LIT:0> ] ) <EOL> if depList : <EOL> raise DepResolutionFailure ( self . cfg , depList , suggMap , <EOL> cannotResolve , splitJob , criticalUpdates ) <EOL> elif suggMap and not self . cfg . autoResolve : <EOL> raise NeededTrovesFailure ( self . cfg , depList , suggMap , <EOL> cannotResolve , splitJob , criticalUpdates ) <EOL> elif cannotResolve : <EOL> raise EraseDepFailure ( self . cfg , depList , suggMap , <EOL> cannotResolve , splitJob , criticalUpdates ) <EOL> if not sync and checkPathConflicts : <EOL> d = { } <EOL> conflicts = { } <EOL> for job in jobSet : <EOL> if not job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : continue <EOL> name , branch = job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . branch ( ) <EOL> l = d . setdefault ( ( name , branch ) , [ ] ) <EOL> l . append ( job ) <EOL> for jobList in d . values ( ) : <EOL> if len ( jobList ) < <NUM_LIT:2> : continue <EOL> trvs = uJob . getTroveSource ( ) . getTroves ( <EOL> [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) for x in jobList ] , <EOL> withFiles = False ) <EOL> paths = [ x . getPathHashes ( ) for x in trvs ] <EOL> for i , job in enumerate ( jobList ) : <EOL> for j in range ( i ) : <EOL> if ( trvs [ i ] . troveInfo . capsule . type ( ) == <EOL> trove . _TROVECAPSULE_TYPE_RPM and <EOL> trvs [ j ] . troveInfo . capsule . type ( ) == <EOL> trove . _TROVECAPSULE_TYPE_RPM ) : <EOL> continue <EOL> if not paths [ i ] . compatibleWith ( paths [ j ] ) : <EOL> l = conflicts . setdefault ( job [ <NUM_LIT:0> ] , [ ] ) <EOL> l . append ( ( job [ <NUM_LIT:2> ] , jobList [ j ] [ <NUM_LIT:2> ] ) ) <EOL> if conflicts : <EOL> raise InstallPathConflicts ( conflicts ) <EOL> if criticalUpdates : <EOL> criticalJobs = [ splitJob [ x ] for x in criticalUpdates ] <EOL> else : <EOL> criticalJobs = [ ] <EOL> if split : <EOL> self . _combineJobs ( uJob , splitJob , criticalJobs ) <EOL> else : <EOL> uJob . addJob ( list ( jobSet ) ) <EOL> uJob . reorderPreScripts ( criticalUpdateInfo ) <EOL> uJob . setTransactionCounter ( self . db . getTransactionCounter ( ) ) <EOL> kwargs = dict ( <EOL> keepExisting = keepExisting , <EOL> recurse = recurse , <EOL> resolveDeps = resolveDeps , <EOL> test = test , <EOL> updateByDefault = updateByDefault , <EOL> split = split , <EOL> sync = sync , <EOL> checkPathConflicts = checkPathConflicts , <EOL> checkPrimaryPins = checkPrimaryPins , <EOL> resolveRepos = resolveRepos , <EOL> syncChildren = syncChildren , <EOL> updateOnly = updateOnly , <EOL> resolveGroupList = resolveGroupList , <EOL> installMissing = installMissing , <EOL> removeNotByDefault = removeNotByDefault , <EOL> keepRequired = keepRequired , <EOL> migrate = migrate , <EOL> exactFlavors = False ) <EOL> kwargs = dict ( ( k , bool ( v ) ) for k , v in kwargs . iteritems ( ) ) <EOL> if not uJob . getRestartedFlag ( ) : <EOL> uJob . setKeywordArguments ( kwargs ) <EOL> uJob . setItemList ( itemList ) <EOL> uJob . setFromChangesets ( fromChangesets ) <EOL> return ( uJob , suggMap ) <EOL> def _validateJob ( self , jobSet ) : <EOL> """<STR_LIT>""" <EOL> oldTroves = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] ) for x in jobSet if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ] <EOL> if not len ( oldTroves ) == len ( set ( oldTroves ) ) : <EOL> extraTroves = set ( x for x in oldTroves if oldTroves . count ( x ) > <NUM_LIT:1> ) <EOL> raise InternalConaryError ( <EOL> "<STR_LIT>" <EOL> + '<STR_LIT>' . join ( '<STR_LIT>' % ( ( x [ <NUM_LIT:0> ] , ) + x [ <NUM_LIT:1> ] ) <EOL> for x in sorted ( extraTroves ) ) ) <EOL> newTroves = [ ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:2> ] ) for x in jobSet if x [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ] <EOL> if not len ( newTroves ) == len ( set ( newTroves ) ) : <EOL> extraTroves = [ x for x in newTroves if newTroves . count ( x ) > <NUM_LIT:1> ] <EOL> raise InternalConaryError ( <EOL> "<STR_LIT>" <EOL> + '<STR_LIT>' . join ( '<STR_LIT>' % ( ( x [ <NUM_LIT:0> ] , ) + x [ <NUM_LIT:1> ] ) <EOL> for x in sorted ( extraTroves ) ) ) <EOL> def _createCs ( self , repos , db , jobSet , uJob ) : <EOL> baseCs = changeset . ReadOnlyChangeSet ( ) <EOL> cs , remainder = uJob . getTroveSource ( ) . createChangeSet ( jobSet , <EOL> recurse = False , withFiles = True , <EOL> withFileContents = True , <EOL> useDatabase = False ) <EOL> baseCs . merge ( cs ) <EOL> if remainder : <EOL> newCs = repos . createChangeSet ( remainder , recurse = False , <EOL> callback = self . updateCallback ) <EOL> baseCs . merge ( newCs ) <EOL> self . _replaceIncomplete ( baseCs , db , db , repos ) <EOL> return baseCs <EOL> def _applyCs ( self , cs , uJob , ** kwargs ) : <EOL> uJob . troveSource . reset ( ) <EOL> jobIdx = kwargs . pop ( '<STR_LIT>' ) <EOL> tagScript = kwargs [ '<STR_LIT>' ] <EOL> justDatabase = kwargs [ '<STR_LIT>' ] . justDatabase <EOL> noScripts = kwargs [ '<STR_LIT>' ] . noScripts <EOL> kwargs . setdefault ( '<STR_LIT>' , { } ) <EOL> if ( uJob . hasJobPreScriptsOrder ( ) and <EOL> ( tagScript or not noScripts ) ) : <EOL> if not self . db . runPreScripts ( uJob , <EOL> callback = self . getUpdateCallback ( ) , <EOL> tagScript = tagScript , <EOL> justDatabase = justDatabase , <EOL> jobIdx = jobIdx ) : <EOL> raise UpdateError ( '<STR_LIT>' ) <EOL> try : <EOL> self . db . commitChangeSet ( cs , uJob , callback = self . updateCallback , <EOL> ** kwargs ) <EOL> except Exception , e : <EOL> self . db . db . rollback ( ) <EOL> if isinstance ( e , database . CommitError ) : <EOL> raise UpdateError , "<STR_LIT>" % e <EOL> raise <EOL> def _createAllCs ( self , q , allJobs , uJob , cfg , stopSelf ) : <EOL> import Queue <EOL> db = database . Database ( cfg . root , cfg . dbPath , timeout = <NUM_LIT> ) <EOL> uJob . troveSource . db = db <EOL> repos = self . createRepos ( db , cfg ) <EOL> self . updateCallback . setAbortEvent ( stopSelf ) <EOL> for i , job in enumerate ( allJobs ) : <EOL> if stopSelf . isSet ( ) : <EOL> return <EOL> self . updateCallback . setChangesetHunk ( i + <NUM_LIT:1> , len ( allJobs ) ) <EOL> try : <EOL> newCs = self . _createCs ( repos , db , job , uJob ) <EOL> except : <EOL> q . put ( ( True , sys . exc_info ( ) ) ) <EOL> return <EOL> while True : <EOL> try : <EOL> q . put ( ( False , newCs ) , True , <NUM_LIT:5> ) <EOL> break <EOL> except Queue . Full : <EOL> if stopSelf . isSet ( ) : <EOL> return <EOL> self . updateCallback . setAbortEvent ( None ) <EOL> q . put ( None ) <EOL> @ api . publicApi <EOL> def getDownloadSizes ( self , uJob ) : <EOL> """<STR_LIT>""" <EOL> allJobs = uJob . getJobs ( ) <EOL> flatJobs = [ x for x in itertools . chain ( * allJobs ) ] <EOL> flatSizes = self . repos . getChangeSetSize ( flatJobs ) <EOL> sizes = [ ] <EOL> for job in allJobs : <EOL> sizes . append ( sum ( flatSizes [ <NUM_LIT:0> : len ( job ) ] ) ) <EOL> flatSizes = flatSizes [ len ( job ) : ] <EOL> return sizes <EOL> @ api . publicApi <EOL> def downloadUpdate ( self , uJob , destDir ) : <EOL> """<STR_LIT>""" <EOL> allJobs = uJob . getJobs ( ) <EOL> csFiles = [ ] <EOL> for i , job in enumerate ( allJobs ) : <EOL> self . updateCallback . setChangesetHunk ( i + <NUM_LIT:1> , len ( allJobs ) ) <EOL> newCs = self . _createCs ( self . repos , self . db , job , uJob ) <EOL> path = os . path . join ( destDir , "<STR_LIT>" % i ) <EOL> newCs . writeToFile ( path ) <EOL> csFiles . append ( path ) <EOL> uJob . setJobsChangesetList ( csFiles ) <EOL> csSource = trovesource . ChangesetFilesTroveSource ( self . db , <EOL> storeDeps = True ) <EOL> csSource . addChangeSets ( <EOL> ( changeset . ChangeSetFromFile ( self . lzCache . open ( x ) ) <EOL> for x in csFiles ) , <EOL> includesFileContents = True ) <EOL> uJob . setSearchSource ( csSource ) <EOL> uJob . troveSource = csSource <EOL> uJob . setChangesetsDownloaded ( True ) <EOL> def applyUpdate ( self , uJob , replaceFiles = False , tagScript = None , <EOL> test = False , justDatabase = False , journal = None , <EOL> callback = None , localRollbacks = False , <EOL> autoPinList = cfgtypes . RegularExpressionList ( ) , <EOL> keepJournal = False , noScripts = False ) : <EOL> """<STR_LIT>""" <EOL> commitFlags = database . CommitChangeSetFlags ( <EOL> replaceManagedFiles = replaceFiles , <EOL> replaceUnmanagedFiles = replaceFiles , <EOL> replaceModifiedFiles = replaceFiles , <EOL> replaceModifiedConfigFiles = replaceFiles , <EOL> justDatabase = justDatabase , <EOL> noScripts = noScripts , <EOL> localRollbacks = localRollbacks , <EOL> test = test , keepJournal = keepJournal ) <EOL> return self . _applyUpdate ( uJob , tagScript = tagScript , <EOL> journal = journal , autoPinList = autoPinList , <EOL> commitFlags = commitFlags ) <EOL> def _applyUpdate ( self , * args , ** kwargs ) : <EOL> try : <EOL> self . db . commitLock ( True ) <EOL> return self . _applyUpdateL ( * args , ** kwargs ) <EOL> finally : <EOL> self . db . commitLock ( False ) <EOL> self . db . close ( ) <EOL> def _applyUpdateL ( self , uJob , tagScript = None , journal = None , <EOL> callback = None , autoPinList = None , <EOL> commitFlags = None ) : <EOL> uJobTransactionCounter = uJob . getTransactionCounter ( ) <EOL> if uJobTransactionCounter is None : <EOL> import warnings <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> elif uJobTransactionCounter != self . db . getTransactionCounter ( ) : <EOL> raise InternalConaryError ( "<STR_LIT>" ) <EOL> if callback : <EOL> import warnings <EOL> warnings . warn ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> self . setUpdateCallback ( callback ) <EOL> if self . updateCallback is None : <EOL> self . setUpdateCallback ( UpdateCallback ( ) ) <EOL> allJobs = uJob . getJobs ( ) <EOL> self . _validateJob ( list ( itertools . chain ( * allJobs ) ) ) <EOL> capsules . MetaCapsuleOperations . preload ( uJob . iterCapsuleTypes ( ) ) <EOL> if ( not uJob . hasJobPreScriptsOrder ( ) and <EOL> ( tagScript or not commitFlags . noScripts ) ) : <EOL> if not self . db . runPreScripts ( uJob , <EOL> callback = self . getUpdateCallback ( ) , <EOL> tagScript = tagScript , <EOL> justDatabase = commitFlags . justDatabase ) : <EOL> raise UpdateError ( '<STR_LIT>' ) <EOL> kwargs = dict ( <EOL> commitFlags = commitFlags , tagScript = tagScript , <EOL> journal = journal , autoPinList = autoPinList ) <EOL> if len ( allJobs ) == <NUM_LIT:1> and not uJob . getChangesetsDownloaded ( ) : <EOL> self . updateCallback . setChangesetHunk ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> newCs = self . _createCs ( self . repos , self . db , allJobs [ <NUM_LIT:0> ] , uJob ) <EOL> self . updateCallback . setUpdateHunk ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> self . updateCallback . setUpdateJob ( allJobs [ <NUM_LIT:0> ] ) <EOL> kwargs [ '<STR_LIT>' ] = <NUM_LIT:0> <EOL> self . _applyCs ( newCs , uJob , ** kwargs ) <EOL> self . updateCallback . updateDone ( ) <EOL> return <EOL> removeHints = dict ( ) <EOL> for job in allJobs : <EOL> removeHints . update ( [ ( ( x [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) , None ) <EOL> for x in job if x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] is not None ] ) <EOL> if uJob . getChangesetsDownloaded ( ) or self . cfg . downloadFirst or not self . cfg . threaded : <EOL> def _applyCs ( job , newCs , i , maxlen ) : <EOL> self . updateCallback . setUpdateHunk ( i + <NUM_LIT:1> , maxlen ) <EOL> self . updateCallback . setUpdateJob ( job ) <EOL> kwargs [ '<STR_LIT>' ] = i <EOL> self . _applyCs ( newCs , uJob , removeHints = removeHints , ** kwargs ) <EOL> self . updateCallback . updateDone ( ) <EOL> if self . cfg . downloadFirst : <EOL> csList = [ ] <EOL> for i , job in enumerate ( allJobs ) : <EOL> self . updateCallback . setChangesetHunk ( i + <NUM_LIT:1> , len ( allJobs ) ) <EOL> newCs = self . _createCs ( self . repos , self . db , job , uJob ) <EOL> csList . append ( ( job , newCs ) ) <EOL> for i , ( job , newCs ) in enumerate ( csList ) : <EOL> _applyCs ( job , newCs , i , len ( csList ) ) <EOL> else : <EOL> for i , job in enumerate ( allJobs ) : <EOL> self . updateCallback . setChangesetHunk ( i + <NUM_LIT:1> , len ( allJobs ) ) <EOL> newCs = self . _createCs ( self . repos , self . db , job , uJob ) <EOL> _applyCs ( job , newCs , i , len ( allJobs ) ) <EOL> if self . getRepos ( ) : <EOL> self . getRepos ( ) . _clearHostCache ( ) <EOL> return <EOL> import Queue <EOL> from threading import Thread , Event <EOL> csQueue = Queue . Queue ( <NUM_LIT:5> ) <EOL> stopDownloadEvent = Event ( ) <EOL> downloadThread = Thread ( None , self . _createAllCs , <EOL> args = ( csQueue , allJobs , uJob , self . cfg , stopDownloadEvent ) ) <EOL> downloadThread . start ( ) <EOL> try : <EOL> i = <NUM_LIT:0> <EOL> while True : <EOL> try : <EOL> newCs = csQueue . get ( True , <NUM_LIT:10> ) <EOL> except Queue . Empty : <EOL> if downloadThread . isAlive ( ) : <EOL> continue <EOL> raise UpdateError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> if newCs is None : <EOL> break <EOL> isException , val = newCs <EOL> if isException : <EOL> raise val [ <NUM_LIT:0> ] , val [ <NUM_LIT:1> ] , val [ <NUM_LIT:2> ] <EOL> newCs = val <EOL> i += <NUM_LIT:1> <EOL> self . updateCallback . setUpdateHunk ( i , len ( allJobs ) ) <EOL> self . updateCallback . setUpdateJob ( allJobs [ i - <NUM_LIT:1> ] ) <EOL> kwargs [ '<STR_LIT>' ] = i - <NUM_LIT:1> <EOL> self . _applyCs ( newCs , uJob , removeHints = removeHints , <EOL> ** kwargs ) <EOL> self . updateCallback . updateDone ( ) <EOL> if self . updateCallback . cancelOperation ( ) : <EOL> break <EOL> finally : <EOL> stopDownloadEvent . set ( ) <EOL> downloadThread . join ( <NUM_LIT:20> ) <EOL> if self . getRepos ( ) : <EOL> self . getRepos ( ) . _clearHostCache ( ) <EOL> if downloadThread . isAlive ( ) : <EOL> self . updateCallback . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . db . close ( ) <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> if tb : <EOL> tb = traceback . format_tb ( tb ) <EOL> self . updateCallback . warning ( '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> exc_text = '<STR_LIT>' . join ( tb ) ) <EOL> os . kill ( os . getpid ( ) , <NUM_LIT:15> ) <EOL> else : <EOL> pass <EOL> @ api . publicApi <EOL> def syncCapsuleDatabase ( self , callback = None , makePins = True ) : <EOL> mode = self . cfg . syncCapsuleDatabase <EOL> if mode == '<STR_LIT:false>' or not mode : <EOL> return <NUM_LIT:0> <EOL> elif mode != '<STR_LIT>' : <EOL> makePins = False <EOL> return self . db . syncCapsuleDatabase ( makePins , callback ) <EOL> class UpdateError ( ClientError ) : <EOL> """<STR_LIT>""" <EOL> def display ( self ) : <EOL> return str ( self ) <EOL> class DowngradeError ( UpdateError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , downgrades ) : <EOL> self . downgrades = downgrades <EOL> msg = [ ] <EOL> msg . append ( '<STR_LIT>' ) <EOL> for ( troveSpec , label ) , ( localTups , repoTups ) in downgrades . iteritems ( ) : <EOL> repoVersions = [ '<STR_LIT>' % ( x [ <NUM_LIT:1> ] . trailingLabel ( ) , <EOL> x [ <NUM_LIT:1> ] . trailingRevision ( ) , <EOL> deps . getInstructionSetFlavor ( x [ <NUM_LIT:2> ] ) ) <EOL> for x in repoTups ] <EOL> repoVersions = '<STR_LIT>' . join ( repoVersions ) <EOL> localVersions = [ '<STR_LIT>' % ( x [ <NUM_LIT:1> ] . trailingLabel ( ) , <EOL> x [ <NUM_LIT:1> ] . trailingRevision ( ) , <EOL> deps . getInstructionSetFlavor ( x [ <NUM_LIT:2> ] ) ) <EOL> for x in localTups ] <EOL> localVersions = '<STR_LIT>' . join ( localVersions ) <EOL> msg . append ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' % ( troveSpec [ <NUM_LIT:0> ] , repoVersions , <EOL> localVersions ) ) <EOL> msg = '<STR_LIT>' . join ( msg ) <EOL> UpdateError . __init__ ( self , msg ) <EOL> class UpdatePinnedTroveError ( UpdateError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , pinnedTrove , newVersion = None ) : <EOL> self . pinnedTrove = pinnedTrove <EOL> self . newVersion = newVersion <EOL> def __str__ ( self ) : <EOL> name = self . pinnedTrove [ <NUM_LIT:0> ] <EOL> if self . newVersion : <EOL> return """<STR_LIT>""" % ( ( name , name ) + self . pinnedTrove ) <EOL> else : <EOL> return """<STR_LIT>""" % ( ( name , name ) + self . pinnedTrove + self . pinnedTrove ) <EOL> class NoNewTrovesError ( UpdateError ) : <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" <EOL> class DependencyFailure ( UpdateError ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , cfg , depList , suggMap , cannotResolve , <EOL> jobSets , criticalUpdates ) : <EOL> self . cfg = cfg <EOL> self . depList = depList <EOL> self . suggMap = suggMap <EOL> self . cannotResolve = cannotResolve <EOL> self . jobSets = jobSets <EOL> self . criticalUpdates = criticalUpdates <EOL> self . errorMessage = self . _initErrorMessage ( ) <EOL> def __str__ ( self ) : <EOL> return self . errorMessage <EOL> def setErrorMessage ( self , errorMessage ) : <EOL> self . errorMessage = errorMessage <EOL> def getErrorMessage ( self ) : <EOL> return self . errorMessage <EOL> def hasCriticalUpdates ( self ) : <EOL> return bool ( self . criticalUpdates ) <EOL> def getCriticalUpdates ( self ) : <EOL> return self . criticalUpdates <EOL> def getSuggestions ( self ) : <EOL> return self . suggMap <EOL> def getDepList ( self ) : <EOL> return self . depList <EOL> def getCannotResolve ( self ) : <EOL> return self . cannotResolve <EOL> def getJobSets ( self ) : <EOL> return self . jobSets <EOL> def formatVF ( self , troveTup , showVersion = True ) : <EOL> if self . cfg . fullVersions : <EOL> version = troveTup [ <NUM_LIT:1> ] <EOL> elif self . cfg . showLabels : <EOL> version = '<STR_LIT>' % ( troveTup [ <NUM_LIT:1> ] . branch ( ) . label ( ) , <EOL> troveTup [ <NUM_LIT:1> ] . trailingRevision ( ) ) <EOL> elif showVersion : <EOL> version = troveTup [ <NUM_LIT:1> ] . trailingRevision ( ) <EOL> else : <EOL> version = '<STR_LIT>' <EOL> if self . cfg . fullFlavors : <EOL> flavor = '<STR_LIT>' % troveTup [ <NUM_LIT:2> ] <EOL> else : <EOL> flavor = '<STR_LIT>' <EOL> return '<STR_LIT>' % ( version , flavor ) <EOL> def formatNVF ( self , troveTup , showVersion = True ) : <EOL> if not self . cfg : <EOL> return '<STR_LIT>' % ( troveTup [ <NUM_LIT:0> ] , troveTup [ <NUM_LIT:1> ] . trailingRevision ( ) ) <EOL> versionFlavor = self . formatVF ( troveTup , showVersion = showVersion ) <EOL> if versionFlavor and versionFlavor [ <NUM_LIT:0> ] != '<STR_LIT:[>' : <EOL> return '<STR_LIT>' % ( troveTup [ <NUM_LIT:0> ] , versionFlavor ) <EOL> return '<STR_LIT>' % ( troveTup [ <NUM_LIT:0> ] , versionFlavor ) <EOL> class DepResolutionFailure ( DependencyFailure ) : <EOL> """<STR_LIT>""" <EOL> def getFailures ( self ) : <EOL> return self . depList <EOL> def _initErrorMessage ( self ) : <EOL> res = [ "<STR_LIT>" ] <EOL> for ( troveInfo , depSet ) in self . depList : <EOL> res . append ( "<STR_LIT>" % ( self . formatNVF ( troveInfo ) , <EOL> "<STR_LIT>" . join ( str ( depSet ) . split ( "<STR_LIT:\n>" ) ) ) ) <EOL> return '<STR_LIT:\n>' . join ( res ) <EOL> class EraseDepFailure ( DepResolutionFailure ) : <EOL> """<STR_LIT>""" <EOL> def getFailures ( self ) : <EOL> return self . cannotResolve <EOL> def _initErrorMessage ( self ) : <EOL> res = [ ] <EOL> packagesByErase = { } <EOL> packagesByInstall = { } <EOL> resolved = set ( itertools . chain ( * self . suggMap . values ( ) ) ) <EOL> for jobSet in self . jobSets : <EOL> for job in jobSet : <EOL> newInfo = job [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] <EOL> oldInfo = job [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> packagesByErase [ oldInfo ] = newInfo <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> packagesByInstall [ newInfo ] = oldInfo <EOL> res . append ( <EOL> '<STR_LIT>' ) <EOL> for ( reqBy , depSet , providedBy ) in self . getFailures ( ) : <EOL> providers = [ ] <EOL> for oldInfo in providedBy : <EOL> newInfo = packagesByErase [ oldInfo ] <EOL> if not newInfo [ <NUM_LIT:1> ] : <EOL> status = '<STR_LIT>' <EOL> else : <EOL> status = '<STR_LIT>' % self . formatVF ( newInfo ) <EOL> providedInfo = '<STR_LIT>' % ( self . formatNVF ( oldInfo ) , status ) <EOL> providers . append ( providedInfo ) <EOL> if reqBy in packagesByInstall : <EOL> oldInfo = packagesByInstall [ reqBy ] <EOL> if oldInfo [ <NUM_LIT:1> ] : <EOL> reqByInfo = '<STR_LIT>' % ( <EOL> self . formatNVF ( reqBy ) , <EOL> self . formatVF ( oldInfo ) ) <EOL> elif reqBy in resolved : <EOL> reqByInfo = '<STR_LIT>' % self . formatNVF ( reqBy ) <EOL> else : <EOL> reqByInfo = '<STR_LIT>' % self . formatNVF ( reqBy ) <EOL> else : <EOL> reqByInfo = '<STR_LIT>' % self . formatNVF ( reqBy ) <EOL> res . append ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" % ( reqByInfo , <EOL> "<STR_LIT>" . join ( str ( depSet ) . split ( "<STR_LIT:\n>" ) ) , <EOL> '<STR_LIT>' . join ( providers ) ) ) <EOL> return '<STR_LIT:\n>' . join ( res ) <EOL> class NeededTrovesFailure ( DependencyFailure ) : <EOL> """<STR_LIT>""" <EOL> def _initErrorMessage ( self ) : <EOL> res = [ ] <EOL> requiredBy = { } <EOL> for ( reqInfo , suggList ) in self . suggMap . iteritems ( ) : <EOL> for sugg in sorted ( suggList ) : <EOL> if sugg in requiredBy : <EOL> requiredBy [ sugg ] . append ( reqInfo ) <EOL> else : <EOL> requiredBy [ sugg ] = [ reqInfo ] <EOL> numPackages = len ( requiredBy ) <EOL> if numPackages == <NUM_LIT:1> : <EOL> res . append ( "<STR_LIT>" % numPackages ) <EOL> else : <EOL> res . append ( "<STR_LIT>" % numPackages ) <EOL> for ( suggInfo , reqList ) in sorted ( requiredBy . iteritems ( ) ) : <EOL> res . append ( "<STR_LIT>" % self . formatNVF ( suggInfo ) ) <EOL> for reqInfo in sorted ( reqList ) : <EOL> res . append ( '<STR_LIT>' % self . formatNVF ( reqInfo ) ) <EOL> return '<STR_LIT:\n>' . join ( res ) <EOL> class InstallPathConflicts ( UpdateError ) : <EOL> def __str__ ( self ) : <EOL> res = [ ] <EOL> res . append ( "<STR_LIT>" ) <EOL> for name , l in sorted ( self . conflicts . iteritems ( ) ) : <EOL> res . append ( "<STR_LIT>" % ( name , <EOL> "<STR_LIT:U+0020>" . join ( [ "<STR_LIT>" % <EOL> ( x [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . asString ( ) , <EOL> deps . formatFlavor ( x [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) , <EOL> x [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . asString ( ) , <EOL> deps . formatFlavor ( x [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) ) <EOL> for x in l ] ) ) ) <EOL> return '<STR_LIT:\n>' . join ( res ) <EOL> def __init__ ( self , conflicts ) : <EOL> self . conflicts = conflicts <EOL> def _serV ( vers , frozen = False ) : <EOL> if frozen : <EOL> return vers . freeze ( ) <EOL> return str ( vers ) <EOL> def _serF ( flv , frozen = False ) : <EOL> if frozen : <EOL> return flv . freeze ( ) <EOL> return str ( flv ) <EOL> def _serializeJob ( job , frozen = False ) : <EOL> jobStr = [ ] <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> jobStr . append ( '<STR_LIT>' % ( job [ <NUM_LIT:0> ] , _serV ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , frozen ) , <EOL> _serF ( job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , frozen ) ) ) <EOL> else : <EOL> jobStr . append ( '<STR_LIT>' % ( job [ <NUM_LIT:0> ] , ) ) <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> jobStr . append ( '<STR_LIT>' % ( _serV ( job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] , frozen ) , <EOL> _serF ( job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] , frozen ) ) ) <EOL> return '<STR_LIT>' . join ( jobStr ) <EOL> def _serializeJobList ( jobList ) : <EOL> return '<STR_LIT:\n>' . join ( _serializeJob ( x ) for x in jobList ) <EOL> def _unserializeJobList ( iterable ) : <EOL> return cmdline . parseChangeList ( x . strip ( ) for x in iterable ) <EOL> def _serializePreScripts ( preScripts ) : <EOL> return '<STR_LIT:\n>' . join ( "<STR_LIT>" % ( act , _serializeJob ( job , frozen = True ) ) <EOL> for act , job in preScripts ) <EOL> def _unserializePreScripts ( iterable ) : <EOL> ret = [ ] <EOL> for line in iterable : <EOL> arr = line . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) <EOL> if len ( arr ) != <NUM_LIT:2> : <EOL> continue <EOL> ret . append ( ( arr [ <NUM_LIT:0> ] , cmdline . parseChangeSpec ( arr [ <NUM_LIT:1> ] , <EOL> withFrozenFlavor = True ) ) ) <EOL> return ret <EOL> def _storeJobInfo ( remainingJobs , updJob ) : <EOL> changeSetSource = updJob . getTroveSource ( ) <EOL> restartDir = tempfile . mkdtemp ( prefix = '<STR_LIT>' ) <EOL> csIndexPath = os . path . join ( restartDir , '<STR_LIT>' ) <EOL> csIndex = open ( csIndexPath , "<STR_LIT:w>" ) <EOL> for idx , ( cs , fname , incFConts ) in enumerate ( changeSetSource . iterChangeSetsFlags ( ) ) : <EOL> if isinstance ( cs , changeset . ChangeSetFromFile ) : <EOL> csFileName = util . normpath ( os . path . abspath ( cs . fileName ) ) <EOL> else : <EOL> cs . reset ( ) <EOL> csFileName = os . path . join ( restartDir , '<STR_LIT>' % idx ) <EOL> cs . writeToFile ( csFileName ) <EOL> csIndex . write ( "<STR_LIT>" % ( csFileName , int ( incFConts ) ) ) <EOL> csIndex . close ( ) <EOL> jobSetPath = os . path . join ( restartDir , '<STR_LIT>' ) <EOL> jobFile = open ( jobSetPath , '<STR_LIT:w>' ) <EOL> jobFile . write ( _serializeJobList ( itertools . chain ( * remainingJobs ) ) ) <EOL> jobFile . close ( ) <EOL> extraDir = restartDir + "<STR_LIT>" <EOL> try : <EOL> os . mkdir ( extraDir ) <EOL> except OSError : <EOL> util . rmtree ( extraDir , ignore_errors = True ) <EOL> os . mkdir ( extraDir ) <EOL> versionFilePath = os . path . join ( extraDir , "<STR_LIT>" ) <EOL> versionFile = open ( versionFilePath , "<STR_LIT>" ) <EOL> versionFile . write ( "<STR_LIT>" % constants . version ) <EOL> versionFile . close ( ) <EOL> versionFilePath = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> versionFile = open ( versionFilePath , "<STR_LIT>" ) <EOL> versionFile . write ( "<STR_LIT>" % constants . version ) <EOL> versionFile . close ( ) <EOL> invocationInfoPath = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> updJob . saveInvocationInfo ( invocationInfoPath ) <EOL> featuresFilePath = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> updJob . saveFeatures ( featuresFilePath ) <EOL> path = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> file ( path , "<STR_LIT:w>" ) . write ( _serializePreScripts ( <EOL> updJob . iterJobPreScriptsAlreadyRun ( ) ) ) <EOL> troveMapDir = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> updJob . saveTroveMap ( troveMapDir ) <EOL> return restartDir <EOL> def _loadRestartInfo ( restartDir , updJob ) : <EOL> lazyFileCache = updJob . lzCache <EOL> changeSetList = [ ] <EOL> fileDict = dict ( ( os . path . join ( restartDir , x ) , False ) <EOL> for x in os . listdir ( restartDir ) if x . endswith ( '<STR_LIT>' ) ) <EOL> csIndexPath = os . path . join ( restartDir , '<STR_LIT>' ) <EOL> if os . path . exists ( csIndexPath ) : <EOL> for line in open ( csIndexPath ) : <EOL> cspath , includesFileContents = line . strip ( ) . split ( ) [ : <NUM_LIT:2> ] <EOL> includesFileContents = bool ( int ( includesFileContents ) ) <EOL> fileDict [ cspath ] = includesFileContents <EOL> for path , includesFileContents in fileDict . iteritems ( ) : <EOL> csFileName = os . path . join ( restartDir , path ) <EOL> cs = changeset . ChangeSetFromFile ( lazyFileCache . open ( csFileName ) ) <EOL> changeSetList . append ( ( cs , includesFileContents ) ) <EOL> jobSetPath = os . path . join ( restartDir , '<STR_LIT>' ) <EOL> jobSet = _unserializeJobList ( open ( jobSetPath ) ) <EOL> finalJobSet = [ ] <EOL> for job in jobSet : <EOL> if job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] : <EOL> oldVersion = versions . VersionFromString ( job [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] ) <EOL> else : <EOL> oldVersion = None <EOL> if job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] : <EOL> newVersion = versions . VersionFromString ( job [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] ) <EOL> else : <EOL> newVersion = None <EOL> finalJobSet . append ( ( job [ <NUM_LIT:0> ] , ( oldVersion , job [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) , <EOL> ( newVersion , job [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ) , job [ <NUM_LIT:3> ] ) ) <EOL> util . rmtree ( restartDir + "<STR_LIT>" , ignore_errors = True ) <EOL> invInfoFile = util . joinPaths ( restartDir , '<STR_LIT>' ) <EOL> if os . path . exists ( invInfoFile ) : <EOL> try : <EOL> updJob . loadInvocationInfo ( invInfoFile ) <EOL> except DecodingError : <EOL> pass <EOL> verFile = util . joinPaths ( restartDir , '<STR_LIT>' ) <EOL> if os . path . exists ( verFile ) : <EOL> ver = [ ] <EOL> try : <EOL> ver = [ x for x in file ( verFile ) if x . startswith ( '<STR_LIT>' ) ] <EOL> except IOError : <EOL> pass <EOL> else : <EOL> if ver : <EOL> ver = ver [ <NUM_LIT:0> ] <EOL> updJob . setPreviousVersion ( ver . strip ( ) . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] ) <EOL> featuresFilePath = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> updJob . loadFeatures ( featuresFilePath ) <EOL> path = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> try : <EOL> iterable = file ( path ) <EOL> except IOError : <EOL> iterable = [ ] <EOL> updJob . setJobPreScriptsAlreadyRun ( _unserializePreScripts ( iterable ) ) <EOL> troveMapDir = os . path . join ( restartDir , "<STR_LIT>" ) <EOL> updJob . loadTroveMap ( troveMapDir ) <EOL> return finalJobSet , changeSetList </s>
