Exemplo n.º 1
0
    def test_02_helper_command_and_some_simple_paths(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)

        dot()
        evnadmin = repo.evnadmin
        verify = evnadmin.verify_path_matches_file_size_exclusion_regex
        verify(repo.path, path='/trunk/foo.txt')

        dot()
        path = '/trunk/foo.csv'
        error_fmt = "path '%s' does not match regex '%s'"
        error = error_fmt % (path, pattern)
        with ensure_fails(self, error):
            verify(repo.path, path=path)

        dot()
        pattern = '\.(txt|csv)$'
        conf.set_max_file_size_exclusion_regex(pattern)
        verify(repo.path, path=path)

        dot()
        path = '/trunk/test.log'
        error = error_fmt % (path, pattern)
        with ensure_fails(self, error):
            verify(repo.path, path=path)
Exemplo n.º 2
0
    def test_02_helper_command_and_some_simple_paths(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)

        dot()
        evnadmin = repo.evnadmin
        verify = evnadmin.verify_path_matches_file_size_exclusion_regex
        verify(repo.path, path='/trunk/foo.txt')

        dot()
        path = '/trunk/foo.csv'
        error_fmt = "path '%s' does not match regex '%s'"
        error = error_fmt % (path, pattern)
        with ensure_fails(self, error):
            verify(repo.path, path=path)

        dot()
        pattern = '\.(txt|csv)$'
        conf.set_max_file_size_exclusion_regex(pattern)
        verify(repo.path, path=path)

        dot()
        path = '/trunk/test.log'
        error = error_fmt % (path, pattern)
        with ensure_fails(self, error):
            verify(repo.path, path=path)
Exemplo n.º 3
0
    def test_04_existing_file_modified_over_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn
        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {'512-then-1025-bytes.txt': bulk_chargen(512)}
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/512-then-1025-bytes.txt')
            svn.ci('trunk', m='Permitted...')

        dot()
        tree = {'512-then-1025-bytes.txt': bulk_chargen(1025)}
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.ci('trunk', m='Permitted...')
Exemplo n.º 4
0
    def test_04_existing_file_modified_over_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn
        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = { '512-then-1025-bytes.txt': bulk_chargen(512) }
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/512-then-1025-bytes.txt')
            svn.ci('trunk', m='Permitted...')

        dot()
        tree = { '512-then-1025-bytes.txt': bulk_chargen(1025) }
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.ci('trunk', m='Permitted...')
Exemplo n.º 5
0
    def test_01_under_then_over(self):
        repo = self.create_repo()
        conf = repo.conf

        dot()
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn
        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {'512-then-1025-bytes.txt': bulk_chargen(512)}
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/512-then-1025-bytes.txt')
            svn.ci('trunk', m='Permitted...')

        dot()
        tree = {'512-then-1025-bytes.txt': bulk_chargen(1025)}
        repo.build(tree, prefix='trunk')

        error = format_file_exceeds_max_size_error(1025, 1024)
        with chdir(repo.wc):
            dot()
            with ensure_blocked(self, error):
                svn.ci('trunk', m='At limit')
Exemplo n.º 6
0
    def test_04_rm_standard_layout(self):
        """
        Given:
            /trunk/
            /tags/
            /branches/
        Make sure we can't rmdir any of the paths.
        """
        repo = self.create_repo()
        svn = repo.svn

        expected = conf.standard_layout
        raw = svn.ls(repo.uri)
        actual = frozenset(format_dir(l) for l in raw.splitlines())
        self.assertEqual(expected, actual)
        dot()

        error = e.TopLevelRepoDirectoryRemoved
        paths = [p.replace('/', '') for p in conf.standard_layout]
        with chdir(repo.wc):
            for path in paths:
                dot()
                svn.rm(path)
                with ensure_blocked(self, error):
                    svn.ci(path)
Exemplo n.º 7
0
    def test_01_under_then_over(self):
        repo = self.create_repo()
        conf = repo.conf

        dot()
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn
        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = { '512-then-1025-bytes.txt': bulk_chargen(512) }
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/512-then-1025-bytes.txt')
            svn.ci('trunk', m='Permitted...')

        dot()
        tree = { '512-then-1025-bytes.txt': bulk_chargen(1025) }
        repo.build(tree, prefix='trunk')

        error = format_file_exceeds_max_size_error(1025, 1024)
        with chdir(repo.wc):
            dot()
            with ensure_blocked(self, error):
                svn.ci('trunk', m='At limit')
    def test_04_rm_standard_layout(self):
        """
        Given:
            /trunk/
            /tags/
            /branches/
        Make sure we can't rmdir any of the paths.
        """
        repo = self.create_repo()
        svn = repo.svn

        expected = conf.standard_layout
        raw = svn.ls(repo.uri)
        actual = frozenset(format_dir(l) for l in raw.splitlines())
        self.assertEqual(expected, actual)
        dot()

        error = e.TopLevelRepoDirectoryRemoved
        paths = [ p.replace('/', '') for p in conf.standard_layout ]
        with chdir(repo.wc):
            for path in paths:
                dot()
                svn.rm(path)
                with ensure_blocked(self, error):
                    svn.ci(path)
