def addTroveDone(self, troveInfo, mirror=False):
        cu = troveInfo.cu
        trv = troveInfo.trv
        trvCs = troveInfo.trvCs
        hidden = troveInfo.hidden

        newFilesInsertList = troveInfo.newFilesInsertList

        self.log(3, trv)

        troveVersion = trv.getVersion()
        troveItemId = self.getItemId(trv.getName())
        sourceName = trv.troveInfo.sourceName()

        # Pull out the clonedFromId
        clonedFrom = trv.troveInfo.clonedFrom()
        clonedFromId = None
        if clonedFrom:
            clonedFromId = self.versionTable.get(clonedFrom, None)
            if clonedFromId is None:
                clonedFromId = self.versionTable.addId(clonedFrom)

        isPackage = (not trv.getName().startswith('group') and
                     not trv.getName().startswith('fileset') and
                     ':' not in trv.getName())

        troveVersionId = self.versionTable.get(troveVersion, None)
        if troveVersionId is not None:
            nodeId = self.versionOps.nodes.getRow(
                troveItemId, troveVersionId, None)

        # this also adds all the missing flavors into the mix
        troveFlavorId = self._addTroveNewFlavors(cu, trv)

        if troveVersionId is None or nodeId is None:
            (nodeId, troveVersionId) = self.versionOps.createVersion(
                troveItemId, troveVersion, troveFlavorId, sourceName)
            if trv.getChangeLog() and trv.getChangeLog().getName():
                self.changeLogs.add(nodeId, trv.getChangeLog())
        elif sourceName: # make sure the sourceItemId matches for the trove we are comitting
            sourceItemId = self.items.getOrAddId(sourceName)
            self.versionOps.nodes.updateSourceItemId(nodeId, sourceItemId, mirrorMode=mirror)

        # the instance may already exist (it could be referenced by a package
        # which has already been added)
        if hidden:
            presence = instances.INSTANCE_PRESENT_HIDDEN
        else:
            presence = instances.INSTANCE_PRESENT_NORMAL

        troveInstanceId = self.getInstanceId(troveItemId, troveVersionId,
                         troveFlavorId, clonedFromId, trv.getType(),
                         isPresent = presence)
        # check that we don't have any TroveTroves entries yet
        cu.execute("select includedId from TroveTroves "
                   "where instanceId = ? limit 1", troveInstanceId)
        assert(len(cu.fetchall()) == 0), "troveId=%d %s has TroveTroves entries" % (
            troveInstanceId, trv.getNameVersionFlavor())

        troveBranchId = self.branchTable[troveVersion.branch()]
        self.depAdder.add(trv, troveInstanceId)

        if trvCs.getOldVersion():
            oldTroveVersionId = self.versionTable.get(trvCs.getOldVersion(),
                                                      None)
            oldFlavorId = self.flavors.get(trvCs.getOldFlavor(), None)
            oldInstanceId = self.instances[(troveItemId,
                                            oldTroveVersionId,
                                            oldFlavorId)]
        else:
            oldInstanceId = None

        cu.execute("""
        INSERT INTO tmpNewTroves (itemId, branchId, flavorId,
                                  instanceId, versionId,
                                  finalTimeStamp, troveType,
                                  oldInstanceId, hidden)
        VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
        """, troveItemId, troveBranchId, troveFlavorId,
             troveInstanceId, troveVersionId,
             '%.3f' % trv.getVersion().timeStamps()[-1],
             trv.getType(), oldInstanceId, int(hidden))

        # Fold tmpNewFiles into FileStreams
        if len(newFilesInsertList):
            self.db.bulkload("tmpNewFiles",
                    [ x + (troveInstanceId,) for x in newFilesInsertList ],
                    [ "pathId", "versionId", "fileId",
                      "dirnameId", "basenameId", "pathChanged",
                      "instanceId" ])

        # iterate over both strong and weak troves, and set weakFlag to
        # indicate which kind we're looking at when
        insertList = []
        for ((name, version, flavor), weakFlag) in itertools.chain(
                itertools.izip(trv.iterTroveList(strongRefs = True,
                                                   weakRefs   = False),
                               itertools.repeat(0)),
                itertools.izip(trv.iterTroveList(strongRefs = False,
                                                   weakRefs   = True),
                               itertools.repeat(schema.TROVE_TROVES_WEAKREF))):

            flags = weakFlag
            if trv.includeTroveByDefault(name, version, flavor):
                flags |= schema.TROVE_TROVES_BYDEFAULT

            # sanity check - version/flavor of components must match the
            # version/flavor of the package
            assert(not isPackage or version == trv.getVersion())
            assert(not isPackage or flavor == trv.getFlavor())
            insertList.append((name, str(version), version.freeze(),
                               ":".join([x % "%.3f" for x in
                                            version.timeStamps()]),
                               '%.3f' %version.timeStamps()[-1],
                               str(version.branch()),
                               str(version.trailingLabel()),
                               flavor.freeze(), flags, troveInstanceId,
                               trv.getType()))

        if len(insertList):
            self.db.bulkload("tmpTroves", insertList, [
                "item", "version", "frozenVersion", "timestamps",
                "finalTimestamp",
                "branch", "label", "flavor", "flags", "instanceId",
                "troveType"])

        # process troveInfo and metadata...
        self.troveInfoTable.addInfo(cu, trv, troveInstanceId)

        if len(list(trv.iterRedirects())):
            # don't bother with any of this unless there actually are redirects
            schema.resetTable(cu, 'tmpNewRedirects')
            # now add the redirects
            for (name, branch, flavor) in trv.iterRedirects():
                if flavor is None:
                    frz = None
                else:
                    frz = flavor.freeze()
                cu.execute("INSERT INTO tmpNewRedirects (item, branch, flavor) "
                           "VALUES (?, ?, ?)", (name, str(branch), frz),
                           start_transaction=False)
            self.db.analyze("tmpNewRedirects")

            cu.execute("""
            INSERT INTO Items (item)
            SELECT tmpNewRedirects.item
            FROM tmpNewRedirects
            LEFT JOIN Items USING (item)
            WHERE Items.itemId is NULL
            """)

            cu.execute("""
            INSERT INTO Branches (branch)
            SELECT tmpNewRedirects.branch
            FROM tmpNewRedirects
            LEFT JOIN Branches USING (branch)
            WHERE Branches.branchId is NULL
            """)

            cu.execute("""
            INSERT INTO Flavors (flavor)
            SELECT tmpNewRedirects.flavor
            FROM tmpNewRedirects
            LEFT JOIN Flavors USING (flavor)
            WHERE
                Flavors.flavor is not NULL
                AND Flavors.flavorId is NULL
            """)

            cu.execute("""
            INSERT INTO TroveRedirects (instanceId, itemId, branchId, flavorId)
            SELECT %d, Items.itemId, Branches.branchId, Flavors.flavorId
            FROM tmpNewRedirects
            JOIN Items USING (item)
            JOIN Branches ON tmpNewRedirects.branch = Branches.branch
            LEFT JOIN Flavors ON tmpNewRedirects.flavor = Flavors.flavor
            """ % troveInstanceId)
dataset/ETHPy150Open sassoftware/conary/conary/repository/netrepos/trovestore.py/TroveStore.addTroveDone/swapped operands of `%`