Ejemplo n.º 1
0
 def test_missingUserSitePackages(self):
     """
     L{BranchManager.getPaths} should return an iterable which does not
     have as an element the user-specific site-packages directory, if
     that directory does not exist.
     """
     home = self.mktemp()
     self.changeEnvironment('HOME', home)
     b = BranchManager()
     self.assertNotIn(self._perUserSitePackages(home), list(b.getPaths()))
Ejemplo n.º 2
0
 def test_missingUserSitePackages(self):
     """
     L{BranchManager.getPaths} should return an iterable which does not
     have as an element the user-specific site-packages directory, if
     that directory does not exist.
     """
     home = self.mktemp()
     self.changeEnvironment('HOME', home)
     b = BranchManager()
     self.assertNotIn(self._perUserSitePackages(home), list(b.getPaths()))
Ejemplo n.º 3
0
 def test_userSitePackages(self):
     """
     L{BranchManager.getPaths} should return an iterable which has as an
     element the user-specific site-packages directory, if that directory
     exists.
     """
     home = self.mktemp()
     sitePackages = self._perUserSitePackages(home)
     os.makedirs(sitePackages)
     self.changeEnvironment('HOME', home)
     b = BranchManager()
     self.assertIn(sitePackages, list(b.getPaths()))
Ejemplo n.º 4
0
 def setUp(self):
     """
     Create a branch manager with temporary directories for all its working
     filesystem paths.
     """
     self.paths = self.mktemp()
     self.projects = self.mktemp()
     os.makedirs(self.paths)
     os.makedirs(self.projects)
     self.manager = BranchManager(self.paths, self.projects)
     self.cwd = os.getcwd()
     self.repositories = FilePath(self.mktemp())
Ejemplo n.º 5
0
 def test_userSitePackages(self):
     """
     L{BranchManager.getPaths} should return an iterable which has as an
     element the user-specific site-packages directory, if that directory
     exists.
     """
     home = self.mktemp()
     sitePackages = self._perUserSitePackages(home)
     os.makedirs(sitePackages)
     self.changeEnvironment('HOME', home)
     b = BranchManager()
     self.assertIn(sitePackages, list(b.getPaths()))
Ejemplo n.º 6
0
 def test_projectsEnvironment(self):
     """
     Verify that BranchManager draws from the environment for the projects
     path.
     """
     self.changeEnvironment("COMBINATOR_PROJECTS", "somedir")
     b = BranchManager()
     self.assertEqual(b.svnProjectsDir, os.path.abspath("somedir"))
Ejemplo n.º 7
0
 def test_creation(self):
     """
     Verify that a newly-created branch manager can locate the paths it
     needs to do things.
     """
     b = BranchManager()
     self.assertNotEqual(b.svnProjectsDir, None)
     self.assertNotEqual(b.sitePathsPath, None)
     self.assertNotEqual(b.binCachePath, None)
Ejemplo n.º 8
0
 def test_pathsEnvironment(self):
     """
     Verify that BranchManager draws from the environment for the paths
     path.
     """
     self.changeEnvironment("COMBINATOR_PATHS", "pathdir")
     b = BranchManager()
     self.assertEqual(b.sitePathsPath, os.path.abspath("pathdir"))
     self.assertEqual(b.binCachePath, "pathdir/bincache")
Ejemplo n.º 9
0
 def setUp(self):
     """
     Create a branch manager with temporary directories for all its working
     filesystem paths.
     """
     self.paths = self.mktemp()
     self.projects = self.mktemp()
     os.makedirs(self.paths)
     os.makedirs(self.projects)
     self.manager = BranchManager(self.paths, self.projects)
     self.cwd = os.getcwd()
     self.repositories = FilePath(self.mktemp())
