Пример #1
0
    def test_non_cannonical_identifiers(self):
        with mocks.local.Svn(self.path), OutputCapture():
            self.assertEqual('2@trunk', str(local.Svn(self.path).commit(identifier='0@branch-a')))
            self.assertEqual('1@trunk', str(local.Svn(self.path).commit(identifier='-1@branch-a')))

            self.assertEqual('2@trunk', str(local.Svn(self.path).commit(identifier='0@branch-b')))
            self.assertEqual('1@trunk', str(local.Svn(self.path).commit(identifier='-1@branch-b')))
Пример #2
0
    def test_checkout_svn(self):
        with mocks.local.Git(), mocks.local.Svn(self.path), MockTime, OutputCapture():
            self.assertEqual(6, local.Svn(self.path).commit().revision)

            self.assertEqual(0, program.main(
                args=('checkout', '3@trunk'),
                path=self.path,
            ))

            self.assertEqual(4, local.Svn(self.path).commit().revision)
Пример #3
0
    def test_cache(self):
        try:
            dirname = tempfile.mkdtemp()
            with mocks.local.Svn(dirname) as mock_repo, OutputCapture():
                os.mkdir(os.path.join(dirname, '.svn'))
                self.assertEqual('4@trunk', str(local.Svn(dirname).commit()))

                mock_repo.connected = False
                commit = local.Svn(dirname).commit()
                self.assertEqual('4@trunk', str(commit))

                with self.assertRaises(local.Svn.Exception):
                    local.Svn(dirname).commit(revision=3)
        finally:
            shutil.rmtree(dirname)
Пример #4
0
    def from_path(cls, path, contributors=None):
        from webkitscmpy import local

        if local.Git.is_checkout(path):
            return local.Git(path, contributors=contributors)
        if local.Svn.is_checkout(path):
            return local.Svn(path, contributors=contributors)
        raise OSError("'{}' is not a known SCM type".format(path))
Пример #5
0
    def from_path(cls, path):
        from webkitscmpy import local

        if local.Git.is_checkout(path):
            return local.Git(path)
        if local.Svn.is_checkout(path):
            return local.Svn(path)
        raise OSError('{} is not a known SCM type')
