def testCreateNewChangesetNotInSource(self):
        # Test creating a relative changeset when all we have in the
        # source is absolute changesets, and vice versa.
        r1 = self.addCollection('foo', '1', [':run'], createComps=True)
        self.addComponent('foo:run', '2', filePrimer=2)
        r2 = self.addCollection('foo', '2', [':run'])

        # create two absolute changesets, we want one relative one out
        absChg = [('foo', (None, None), (r1.getVersion(), r1.getFlavor()), True),
               ('foo', (None, None), (r2.getVersion(), r2.getFlavor()), True)]
        repos = self.openRepository()
        absCs = repos.createChangeSet(absChg, recurse=True)

        trvSrc = ChangesetFilesTroveSource(None)
        trvSrc.addChangeSet(absCs)

        relChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                         (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([relChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(not remainder)
        trvCs = newCs.iterNewTroveList().next()
        assert(trvCs.getNewVersion() == r2.getVersion())
        assert(trvCs.getOldVersion() == r1.getVersion())

        # now we'll try to get a relative changeset out when we don't 
        # have the new trove that we'd need to make the relative changeset 
        # work
        badChg = ('foo', (r1.getVersion(), r1.getFlavor()),
                      (r2.getVersion(), deps.parseFlavor('foo')), False)
        newCs, remainder = trvSrc.createChangeSet([badChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(remainder)
        assert(newCs.isEmpty())

        # now we'll try to get a relative changeset out when we don't 
        # have the _old_ trove that we'd need to make the relative changeset 
        # work
        badChg = ('foo', (r1.getVersion(), deps.parseFlavor('foo')),
                      (r2.getVersion(), r2.getFlavor()), False)
        newCs, remainder = trvSrc.createChangeSet([badChg], recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(remainder)
        assert(newCs.isEmpty())

        # Now test getting absolute changesets when the trovesource only has
        # relative ones.  This requires using the database to grab information
        # from the installed system about the old versions of troves.

        # First try creating those absolute changesets when there is
        # no information about the old trove on the system
        relCs = repos.createChangeSet([relChg], recurse=True)
        db = self.openDatabase()
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg, recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(len(remainder) == 2)
        assert(newCs.isEmpty())

        # now create them when the old trove has been installed.
        self.updatePkg(['foo=%s' % r1.getVersion()])
        # FIXME - we need to recreate the changeset files source here -
        # apparently some information pertaining to what is installed is
        # cached
        trvSrc = ChangesetFilesTroveSource(db)
        trvSrc.addChangeSet(relCs)
        newCs, remainder = trvSrc.createChangeSet(absChg, recurse=False,
                                       withFiles=False, withFileContents=False)
        assert(not remainder)
        assert(len(list(newCs.iterNewTroveList())) == 2)
dataset/ETHPy150Open sassoftware/conary/conary_test/repositorytest/trovesourcetest.py/ChangesetFilesTest.testCreateNewChangesetNotInSource/original