Ejemplo n.º 10
0
class BranchManagerChangeBranchTests(TestCase, ChangeBranchTestsMixin):
    """
    Tests for L{BranchManager.changeProjectBranch}.
    """
    projectName = 'Quux'

    def setUp(self):
        """
        Create a branch manager with temporary directories for all its working
        filesystem paths.
        """
        self.paths = self.mktemp()
        self.projects = self.mktemp()
        os.makedirs(self.paths)
        os.makedirs(self.projects)
        self.manager = BranchManager(self.paths, self.projects)
        self.cwd = os.getcwd()
        self.repositories = FilePath(self.mktemp())


    def tearDown(self):
        """
        Assert that the working directory has been restored to its original
        value if it was changed.
        """
        try:
            self.assertEqual(self.cwd, os.getcwd())
        finally:
            os.chdir(self.cwd)


    def createRepository(self, projectName, contents):
        """
        Create a new SVN repository with the given contents and associate it
        with given project.
        """
        path = self.repositories.child(projectName)
        path.makedirs()
        createSubversionRepository(path, contents)


    def uri(self, projectName, *branch):
        """
        Return a I{file} URI for the given branch of the given project.
        """
        return _uri(self.repositories.child(projectName), *branch)


    def checkTrunkCheckout(self, project):
        """
        Assert that a trunk checkout of the given project exists.
        """
        trunkWorkingCopy = FilePath(self.paths).child(project).child('trunk')
        self.assertTrue(
            trunkWorkingCopy.exists(),
            "%r did not exist." % (trunkWorkingCopy.path,))


    def makeRepositoryInaccessible(self, projectName):
        """
        Make the repository inaccessible so checks for the existence of
        branches can't possibly succeed.
        """
        self.repositories.child(projectName).remove()


    def modifyTrunk(self, projectName, fname, newData):
        """
        Make a change to a file in trunk.
        """
        trunkpath = FilePath(self.paths).child(projectName).child('trunk')
        f = trunkpath.child(fname).open('w')
        f.write(newData)
        f.close()


    def commitTrunk(self, projectName):
        """
        Commit the trunk working copy for the given project.
        """
        commit(
            FilePath(self.paths).child(projectName).child('trunk'),
            'Commit some changes')


    def modifyBranch(self, projectName, branchName, fname, newData):
        """
        Make a change to a file in a branch.
        """
        fObj = FilePath(self.paths).child(projectName).child(
            'branches').child(branchName).child(fname).open('w')
        fObj.write(newData)
        fObj.close()


    def commitBranch(self, projectName, branchName):
        """
        Commit a branch working for the given project.
        """
        commit(
            FilePath(self.paths).child(projectName).child(
                'branches').child(branchName),
            'Commit some changes')


    def test_mergeConflict(self):
        """
        L{BranchManager.mergeProjectBranch} performs merges
        non-interactively so that they complete even if there is a merge
        conflict.
        """
        projectName = "Quux"
        branchName = 'baz'
        fname = 'foo.txt'
        contents = {fname: 'some data'}
        self.createRepository(projectName, {"trunk": contents,
                                            "branches": {}})

        self.manager.changeProjectBranch(
            projectName, 'trunk', self.uri(projectName, 'trunk'))
        self.manager.newProjectBranch(projectName, branchName)
        self.modifyTrunk(projectName, fname, 'changed data')
        self.commitTrunk(projectName)
        self.modifyBranch(
            projectName, branchName, fname, 'differently changed data')
        self.commitBranch(projectName, branchName)

        self.manager.mergeProjectBranch(projectName)


    def test_changeCurrentBranchDeletesUnknown(self):
        """
        If L{BranchManager.changeProjectBranch} creates a new working copy, it
        doesn't contain extra unversioned files from the I{trunk} working copy.
        """
        projectName = 'Quux'
        branchName = 'foo'

        self.createRepository(
            projectName, {'trunk': {},
                          'branches':
                              {branchName: {}}})

        # Get a trunk checkout
        self.manager.changeProjectBranch(
            projectName, 'trunk', self.uri(projectName, 'trunk'))

        # Here is some unversioned junk in the trunk working copy
        self.modifyTrunk(projectName, "junk", "garbage")

        self.manager.changeProjectBranch(projectName, branchName)

        junk = FilePath(self.paths).descendant([
                projectName, "branches", branchName, "junk"])
        self.assertFalse(junk.exists())