Exemplo n.º 9
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Disable so we can mkdir ^/other
        dot()
        evnadmin.disable(repo.path)
        svn.mkdir(repo.ra('/other/'), m='Creating other directory')
        evnadmin.add_root_exclusion(
            repo.name,
            root_exclusion='/[abcdo]{1,1}the.*',
        )

        dot()
        evnadmin.enable(repo.path)
        svn.cp(repo.ra('/trunk/'), repo.ra('/branches/1.x/'), m='Branching')
        svn.cp(repo.ra('/branches/1.x/'), repo.ra('/tags/1.0/'), m='Tagging')

        # Lazy (quick) test of roots.
        dot()
        expected_roots = set(('/trunk/', '/branches/1.x/', '/tags/1.0/'))
        actual_roots = set(repo.roots.keys())
        self.assertEqual(expected_roots, actual_roots)

        # Add ourselves as a repo admin so that we can force through the next
        # commit.
        dot()
        evnadmin.add_repo_admin(repo.name, username=svn.username)
        expected = 'yes'
        actual = evnadmin.is_repo_admin(repo.name, username=svn.username)
        self.assertEqual(expected, actual)

        dot()
        with chdir(repo.wc):
            svn.up()
            svn.mv('trunk', 'other/foobar')
            svn.mv('branches/1.x', 'other/1.x')
            svn.mv('tags/1.0', 'other/1.0')
            svn.ci(m='IGNORE ERRORS')

        evn_props_r5_expected = {
            'errors': {
                '/other/1.0/': [
                    'tag renamed',
                    'known root path renamed to unknown path',
                ],
                '/other/1.x/': [
                    'known root path renamed to unknown path',
                    'branch renamed to unknown',
                ],
                '/other/foobar/': [
                    'known root path renamed to unknown path',
                    'trunk renamed to unknown path',
                ],
            },
            'roots': { }
        }
        self.assertEqual(repo.revprops_at(5)['evn'], evn_props_r5_expected)
Exemplo n.º 10
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Disable so we can mkdir ^/other
        dot()
        evnadmin.disable(repo.path)
        svn.mkdir(repo.ra('/other/'), m='Creating other directory')
        evnadmin.add_root_exclusion(
            repo.name,
            root_exclusion='/[abcdo]{1,1}the.*',
        )

        dot()
        evnadmin.enable(repo.path)
        svn.cp(repo.ra('/trunk/'), repo.ra('/branches/1.x/'), m='Branching')
        svn.cp(repo.ra('/branches/1.x/'), repo.ra('/tags/1.0/'), m='Tagging')

        # Lazy (quick) test of roots.
        dot()
        expected_roots = set(('/trunk/', '/branches/1.x/', '/tags/1.0/'))
        actual_roots = set(repo.roots.keys())
        self.assertEqual(expected_roots, actual_roots)

        # Add ourselves as a repo admin so that we can force through the next
        # commit.
        dot()
        evnadmin.add_repo_admin(repo.name, username=svn.username)
        expected = 'yes'
        actual = evnadmin.is_repo_admin(repo.name, username=svn.username)
        self.assertEqual(expected, actual)

        dot()
        with chdir(repo.wc):
            svn.up()
            svn.mv('trunk', 'other/foobar')
            svn.mv('branches/1.x', 'other/1.x')
            svn.mv('tags/1.0', 'other/1.0')
            svn.ci(m='IGNORE ERRORS')

        evn_props_r5_expected = {
            'errors': {
                '/other/1.0/': [
                    'tag renamed',
                    'known root path renamed to unknown path',
                ],
                '/other/1.x/': [
                    'known root path renamed to unknown path',
                    'branch renamed to unknown',
                ],
                '/other/foobar/': [
                    'known root path renamed to unknown path',
                    'trunk renamed to unknown path',
                ],
            },
            'roots': {}
        }
        self.assertEqual(repo.revprops_at(5)['evn'], evn_props_r5_expected)
    def test_02_ra_when_enabled(self):
        repo = self.create_repo(checkout=False)
        conf = repo.conf
        svn = repo.svn

        dot()
        error = KnownRootPathCopiedToKnownRootSubtreePath
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('trunk/foo'), m='Copy')
Exemplo n.º 12
0
    def test_02_ra_when_enabled(self):
        repo = self.create_repo(checkout=False)
        conf = repo.conf
        svn = repo.svn

        dot()
        error = KnownRootPathCopiedToKnownRootSubtreePath
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('trunk/foo'), m='Copy')
Exemplo n.º 13
0
    def test_01_conf_setting(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)

        actual = conf.get('main', 'max-file-size-exclusion-regex')
        self.assertEqual(pattern, actual)