Пример #6
0
 def test_identifier(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertEqual(1, local.Svn(self.path).commit(identifier='1@trunk').revision)
         self.assertEqual(2, local.Svn(self.path).commit(identifier='2@trunk').revision)
         self.assertEqual(3, local.Svn(self.path).commit(identifier='2.1@branch-a').revision)
         self.assertEqual(4, local.Svn(self.path).commit(identifier='3@trunk').revision)
         self.assertEqual(5, local.Svn(self.path).commit(identifier='2.2@branch-b').revision)
         self.assertEqual(6, local.Svn(self.path).commit(identifier='4@trunk').revision)
         self.assertEqual(7, local.Svn(self.path).commit(identifier='2.2@branch-a').revision)
         self.assertEqual(8, local.Svn(self.path).commit(identifier='2.3@branch-b').revision)
Пример #7
0
    def test_commit_revision(self):
        with mocks.local.Svn(self.path), OutputCapture():
            self.assertEqual('1@trunk', str(local.Svn(self.path).commit(revision=1)))
            self.assertEqual('2@trunk', str(local.Svn(self.path).commit(revision=2)))
            self.assertEqual('2.1@branch-a', str(local.Svn(self.path).commit(revision=3)))
            self.assertEqual('3@trunk', str(local.Svn(self.path).commit(revision=4)))
            self.assertEqual('2.2@branch-b', str(local.Svn(self.path).commit(revision=5)))
            self.assertEqual('4@trunk', str(local.Svn(self.path).commit(revision=6)))
            self.assertEqual('2.2@branch-a', str(local.Svn(self.path).commit(revision=7)))
            self.assertEqual('2.3@branch-b', str(local.Svn(self.path).commit(revision=8)))

            # Out-of-bounds commit
            with self.assertRaises(local.Svn.Exception):
                self.assertEqual(None, local.Svn(self.path).commit(revision=11))
Пример #8
0
 def test_commits_branch(self):
     with mocks.local.Svn(self.path), OutputCapture():
         svn = local.Svn(self.path)
         self.assertEqual(Commit.Encoder().default([
             svn.commit(revision='r7'),
             svn.commit(revision='r3'),
             svn.commit(revision='r2'),
             svn.commit(revision='r1'),
         ]), Commit.Encoder().default(list(svn.commits(begin=dict(argument='r1'), end=dict(argument='r7')))))
Пример #9
0
    def test_branches_priority(self):
        with mocks.local.Svn(self.path):
            self.assertEqual(
                'trunk',
                local.Svn(self.path).prioritize_branches(['trunk', 'branch-a', 'dev/12345', 'safari-610-branch', 'safari-610.1-branch'])
            )

            self.assertEqual(
                'safari-610-branch',
                local.Svn(self.path).prioritize_branches(['branch-a', 'dev/12345', 'safari-610-branch', 'safari-610.1-branch'])
            )

            self.assertEqual(
                'safari-610.1-branch',
                local.Svn(self.path).prioritize_branches(['branch-a', 'dev/12345', 'safari-610.1-branch'])
            )

            self.assertEqual(
                'branch-a',
                local.Svn(self.path).prioritize_branches(['branch-a', 'dev/12345'])
            )
Пример #10
0
    def test_checkout(self):
        with mocks.local.Svn(self.path), OutputCapture():
            repository = local.Svn(self.path)

            self.assertEqual(6, repository.commit().revision)
            self.assertEqual(5, repository.checkout('r5').revision)
            self.assertEqual(5, repository.commit().revision)

            self.assertEqual(4, repository.checkout('3@trunk').revision)
            self.assertEqual(4, repository.commit().revision)

            self.assertEqual(9, repository.checkout('tag-1').revision)
            self.assertEqual(9, repository.commit().revision)
Пример #11
0
 def test_info(self):
     with mocks.local.Svn(self.path):
         self.assertDictEqual(
             {
                 u'Path': u'.',
                 u'Working Copy Root Path': u'/mock/repository',
                 u'Repository Root': u'https://svn.mock.org/repository/repository',
                 u'URL': u'https://svn.mock.org/repository/repository/trunk',
                 u'Relative URL':  u'^/trunk',
                 u'Revision': u'6',
                 u'NodeKind': u'directory',
                 u'Schedule': u'normal',
                 u'Last Changed Author': u'*****@*****.**',
                 u'Last Changed Rev': u'6',
                 u'Last Changed Date': datetime.utcfromtimestamp(1601665100).strftime('%Y-%m-%d %H:%M:%S 0000 (%a, %d %b %Y)'),
             }, local.Svn(self.path).info(),
         )
Пример #12
0
    def test_no_network(self):
        with mocks.local.Svn(self.path) as mock_repo, OutputCapture():
            repo = local.Svn(self.path)
            self.assertEqual('4@trunk', str(repo.commit()))

            mock_repo.connected = False
            commit = repo.commit()
            self.assertEqual('4@trunk', str(commit))
            self.assertEqual(6, commit.revision)
            self.assertEqual(None, commit.message)

            commit = repo.commit(revision=4)
            self.assertEqual('3@trunk', str(commit))
            self.assertEqual(None, commit.message)

            with self.assertRaises(local.Svn.Exception):
                repo.commit(revision=3)

            mock_repo.connected = True
            self.assertEqual('2.1@branch-a', str(repo.commit(revision=3)))

            mock_repo.connected = False
            self.assertEqual('2.1@branch-a', str(repo.commit(revision=3)))
Пример #13
0
 def test_scm_type(self):
     with mocks.local.Svn(self.path):
         self.assertTrue(local.Svn(self.path).is_svn)
         self.assertFalse(local.Svn(self.path).is_git)
Пример #14
0
 def test_default_branch(self):
     with mocks.local.Svn(self.path):
         self.assertEqual(local.Svn(self.path).default_branch, 'trunk')
Пример #15
0
 def test_tags(self):
     with mocks.local.Svn(self.path):
         self.assertEqual(
             local.Svn(self.path).tags,
             ['tag-1', 'tag-2'],
         )
Пример #16
0
 def test_branches(self):
     with mocks.local.Svn(self.path):
         self.assertEqual(
             local.Svn(self.path).branches,
             ['trunk', 'branch-a', 'branch-b'],
         )
Пример #17
0
 def test_remote(self):
     with mocks.local.Svn(self.path) as repo:
         self.assertEqual(local.Svn(self.path).remote(), repo.remote)
Пример #18
0
    def test_root(self):
        with mocks.local.Svn(self.path):
            self.assertEqual(local.Svn(self.path).root_path, self.path)

            with self.assertRaises(OSError):
                local.Svn(os.path.dirname(self.path)).root_path
Пример #19
0
 def test_no_identifier(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertIsNone(local.Svn(self.path).find('trunk', include_identifier=False).identifier)
Пример #20
0
 def test_tag_previous(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertEqual(7, local.Svn(self.path).commit(identifier='2.2@tags/tag-1').revision)
Пример #21
0
 def test_tag(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertEqual(9, local.Svn(self.path).commit(tag='tag-1').revision)
Пример #22
0
 def test_alternative_default_branch(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertEqual(str(local.Svn(self.path).find('4@main')), '4@trunk')
         self.assertEqual(str(local.Svn(self.path).find('4@master')), '4@trunk')
Пример #23
0
 def test_no_log(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertIsNone(local.Svn(self.path).commit(identifier='4@trunk', include_log=False).message)
Пример #24
0
 def test_branches(self):
     with mocks.local.Svn(self.path, branches=('branch-1', 'branch-2')):
         self.assertEqual(
             local.Svn(self.path).branches,
             ['trunk', 'branch-1', 'branch-2'],
         )
Пример #25
0
 def test_commit_from_branch(self):
     with mocks.local.Svn(self.path), OutputCapture():
         self.assertEqual('4@trunk', str(local.Svn(self.path).commit(branch='trunk')))
         self.assertEqual('2.2@branch-a', str(local.Svn(self.path).commit(branch='branch-a')))
         self.assertEqual('2.3@branch-b', str(local.Svn(self.path).commit(branch='branch-b')))