Ejemplo n.º 11
0
class BranchManagerChangeBranchTests(TestCase, ChangeBranchTestsMixin):
    """
    Tests for L{BranchManager.changeProjectBranch}.
    """
    projectName = 'Quux'

    def setUp(self):
        """
        Create a branch manager with temporary directories for all its working
        filesystem paths.
        """
        self.paths = self.mktemp()
        self.projects = self.mktemp()
        os.makedirs(self.paths)
        os.makedirs(self.projects)
        self.manager = BranchManager(self.paths, self.projects)
        self.cwd = os.getcwd()
        self.repositories = FilePath(self.mktemp())

    def tearDown(self):
        """
        Assert that the working directory has been restored to its original
        value if it was changed.
        """
        try:
            self.assertEqual(self.cwd, os.getcwd())
        finally:
            os.chdir(self.cwd)

    def createRepository(self, projectName, contents):
        """
        Create a new SVN repository with the given contents and associate it
        with given project.
        """
        path = self.repositories.child(projectName)
        path.makedirs()
        createSubversionRepository(path, contents)

    def uri(self, projectName, *branch):
        """
        Return a I{file} URI for the given branch of the given project.
        """
        return _uri(self.repositories.child(projectName), *branch)

    def checkTrunkCheckout(self, project):
        """
        Assert that a trunk checkout of the given project exists.
        """
        trunkWorkingCopy = FilePath(self.paths).child(project).child('trunk')
        self.assertTrue(trunkWorkingCopy.exists(),
                        "%r did not exist." % (trunkWorkingCopy.path, ))

    def makeRepositoryInaccessible(self, projectName):
        """
        Make the repository inaccessible so checks for the existence of
        branches can't possibly succeed.
        """
        self.repositories.child(projectName).remove()

    def modifyTrunk(self, projectName, fname, newData):
        """
        Make a change to a file in trunk.
        """
        trunkpath = FilePath(self.paths).child(projectName).child('trunk')
        f = trunkpath.child(fname).open('w')
        f.write(newData)
        f.close()

    def commitTrunk(self, projectName):
        """
        Commit the trunk working copy for the given project.
        """
        commit(
            FilePath(self.paths).child(projectName).child('trunk'),
            'Commit some changes')

    def modifyBranch(self, projectName, branchName, fname, newData):
        """
        Make a change to a file in a branch.
        """
        fObj = FilePath(self.paths).child(projectName).child('branches').child(
            branchName).child(fname).open('w')
        fObj.write(newData)
        fObj.close()

    def commitBranch(self, projectName, branchName):
        """
        Commit a branch working for the given project.
        """
        commit(
            FilePath(self.paths).child(projectName).child('branches').child(
                branchName), 'Commit some changes')

    def test_mergeConflict(self):
        """
        L{BranchManager.mergeProjectBranch} performs merges
        non-interactively so that they complete even if there is a merge
        conflict.
        """
        projectName = "Quux"
        branchName = 'baz'
        fname = 'foo.txt'
        contents = {fname: 'some data'}
        self.createRepository(projectName, {"trunk": contents, "branches": {}})

        self.manager.changeProjectBranch(projectName, 'trunk',
                                         self.uri(projectName, 'trunk'))
        self.manager.newProjectBranch(projectName, branchName)
        self.modifyTrunk(projectName, fname, 'changed data')
        self.commitTrunk(projectName)
        self.modifyBranch(projectName, branchName, fname,
                          'differently changed data')
        self.commitBranch(projectName, branchName)

        self.manager.mergeProjectBranch(projectName)