Exemplo n.º 14
0
    def test_01_conf_setting(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.txt$'

        dot()
        conf.set_max_file_size_exclusion_regex(pattern)

        actual = conf.get('main', 'max-file-size-exclusion-regex')
        self.assertEqual(pattern, actual)
    def test_01_conf_setting(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.(dll|exe|jar)$'

        dot()
        conf.set_blocked_file_extensions_regex(pattern)

        actual = conf.get('main', 'blocked-file-extensions-regex')
        self.assertEqual(pattern, actual)
Exemplo n.º 16
0
    def test_01_conf_setting(self):
        repo = self.create_repo()
        conf = repo.conf
        pattern = '\.(dll|exe|jar)$'

        dot()
        conf.set_blocked_file_extensions_regex(pattern)

        actual = conf.get('main', 'blocked-file-extensions-regex')
        self.assertEqual(pattern, actual)
Exemplo n.º 17
0
    def test_02_evn_enabled(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Make sure the roots on r1 are as we expect.
        dot()
        roots_r1_expected = {
            '/trunk/': {
                'copies': {},
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(repo.roots, roots_r1_expected)

        # Copy the path.
        dot()
        svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Copy')

        # Try copy it again; ensure it's blocked.
        dot()
        error = KnownRootPathCopiedToKnownRootSubtreePath
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Copy again')

        # Check roots.
        dot()
        roots_r1_expected = {
            '/trunk/': {
                'copies': {
                    1: [('/tags/1.0/', 2)]
                },
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(repo.roots_at(1), roots_r1_expected)

        dot()
        roots_r2_expected = {
            '/tags/1.0/': {
                'copied_from': ('/trunk/', 1),
                'copies': {},
                'created': 2,
                'creation_method': 'copied',
                'errors': [],
            },
            '/trunk/': {
                'created': 1
            },
        }
        roots_r2 = repo.roots_at(2)
        self.assertEqual(roots_r2, roots_r2_expected)
Exemplo n.º 18
0
    def test_02_ra(self):
        repo = self.create_repo(checkout=False)
        svn = repo.svn

        dot()
        svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Tagging 1.0')

        error = KnownRootPathCopiedToKnownRootSubtreePath
        dot()
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Tagging 1.0')
    def test_02_ra(self):
        repo = self.create_repo(checkout=False)
        svn = repo.svn

        dot()
        svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Tagging 1.0')

        error = KnownRootPathCopiedToKnownRootSubtreePath
        dot()
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Tagging 1.0')
    def test_02_evn_enabled(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Make sure the roots on r1 are as we expect.
        dot()
        roots_r1_expected = {
            '/trunk/': {
                'copies': {},
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(repo.roots, roots_r1_expected)

        # Copy the path.
        dot()
        svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Copy')

        # Try copy it again; ensure it's blocked.
        dot()
        error = KnownRootPathCopiedToKnownRootSubtreePath
        with ensure_blocked(self, error):
            svn.copy(repo.ra('trunk'), repo.ra('tags/1.0'), m='Copy again')

        # Check roots.
        dot()
        roots_r1_expected = {
            '/trunk/': {
                'copies': {
                    1: [('/tags/1.0/', 2)]
                },
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(repo.roots_at(1), roots_r1_expected)

        dot()
        roots_r2_expected = {
            '/tags/1.0/': {
                'copied_from': ('/trunk/', 1),
                'copies': {},
                'created': 2,
                'creation_method': 'copied',
                'errors': [],
            },
            '/trunk/': { 'created': 1 },
        }
        roots_r2 = repo.roots_at(2)
        self.assertEqual(roots_r2, roots_r2_expected)
Exemplo n.º 21
0
    def test_01_wc_when_enabled(self):
        # This appears to be blocked by svn.exe with an error message along
        # the lines of:
        #   Cannot copy path '/trunk' into its own child '/trunk/foo'
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        error = 'Cannot copy path'
        dot()
        with chdir(repo.wc):
            with ensure_blocked(self, error):
                svn.copy('trunk', 'trunk/foo')
                svn.ci('trunk', m='Copy trunk')
Exemplo n.º 22
0
def make_std_layout(repo, components=None):
    conf = repo.conf
    svn = repo.svn
    if not components:
        components = ('foo', 'bar')
    paths = [p.replace('/', '') for p in conf.standard_layout]
    with chdir(repo.wc):
        for component in components:
            svn.mkdir(component)
            for path in paths:
                dot()
                target = '/'.join((component, path))
                svn.mkdir(target)
            svn.ci(component)
def make_std_layout(repo, components=None):
    conf = repo.conf
    svn = repo.svn
    if not components:
        components = ('foo', 'bar')
    paths = [ p.replace('/', '') for p in conf.standard_layout ]
    with chdir(repo.wc):
        for component in components:
            svn.mkdir(component)
            for path in paths:
                dot()
                target = '/'.join((component, path))
                svn.mkdir(target)
            svn.ci(component)
    def test_01_wc_when_enabled(self):
        # This appears to be blocked by svn.exe with an error message along
        # the lines of:
        #   Cannot copy path '/trunk' into its own child '/trunk/foo'
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        error = 'Cannot copy path'
        dot()
        with chdir(repo.wc):
            with ensure_blocked(self, error):
                svn.copy('trunk', 'trunk/foo')
                svn.ci('trunk', m='Copy trunk')
Exemplo n.º 25
0
    def test_01_wc(self):
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        dot()
        with chdir(repo.wc):
            svn.copy('trunk', 'tags/1.0')
            svn.ci('tags', m='Tag trunk')

        error = 'known root path copied to known root subtree path'
        with chdir(repo.wc):
            with ensure_blocked(self, error):
                svn.copy('trunk', 'tags/1.0')
                svn.ci('tags/1.0', m='Incorrect copy')
    def test_01_wc(self):
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        dot()
        with chdir(repo.wc):
            svn.copy('trunk', 'tags/1.0')
            svn.ci('tags', m='Tag trunk')

        error = 'known root path copied to known root subtree path'
        with chdir(repo.wc):
            with ensure_blocked(self, error):
                svn.copy('trunk', 'tags/1.0')
                svn.ci('tags/1.0', m='Incorrect copy')
Exemplo n.º 27
0
    def test_03_component_standard_layout_allowed(self):
        """
        Ensure top-level standard layout directories can be created if they're
        housed under a component.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        paths = [p.replace('/', '') for p in conf.standard_layout]
        with chdir(repo.wc):
            for component in ('foo', 'bar'):
                svn.mkdir(component)
                for path in paths:
                    dot()
                    target = '/'.join((component, path))
                    svn.mkdir(target)
                svn.ci(component)
    def test_03_no_svnmucc__commit_together(self):
        """
        Create an empty repo via `evnadmin create --no-svnmucc`, then issue
        three mkdirs followed by a single commit for:
            /trunk/
            /tags/
            /branches/
        """
        repo = self.create_repo(no_svnmucc=True)
        svn = repo.svn

        with chdir(repo.wc):
            for d in conf.standard_layout:
                # Lop-off the leading '/'.
                svn.mkdir(d[1:])
            svn.ci()
            dot()
Exemplo n.º 29
0
    def test_03_no_svnmucc__commit_together(self):
        """
        Create an empty repo via `evnadmin create --no-svnmucc`, then issue
        three mkdirs followed by a single commit for:
            /trunk/
            /tags/
            /branches/
        """
        repo = self.create_repo(no_svnmucc=True)
        svn = repo.svn

        with chdir(repo.wc):
            for d in conf.standard_layout:
                # Lop-off the leading '/'.
                svn.mkdir(d[1:])
            svn.ci()
            dot()
    def test_03_component_standard_layout_allowed(self):
        """
        Ensure top-level standard layout directories can be created if they're
        housed under a component.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        paths = [ p.replace('/', '') for p in conf.standard_layout ]
        with chdir(repo.wc):
            for component in ('foo', 'bar'):
                svn.mkdir(component)
                for path in paths:
                    dot()
                    target = '/'.join((component, path))
                    svn.mkdir(target)
                svn.ci(component)
Exemplo n.º 31
0
    def test_02_standard_layout_blocked(self):
        """
        Ensure top-level standard layout directories can't be created.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        actual = svn.ls(repo.uri)
        self.assertEqual('', actual)

        error = e.StandardLayoutTopLevelDirectoryCreatedInMultiComponentRepo
        paths = [p.replace('/', '') for p in conf.standard_layout]
        with chdir(repo.wc):
            for path in paths:
                dot()
                svn.mkdir(path)
                with ensure_blocked(self, error):
                    svn.ci(path)
    def test_02_standard_layout_blocked(self):
        """
        Ensure top-level standard layout directories can't be created.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        actual = svn.ls(repo.uri)
        self.assertEqual('', actual)

        error = e.StandardLayoutTopLevelDirectoryCreatedInMultiComponentRepo
        paths = [ p.replace('/', '') for p in conf.standard_layout ]
        with chdir(repo.wc):
            for path in paths:
                dot()
                svn.mkdir(path)
                with ensure_blocked(self, error):
                    svn.ci(path)
Exemplo n.º 33
0
    def test_04_block_two_deep_non_standard_dirs(self):
        """
        Prevent any two-level deep directories from being created if they're
        not a standard directory.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        error = e.InvalidTopLevelRepoComponentDirectoryCreated
        paths = [p.replace('/', '') for p in conf.standard_layout]
        with chdir(repo.wc):
            dot()
            svn.mkdir('foo')
            svn.ci()

            dot()
            svn.mkdir('foo/bar')
            with ensure_blocked(self, error):
                svn.ci()
    def test_04_verify(self):
        repo = self.create_repo()
        evnadmin = repo.evnadmin
        verify = evnadmin.verify_path_matches_blocked_file_extensions_regex

        dot()
        verify(repo.path, path='/trunk/foo.dll')

        dot()
        verify(repo.path, path='FOO.DLL')

        dot()
        verify(repo.path, path='tomcat.exe')

        dot()
        verify(repo.path, path='hornet.jAr')

        dot()
        verify(repo.path, path='/abcd/efg/viper.EXE')
Exemplo n.º 35
0
    def test_04_verify(self):
        repo = self.create_repo()
        evnadmin = repo.evnadmin
        verify = evnadmin.verify_path_matches_blocked_file_extensions_regex

        dot()
        verify(repo.path, path='/trunk/foo.dll')

        dot()
        verify(repo.path, path='FOO.DLL')

        dot()
        verify(repo.path, path='tomcat.exe')

        dot()
        verify(repo.path, path='hornet.jAr')

        dot()
        verify(repo.path, path='/abcd/efg/viper.EXE')
    def test_04_block_two_deep_non_standard_dirs(self):
        """
        Prevent any two-level deep directories from being created if they're
        not a standard directory.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        error = e.InvalidTopLevelRepoComponentDirectoryCreated
        paths = [ p.replace('/', '') for p in conf.standard_layout ]
        with chdir(repo.wc):
            dot()
            svn.mkdir('foo')
            svn.ci()

            dot()
            svn.mkdir('foo/bar')
            with ensure_blocked(self, error):
                svn.ci()
    def test_02_add_new(self):
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {
            'test.dll': bulk_chargen(100),
        }
        repo.build(tree, prefix='trunk')

        error = e.BlockedFileExtension
        with chdir(repo.wc):
            dot()
            svn.add('trunk/test.dll')
            with ensure_blocked(self, error):
                svn.ci('trunk/test.dll', m='Adding test.dll...')
Exemplo n.º 38
0
    def test_02_add_new(self):
        repo = self.create_repo()
        conf = repo.conf
        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {
            'test.dll': bulk_chargen(100),
        }
        repo.build(tree, prefix='trunk')

        error = e.BlockedFileExtension
        with chdir(repo.wc):
            dot()
            svn.add('trunk/test.dll')
            with ensure_blocked(self, error):
                svn.ci('trunk/test.dll', m='Adding test.dll...')
    def test_02_no_svnmucc__commit_individually(self):
        """
        Create an empty repo via `evnadmin create --no-svnmucc`, then issue
        three individual mkdirs then commits for:
            /trunk/
            /tags/
            /branches/
        """
        repo = self.create_repo(no_svnmucc=True)
        svn = repo.svn

        actual = svn.ls(repo.uri)
        self.assertEqual('', actual)
        dot()

        for d in conf.standard_layout:
            with chdir(repo.wc):
                # Lop-off the leading '/'.
                svn.mkdir(d[1:])
                svn.ci()
                dot()
Exemplo n.º 40
0
    def test_02_no_svnmucc__commit_individually(self):
        """
        Create an empty repo via `evnadmin create --no-svnmucc`, then issue
        three individual mkdirs then commits for:
            /trunk/
            /tags/
            /branches/
        """
        repo = self.create_repo(no_svnmucc=True)
        svn = repo.svn

        actual = svn.ls(repo.uri)
        self.assertEqual('', actual)
        dot()

        for d in conf.standard_layout:
            with chdir(repo.wc):
                # Lop-off the leading '/'.
                svn.mkdir(d[1:])
                svn.ci()
                dot()
Exemplo n.º 41
0
    def test_01_over_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        over = 1025
        tree = { 'over.txt': bulk_chargen(over) }
        repo.build(tree, prefix='trunk')

        error = format_file_exceeds_max_size_error(over, 1024)
        with chdir(repo.wc):
            dot()
            svn.add('trunk/over.txt')
            with ensure_blocked(self, error):
                svn.ci('trunk', m='Over limit')
Exemplo n.º 42
0
    def test_01_over_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        over = 1025
        tree = {'over.txt': bulk_chargen(over)}
        repo.build(tree, prefix='trunk')

        error = format_file_exceeds_max_size_error(over, 1024)
        with chdir(repo.wc):
            dot()
            svn.add('trunk/over.txt')
            with ensure_blocked(self, error):
                svn.ci('trunk', m='Over limit')
Exemplo n.º 43
0
    def test_01_tag_and_branch_creation_detection(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set_custom_hook_classname(self.classname)
        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        error = 'is_branch_create: /branches/1.x/'
        with chdir(repo.wc):
            svn.cp('trunk', 'branches/1.x')
            with ensure_blocked(self, error):
                svn.ci('branches/1.x', m='Branching...')

        dot()
        error = 'is_tag_create: /tags/1.1/'
        with chdir(repo.wc):
            svn.cp('trunk', 'tags/1.1')
            with ensure_blocked(self, error):
                svn.ci('tags/1.1', m='Tagging...')
Exemplo n.º 44
0
    def test_01_basic(self):
        """
        Given:
            /trunk/
            /tags/
            /branches/
        Make sure we can't create:
            /bar/
        """
        repo = self.create_repo()
        svn = repo.svn

        expected = conf.standard_layout
        raw = svn.ls(repo.uri)
        actual = frozenset(format_dir(l) for l in raw.splitlines())
        self.assertEqual(expected, actual)
        dot()

        expected = e.InvalidTopLevelRepoDirectoryCreated
        with chdir(repo.wc):
            svn.mkdir('bar')
            with ensure_blocked(self, expected):
                svn.ci()
                dot()
    def test_01_basic(self):
        """
        Given:
            /trunk/
            /tags/
            /branches/
        Make sure we can't create:
            /bar/
        """
        repo = self.create_repo()
        svn = repo.svn

        expected = conf.standard_layout
        raw = svn.ls(repo.uri)
        actual = frozenset(format_dir(l) for l in raw.splitlines())
        self.assertEqual(expected, actual)
        dot()

        expected = e.InvalidTopLevelRepoDirectoryCreated
        with chdir(repo.wc):
            svn.mkdir('bar')
            with ensure_blocked(self, expected):
                svn.ci()
                dot()
Exemplo n.º 46
0
    def test_05_block_n_deep_non_standard_dirs(self):
        """
        Prevent any > two-level deep directories from being created if they're
        not a standard directory.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        error = e.InvalidTopLevelRepoComponentDirectoryCreated
        paths = [p.replace('/', '') for p in conf.standard_layout]
        with chdir(repo.wc):
            dot()
            svn.mkdir('foo')
            svn.ci()

            dot()
            svn.mkdir('foo/bar')
            svn.mkdir('foo/bar/tmp')
            with ensure_blocked(self, error):
                svn.ci()

            dot()
            svn.mkdir('viper')
            svn.mkdir('viper/eagle')
            svn.mkdir('viper/eagle/tomcat')
            with ensure_blocked(self, error):
                svn.ci('viper')

            dot()
            svn.mkdir('fulcrum')
            svn.mkdir('fulcrum/flanker')
            svn.mkdir('fulcrum/flanker/foxbat')
            svn.mkdir('fulcrum/flanker/foxbat/tags')
            svn.mkdir('fulcrum/flanker/foxbat/trunk')
            svn.mkdir('fulcrum/flanker/foxbat/branches')
            with ensure_blocked(self, error):
                svn.ci('fulcrum')
    def test_05_block_n_deep_non_standard_dirs(self):
        """
        Prevent any > two-level deep directories from being created if they're
        not a standard directory.
        """
        repo = self.create_repo(multi=True)
        svn = repo.svn

        error = e.InvalidTopLevelRepoComponentDirectoryCreated
        paths = [ p.replace('/', '') for p in conf.standard_layout ]
        with chdir(repo.wc):
            dot()
            svn.mkdir('foo')
            svn.ci()

            dot()
            svn.mkdir('foo/bar')
            svn.mkdir('foo/bar/tmp')
            with ensure_blocked(self, error):
                svn.ci()

            dot()
            svn.mkdir('viper')
            svn.mkdir('viper/eagle')
            svn.mkdir('viper/eagle/tomcat')
            with ensure_blocked(self, error):
                svn.ci('viper')

            dot()
            svn.mkdir('fulcrum')
            svn.mkdir('fulcrum/flanker')
            svn.mkdir('fulcrum/flanker/foxbat')
            svn.mkdir('fulcrum/flanker/foxbat/tags')
            svn.mkdir('fulcrum/flanker/foxbat/trunk')
            svn.mkdir('fulcrum/flanker/foxbat/branches')
            with ensure_blocked(self, error):
                svn.ci('fulcrum')
Exemplo n.º 48
0
    def test_01_basic(self):
        """
        Make sure trunk can't be re-copied within a branch.
        Reported by: @jamieechlin
        """
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        dot()
        roots_r1 = {
            '/trunk/': {
                'copies': {},
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(roots_r1, repo.roots)

        dot()
        with chdir(repo.wc):
            svn.cp('trunk', 'branches/1.x')
            svn.ci(m='Branching 1.x.')

        roots_r2 = {
            '/trunk/': { 'created': 1 },
            '/branches/1.x/': {
                'copied_from': ('/trunk/', 1),
                'copies': {},
                'created': 2,
                'creation_method': 'copied',
                'errors': []
            },
        }
        self.assertEqual(roots_r2, repo.roots)

        dot()
        error = 'known root path copied to known root subtree path'
        with chdir(repo.wc):
            svn.cp('trunk', 'branches/1.x')
            with ensure_blocked(self, error):
                svn.ci('branches/1.x', m='Copying trunk to branches/1.x.')
    def test_02_non_exempt(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set('main', 'exempt-symlinks-from-blocked-file-extensions', '0')
        conf.save()
        svn = repo.svn

        dot()
        self.assertFalse(conf.exempt_symlinks_from_blocked_file_extensions)

        dot()
        tree = { 'target': bulk_chargen(100) }
        repo.build(tree, prefix='trunk')
        trunk = join_path(repo.wc, 'trunk')
        error = e.BlockedFileExtension
        with chdir(trunk):
            dot()
            os.symlink('target', 'target.so')
            svn.add('target.so')
            with ensure_blocked(self, error):
                svn.ci('target.so', m='Adding symlink.')
Exemplo n.º 50
0
    def test_02_non_exempt(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set('main', 'exempt-symlinks-from-blocked-file-extensions', '0')
        conf.save()
        svn = repo.svn

        dot()
        self.assertFalse(conf.exempt_symlinks_from_blocked_file_extensions)

        dot()
        tree = {'target': bulk_chargen(100)}
        repo.build(tree, prefix='trunk')
        trunk = join_path(repo.wc, 'trunk')
        error = e.BlockedFileExtension
        with chdir(trunk):
            dot()
            os.symlink('target', 'target.so')
            svn.add('target.so')
            with ensure_blocked(self, error):
                svn.ci('target.so', m='Adding symlink.')
Exemplo n.º 51
0
    def test_01_under_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {
            '1000-bytes.txt': bulk_chargen(1000),
            '1023-bytes.txt': bulk_chargen(1023),
        }
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/1000-bytes.txt')
            dot()
            svn.add('trunk/1023-bytes.txt')
            svn.ci('trunk', m='Adding files under limit...')
Exemplo n.º 52
0
    def test_01_under_limit(self):
        repo = self.create_repo()
        conf = repo.conf
        conf.set_max_file_size_in_bytes(1024)

        svn = repo.svn

        #evnadmin = repo.evnadmin
        #evnadmin.enable_remote_debug(repo.path, hook='pre-commit')

        dot()
        tree = {
            '1000-bytes.txt': bulk_chargen(1000),
            '1023-bytes.txt': bulk_chargen(1023),
        }
        repo.build(tree, prefix='trunk')

        with chdir(repo.wc):
            dot()
            svn.add('trunk/1000-bytes.txt')
            dot()
            svn.add('trunk/1023-bytes.txt')
            svn.ci('trunk', m='Adding files under limit...')
Exemplo n.º 53
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Disable so we can mkdir ^/other
        dot()
        evnadmin.disable(repo.path)
        svn.mkdir(repo.ra("/other/"), m="Creating other directory")

        dot()
        evnadmin.enable(repo.path)
        svn.cp(repo.ra("/trunk/"), repo.ra("/branches/1.x/"), m="Branching")
        svn.cp(repo.ra("/branches/1.x/"), repo.ra("/tags/1.0/"), m="Tagging")
        svn.cp(repo.ra("/branches/1.x/"), repo.ra("/tags/1.1/"), m="Tagging")
        svn.cp(repo.ra("/branches/1.x/"), repo.ra("/tags/1.2/"), m="Tagging")

        # Lazy (quick) test of roots.
        dot()
        expected_roots = set(("/trunk/", "/branches/1.x/", "/tags/1.0/", "/tags/1.1/", "/tags/1.2/"))
        actual_roots = set(repo.roots.keys())
        self.assertEqual(expected_roots, actual_roots)

        is_repo_admin = lambda u: evnadmin.is_repo_admin(repo.name, u=u)
        add_repo_admin = lambda u: evnadmin.add_repo_admin(repo.name, u=u)
        show_repo_admins = lambda: evnadmin.show_repo_admins(repo.name)
        remove_repo_admin = lambda u: evnadmin.remove_repo_admin(repo.name, u=u)

        dot()
        username = svn.username
        self.assertEqual(is_repo_admin(username), "no")
        self.assertEqual(is_repo_admin("laskdjflsdkjf"), "no")

        dot()
        error = e.TagCopied
        with ensure_blocked(self, error):
            svn.cp(repo.ra("/tags/1.0/"), repo.ra("/other/1.0/"), m="Tagging")

        dot()
        error = "commits with errors can only be forced through by"
        with ensure_blocked(self, error):
            svn.cp(repo.ra("/tags/1.0/"), repo.ra("/other/1.0/"), m="IGNORE ERRORS")

        # dot()
        # error = e.TagCopied
        # with ensure_blocked(self, error):
        #    svn.cp(repo.ra('/tags/1.0/'), repo.ra('/other/1.0/'),
        #           m=EVN_ERROR_CONFIRMATIONS[e.TagCopied])

        dot()
        add_repo_admin(username)
        self.assertEqual(is_repo_admin(username), "yes")

        # Make sure we're still blocked if we're an admin but we haven't
        # explicitly included IGNORE ERRORS.
        dot()
        error = e.TagCopied
        with ensure_blocked(self, error):
            svn.cp(repo.ra("/tags/1.0/"), repo.ra("/other/1.0/"), m="Tagging")

        dot()
        error = e.TagCopied
        svn.cp(repo.ra("/tags/1.0/"), repo.ra("/other/1.0/"), m="IGNORE ERRORS")

        # dot()
        # error = e.TagRemoved
        # svn.rm(repo.ra('/tags/1.1/'), m=EVN_ERROR_CONFIRMATIONS[error])

        with chdir(repo.wc):
            svn.up()
            svn.cp("tags/1.2", "other/1.2")
            svn.cp("trunk", "other/foobar")
            svn.cp("branches/1.x", "other/1.x")
            svn.ci(m="IGNORE ERRORS")
Exemplo n.º 54
0
    def test_02_set_repo_readonly(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        is_repo_readonly = evnadmin.is_repo_readonly
        set_repo_readonly = evnadmin.set_repo_readonly
        unset_repo_readonly = evnadmin.unset_repo_readonly

        dot()
        expected = "no"
        actual = is_repo_readonly(repo.path)
        self.assertEqual(expected, actual)

        tree = {"test1.txt": bulk_chargen(100)}
        repo.build(tree, prefix="trunk")

        dot()
        with chdir(repo.wc):
            dot()
            svn.add("trunk/test1.txt")
            dot()
            svn.ci("trunk", m="Adding test1.txt")

        dot()
        set_repo_readonly(repo.path)

        dot()
        expected = "yes"
        actual = is_repo_readonly(repo.path)
        self.assertEqual(expected, actual)

        dot()
        tree = {"test2.txt": bulk_chargen(200)}
        repo.build(tree, prefix="trunk")

        error = "This repository cannot be committed to at the present time"
        with ensure_blocked(self, error):
            with chdir(repo.wc):
                dot()
                svn.add("trunk/test2.txt")
                dot()
                svn.ci("trunk", m="Adding test2.txt")

        dot()
        unset_repo_readonly(repo.path)

        dot()
        expected = "no"
        actual = is_repo_readonly(repo.path)
        self.assertEqual(expected, actual)

        dot()
        with chdir(repo.wc):
            dot()
            dot()
            svn.ci("trunk", m="Adding test2.txt")
Exemplo n.º 55
0
    def test_01(self):
        """
        Create a single-component repo, then convert to multi-component.
        """
        repo = self.create_repo()

        svn = repo.svn
        name = repo.name
        evnadmin = repo.evnadmin

        expected = conf.standard_layout
        raw = svn.ls(repo.uri)
        actual = frozenset(format_dir(l) for l in raw.splitlines())
        self.assertEqual(expected, actual)

        dot()
        self.assertEqual(0, repo.component_depth)

        dot()
        roots = {
            '/trunk/': {
                'copies': {},
                'created': 1,
                'creation_method': 'created',
            }
        }
        self.assertEqual(roots, repo.roots)

        dot()
        with chdir(repo.wc):
            svn.cp('trunk', 'branches/1.x')
            svn.ci(m='Branching 1.x.')

        dot()
        with chdir(repo.wc):
            svn.cp('branches/1.x', 'tags/1.1')
            svn.ci(m='Tagging 1.1.')

        dot()
        error = 'root ancestor path renamed to unknown path'
        with chdir(repo.wc):
            svn.up()
            svn.mkdir('foo')
            svn.mv('tags', 'foo')
            svn.mv('trunk', 'foo')
            svn.mv('branches', 'foo')
            with ensure_blocked(self, error):
                svn.ci()

        dot()
        evnadmin.disable(name)
        with chdir(repo.wc):
            svn.ci()
        evnadmin.set_repo_component_depth(repo.name, multi=True)
        evnadmin.enable(name)

        roots = {
            '/foo/branches/1.x/': {
                'copies': {},
                'created': 4,
                'creation_method': 'renamed_indirectly',
                'errors': ['root ancestor path renamed to unknown path'],
                'renamed_from': ('/branches/1.x/', 3),
                'renamed_indirectly_from': (
                    '/branches/',
                    '/foo/branches/',
                ),
            },
            '/foo/tags/1.1/': {
                'copies': {},
                'created': 4,
                'creation_method': 'renamed_indirectly',
                'errors': ['root ancestor path renamed to unknown path'],
                'renamed_from': ('/tags/1.1/', 3),
                'renamed_indirectly_from': (
                    '/tags/',
                    '/foo/tags/',
                ),
            },
            '/foo/trunk/': {
                'copies': {},
                'created': 4,
                'creation_method': 'renamed',
                'errors': [],
                'renamed_from': ('/trunk/', 3)
            }
        }

        self.assertEqual(roots, repo.roots)
Exemplo n.º 56
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        user1 = svn.username
        user2 = "foobar"
        assert user1 != user2
        both = ",".join(sorted((user2, user1)))

        is_repo_admin = lambda u: evnadmin.is_repo_admin(repo.name, u=u)
        add_repo_admin = lambda u: evnadmin.add_repo_admin(repo.name, u=u)
        show_repo_admins = lambda: evnadmin.show_repo_admins(repo.name)
        remove_repo_admin = lambda u: evnadmin.remove_repo_admin(repo.name, u=u)

        dot()
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), "<none>")

        dot()
        add_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Trying to re-add will be ignored.
        dot()
        add_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Try to remove non-existent.
        dot()
        remove_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Remove first.
        dot()
        remove_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), "<none>")

        # Add one back.
        dot()
        add_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Add second.
        add_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), both)

        # Add second again (no-op).
        dot()
        add_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), both)

        # Remove second.
        dot()
        remove_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Remove second again.
        dot()
        remove_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Remove first.
        dot()
        remove_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), "<none>")

        # Re-start: add first, then second, then remove first.
        dot()
        add_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), user1)

        # Add second.
        dot()
        add_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), both)

        # Remove first.
        dot()
        remove_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), user2)

        # Remove first again.
        dot()
        remove_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), user2)

        # Remove second.
        dot()
        remove_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "no")
        self.assertEqual(show_repo_admins(), "<none>")

        # Add second then first, verify order is still as expected.
        dot()
        add_repo_admin(user2)
        self.assertEqual(is_repo_admin(user1), "no")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), user2)

        dot()
        add_repo_admin(user1)
        self.assertEqual(is_repo_admin(user1), "yes")
        self.assertEqual(is_repo_admin(user2), "yes")
        self.assertEqual(show_repo_admins(), both)
Exemplo n.º 57
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        svnmucc = repo.svnmucc
        evnadmin = repo.evnadmin

        # Disable so we can mkdir ^/other
        dot()
        evnadmin.disable(repo.path)
        with chdir(repo.wc):
            svn.mkdir('other')
            svn.mkdir('keep')
            svn.ci()

        dot()
        evnadmin.enable(repo.path)
        svn.cp(repo.ra('/trunk/'), repo.ra('/branches/1.x/'), m='Branching')
        svn.cp(repo.ra('/branches/1.x/'), repo.ra('/tags/1.0/'), m='Tagging')

        # Lazy (quick) test of roots.
        dot()
        expected_roots = set(('/trunk/', '/branches/1.x/', '/tags/1.0/'))
        actual_roots = set(repo.roots.keys())
        self.assertEqual(expected_roots, actual_roots)

        # Add ourselves as a repo admin so that we can force through the next
        # commit.
        dot()
        evnadmin.add_repo_admin(repo.name, username=svn.username)
        expected = 'yes'
        actual = evnadmin.is_repo_admin(repo.name, username=svn.username)
        self.assertEqual(expected, actual)

        dot()
        with chdir(repo.wc):
            svn.up()
            svn.cp('trunk', 'other/foobar')
            svn.cp('branches/1.x', 'other/1.x')
            svn.cp('tags/1.0', 'other/1.0')
            svn.ci(m='IGNORE ERRORS')

        dot()
        evnadmin.set_repo_component_depth(repo.name, component_depth='-1')

        evnadmin.add_root_exclusion(
            repo.name,
            root_exclusion='/other/',
        )
        dot()
        svnmucc.rm(
            repo.ra('/other/'),
            'cp', '5', repo.ra('/other/'), repo.ra('/other/'),
            m='IGNORE ERRORS',
        )

        error = 'root ancestor path copied via replace to root ancestor path'
        evn_props_r6_expected = {
            'errors': {
                '/other/': [ error, ]
            },
            'roots' : {
                '/branches/1.x/': {'created': 3},
                '/tags/1.0/': {'created': 4},
                '/trunk/': {'created': 1},
            }
        }
        self.assertEqual(repo.revprops_at(6)['evn'], evn_props_r6_expected)

        evn_brprops_expected_after_r6 = {
            'last_rev': 6,
            'version': 1,
            'root_exclusions': ['/other/'],
            'root_ancestor_actions': {
                '/other/': {
                    6: [
                        {
                            'action': 'replaced',
                            'num_roots_removed': 3,
                        },
                        {
                            'action': 'copied',
                            'copied_from': ('/other/', 5),
                            'num_origin_roots': 3,
                            'num_roots_created': 0,
                        },
                    ],
                },
            },
        }
        self.assertEqual(
            repo.revprops_at(0)['evn'],
            evn_brprops_expected_after_r6,
        )
Exemplo n.º 58
0
    def test_01(self):
        repo = self.create_repo()
        svn = repo.svn
        evnadmin = repo.evnadmin

        # Disable so we can mkdir ^/other
        dot()
        evnadmin.disable(repo.path)
        with chdir(repo.wc):
            svn.mkdir('other')
            svn.mkdir('keep')
            svn.ci()

        dot()
        evnadmin.enable(repo.path)
        svn.cp(repo.ra('/trunk/'), repo.ra('/branches/1.x/'), m='Branching')
        svn.cp(repo.ra('/branches/1.x/'), repo.ra('/tags/1.0/'), m='Tagging')

        # Lazy (quick) test of roots.
        dot()
        expected_roots = set(('/trunk/', '/branches/1.x/', '/tags/1.0/'))
        actual_roots = set(repo.roots.keys())
        self.assertEqual(expected_roots, actual_roots)

        # Add ourselves as a repo admin so that we can force through the next
        # commit.
        dot()
        evnadmin.add_repo_admin(repo.name, username=svn.username)
        expected = 'yes'
        actual = evnadmin.is_repo_admin(repo.name, username=svn.username)
        self.assertEqual(expected, actual)

        dot()
        with chdir(repo.wc):
            svn.up()
            svn.cp('trunk', 'other/foobar')
            svn.cp('branches/1.x', 'other/1.x')
            svn.cp('tags/1.0', 'other/1.0')
            svn.ci(m='IGNORE ERRORS')

        evn_props_r5_expected = {
            'errors': {
                '/other/1.0/': [
                    'tag copied',
                    'known root path copied to unknown path',
                ],
                '/other/1.x/': [ 'known root path copied to unknown path' ],
                '/other/foobar/': [ 'known root path copied to unknown path' ],
            },
            'roots': {
                '/branches/1.x/': { 'created': 3 },
                '/other/1.0/': {
                    'copied_from': ('/tags/1.0/', 4),
                    'copies': {},
                    'created': 5,
                    'creation_method': 'copied',
                    'errors': [
                        'tag copied',
                        'known root path copied to unknown path',
                    ],
                },
                '/other/1.x/': {
                    'copied_from': ('/branches/1.x/', 4),
                    'copies': {},
                    'created': 5,
                    'creation_method': 'copied',
                    'errors': ['known root path copied to unknown path'],
                },
                '/other/foobar/': {
                    'copied_from': ('/trunk/', 4),
                    'copies': {},
                    'created': 5,
                    'creation_method': 'copied',
                    'errors': ['known root path copied to unknown path'],
                },
                '/tags/1.0/': { 'created': 4 },
                '/trunk/': { 'created': 1 }
            }
        }
        self.assertEqual(repo.revprops_at(5)['evn'], evn_props_r5_expected)

        dot()
        svn.mv(repo.ra('/other/'), repo.ra('/other.bak/'), m='IGNORE ERRORS')

        evn_props_r6_expected = {
            'errors': {
                '/other.bak/': ['root ancestor path renamed to unknown path'],
            },
            'roots' : {
                '/other.bak/1.0/': {
                    'renamed_indirectly_from': ('/other/', '/other.bak/'),
                    'renamed_from': ('/other/1.0/', 5),
                    'copies': {},
                    'created': 6,
                    'creation_method': 'renamed_indirectly',
                    'errors': ['root ancestor path renamed to unknown path'],
                },
                '/other.bak/1.x/': {
                    'renamed_indirectly_from': ('/other/', '/other.bak/'),
                    'renamed_from': ('/other/1.x/', 5),
                    'copies': {},
                    'created': 6,
                    'creation_method': 'renamed_indirectly',
                    'errors': ['root ancestor path renamed to unknown path'],
                },
                '/other.bak/foobar/': {
                    'renamed_indirectly_from': ('/other/', '/other.bak/'),
                    'renamed_from': ('/other/foobar/', 5),
                    'copies': {},
                    'created': 6,
                    'creation_method': 'renamed_indirectly',
                    'errors': ['root ancestor path renamed to unknown path'],
                },
                '/branches/1.x/': {'created': 3},
                '/tags/1.0/': {'created': 4},
                '/trunk/': {'created': 1},
            }
        }
        self.assertEqual(repo.revprops_at(6)['evn'], evn_props_r6_expected)

        evn_brprops_expected_after_r6 = {
            'component_depth': 0,
            'last_rev': 6,
            'version': 1,
            'root_ancestor_actions': {
                '/other.bak/': {
                    6: [
                        {
                            'action': 'renamed',
                            'renamed_from': '/other/',
                            'num_origin_roots': 3,
                            'num_roots_created': 3,
                            'num_roots_removed': 3,
                        },
                    ],
                },
            },
        }
        self.assertEqual(
            repo.revprops_at(0)['evn'],
            evn_brprops_expected_after_r6,
        )