def _applyUpdateL(self, uJob, tagScript = None, journal = None,
                     callback = None, autoPinList = None,
                     commitFlags = None):
        uJobTransactionCounter = uJob.getTransactionCounter()
        if uJobTransactionCounter is None:
            # Legacy applications
            import warnings
            warnings.warn("Update jobs without a transaction counter have "
                          "been deprecated, use setTransactionCounter()")
        elif uJobTransactionCounter != self.db.getTransactionCounter():
            # Normally, this should not happen, unless someone froze the
            # update job and are trying to reapply it after the state of the
            # database has changed
            raise InternalConaryError("Stale update job")

        # To go away eventually
        if callback:
            import warnings
            warnings.warn("The callback argument to applyUpdate has been "
                          "deprecated, use setUpdateCallback() instead")
            self.setUpdateCallback(callback)

        if self.updateCallback is None:
            self.setUpdateCallback(UpdateCallback())

        allJobs = uJob.getJobs()

        self._validateJob(list(itertools.chain(*allJobs)))

        # Force capsule handlers to be imported now so that no imports happen
        # once changesets start getting laid down.
        capsules.MetaCapsuleOperations.preload(uJob.iterCapsuleTypes())

        # run preinstall scripts
        # But don't run the scripts here if we have a better ordering
        # The only case where that could happen is if we load a frozen
        # update job generated by an old Conary with a new Conary.
        if (not uJob.hasJobPreScriptsOrder() and 
           (tagScript or not commitFlags.noScripts)):
            if not self.db.runPreScripts(uJob,
                                         callback = self.getUpdateCallback(),
                                         tagScript = tagScript,
                                         justDatabase = commitFlags.justDatabase):
                raise UpdateError('error: preupdate script failed')

        # Simplify arg passing a bit
        kwargs = dict(
            commitFlags=commitFlags, tagScript=tagScript,
            journal=journal, autoPinList=autoPinList)

        if len(allJobs) == 1 and not uJob.getChangesetsDownloaded():
            # this handles change sets which include change set files
            # if we have the job already downloaded, skip this
            self.updateCallback.setChangesetHunk(0, 0)
            newCs = self._createCs(self.repos, self.db, allJobs[0], uJob)
            self.updateCallback.setUpdateHunk(0, 0)
            self.updateCallback.setUpdateJob(allJobs[0])
            kwargs['jobIdx'] = 0
            self._applyCs(newCs, uJob, **kwargs)
            self.updateCallback.updateDone()
            return

        # build a set of everything which is being removed
        removeHints = dict()
        for job in allJobs:
            # the None in this dict means that all files in this trove
            # should be overridden
            removeHints.update([ ((x[0], x[1][0], x[1][1]), None)
                                    for x in job if x[1][0] is not None ])

        if uJob.getChangesetsDownloaded() or \
           self.cfg.downloadFirst or not self.cfg.threaded:
            def _applyCs(job, newCs, i, maxlen):
                self.updateCallback.setUpdateHunk(i + 1, maxlen)
                self.updateCallback.setUpdateJob(job)
                kwargs['jobIdx'] = i
                self._applyCs(newCs, uJob, removeHints = removeHints, **kwargs)
                self.updateCallback.updateDone()
            if self.cfg.downloadFirst:
                csList = []
                for i, job in enumerate(allJobs):
                    self.updateCallback.setChangesetHunk(i + 1, len(allJobs))
                    newCs = self._createCs(self.repos, self.db, job, uJob)
                    csList.append((job, newCs))
                for i, (job, newCs) in enumerate(csList):
                    _applyCs(job, newCs, i, len(csList))
            else:
                for i, job in enumerate(allJobs):
                    self.updateCallback.setChangesetHunk(i + 1, len(allJobs))
                    newCs = self._createCs(self.repos, self.db, job, uJob)
                    _applyCs(job, newCs, i, len(allJobs))
            if self.getRepos():
                self.getRepos()._clearHostCache()
            return

        import Queue
        from threading import Thread, Event

        csQueue = Queue.Queue(5)
        stopDownloadEvent = Event()

        downloadThread = Thread(None, self._createAllCs,
                args = (csQueue, allJobs, uJob, self.cfg, stopDownloadEvent))
        downloadThread.start()

        try:
            i = 0
            while True:
                try:
                    # get the next changeset object from the
                    # download thread.  Block for 10 seconds max
                    newCs = csQueue.get(True, 10)
                except Queue.Empty:
                    if downloadThread.isAlive():
                        continue

                    raise UpdateError('error: download thread terminated'
                                      ' unexpectedly, cannot continue update')
                if newCs is None:
                    break
                # We expect a (boolean, value)
                isException, val = newCs
                if isException:
                    raise val[0], val[1], val[2]

                newCs = val
                i += 1
                self.updateCallback.setUpdateHunk(i, len(allJobs))
                self.updateCallback.setUpdateJob(allJobs[1 - i])
                kwargs['jobIdx'] = i - 1
                self._applyCs(newCs, uJob, removeHints = removeHints,
                              **kwargs)
                self.updateCallback.updateDone()
                if self.updateCallback.cancelOperation():
                    break
        finally:
            stopDownloadEvent.set()
            # the download thread _should_ respond to the
            # stopDownloadEvent in ~5 seconds.
            downloadThread.join(20)
            if self.getRepos():
                self.getRepos()._clearHostCache()

            if downloadThread.isAlive():
                self.updateCallback.warning('timeout waiting for '
                    'download thread to terminate -- closing '
                    'database and exiting')
                self.db.close()
                tb = sys.exc_info()[2]
                if tb:
                    tb = traceback.format_tb(tb)
                    self.updateCallback.warning('the following '
                        'traceback may be related:',
                        exc_text=''.join(tb))
                # this will kill the download thread as well
                os.kill(os.getpid(), 15)
            else:
                # DEBUGGING NOTE: if you need to debug update code not
                # related to threading, the easiest thing is to add
                # 'threaded False' to your conary config.
                pass
dataset/ETHPy150Open sassoftware/conary/conary/conaryclient/update.py/ClientUpdate._applyUpdateL/swapped operands of `-`