Example #1
0
File: svn_fs.py Project: t2y/trac
 def setUp(self):
     self.env = EnvironmentStub()
     self.repos_path = tempfile.mkdtemp(prefix='trac-svnrepos-')
     self.dbprovider = DbRepositoryProvider(self.env)
     pool = core.svn_pool_create(None)
     repos.svn_repos_create(self.repos_path, '', '', None, None, pool)
     self.dbprovider.add_repository(REPOS_NAME, self.repos_path, 'svn')
Example #2
0
    def setUp(self):
        dumpfile = open(os.path.join(os.path.split(__file__)[0],
                                     'svnrepos.dump'))

        svn_fs._import_svn()
        core.apr_initialize()
        pool = core.svn_pool_create(None)
        dumpstream = None
        try:
            if os.path.exists(REPOS_PATH):
                print 'trouble ahead with db/rep-cache.db... see #8278'
            r = repos.svn_repos_create(REPOS_PATH, '', '', None, None, pool)
            if hasattr(repos, 'svn_repos_load_fs2'):
                repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                        repos.svn_repos_load_uuid_default, '',
                                        0, 0, None, pool)
            else:
                dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
                repos.svn_repos_load_fs(r, dumpstream, None,
                                        repos.svn_repos_load_uuid_default, '',
                                        None, None, pool)
        finally:
            if dumpstream:
                core.svn_stream_close(dumpstream)
            core.svn_pool_destroy(pool)
            core.apr_terminate()
Example #3
0
 def setupClass(cls):
     svn_fs._import_svn()
     core.apr_initialize()
     pool = core.svn_pool_create(None)
     dumpstream = None
     cls.repos_path = tempfile.mkdtemp(prefix='svn-tmp')
     shutil.rmtree(cls.repos_path)
     dumpfile = open(os.path.join(os.path.split(__file__)[0], 'svn.dump'))
     try:
         r = repos.svn_repos_create(cls.repos_path, '', '', None, None,
                                    pool)
         if hasattr(repos, 'svn_repos_load_fs2'):
             repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                      repos.svn_repos_load_uuid_default, '',
                                      0, 0, None, pool)
         else:
             dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
             repos.svn_repos_load_fs(r, dumpstream, None,
                                     repos.svn_repos_load_uuid_default, '',
                                     None, None, pool)
     finally:
         if dumpstream:
             core.svn_stream_close(dumpstream)
         core.svn_pool_destroy(pool)
         core.apr_terminate()
Example #4
0
    def setUp(self):
        dumpfile = open(
            os.path.join(os.path.split(__file__)[0], 'svnrepos.dump'))

        svn_fs._import_svn()
        core.apr_initialize()
        pool = core.svn_pool_create(None)
        dumpstream = None
        try:
            if os.path.exists(REPOS_PATH):
                print 'trouble ahead with db/rep-cache.db... see #8278'
            r = repos.svn_repos_create(REPOS_PATH, '', '', None, None, pool)
            if hasattr(repos, 'svn_repos_load_fs2'):
                repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                         repos.svn_repos_load_uuid_default, '',
                                         0, 0, None, pool)
            else:
                dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
                repos.svn_repos_load_fs(r, dumpstream, None,
                                        repos.svn_repos_load_uuid_default, '',
                                        None, None, pool)
        finally:
            if dumpstream:
                core.svn_stream_close(dumpstream)
            core.svn_pool_destroy(pool)
            core.apr_terminate()
Example #5
0
def create_and_load(repopath, dumpfd):
    ''' create a new repository at repopath and load the given dump into it '''
    pool = core.Pool()
    r = repos.svn_repos_create(repopath, '', '', None, None, pool)
    with open(os.path.join(repopath, 'db', 'fsfs.conf'), 'w') as f:
        f.write(
            textwrap.dedent("""\
        # config settings for svn repos to try and speed up the testsuite
        [rep-sharing]
        enable-rep-sharing = false
        [deltification]
        enable-dir-deltification = false
        enable-props-deltification = false
        [compression]
        compression-level=1
        """))

    try:
        repos.svn_repos_load_fs2(r, dumpfd, None,
                                 repos.svn_repos_load_uuid_force, '', False,
                                 False, None, pool)
    finally:
        dumpfd.close()

        pool.destroy()
Example #6
0
    def setUp(self):
        dumpfile = open(os.path.join(os.path.split(__file__)[0], "svnrepos.dump"))

        # Remove the trac-svnrepos directory, so that we can
        # ensure a fresh start.
        self.tearDown()

        r = repos.svn_repos_create(REPOS_PATH, "", "", None, None)
        repos.svn_repos_load_fs2(r, dumpfile, StringIO(), repos.svn_repos_load_uuid_ignore, "", 0, 0, None)
Example #7
0
    def setUp(self):
        dump_path = os.path.join(os.path.split(__file__)[0], 'svnrepos.dump')
        with open(dump_path, 'rb') as dumpfile:
            # Remove the trac-svnrepos directory, so that we can
            # ensure a fresh start.
            self.tearDown()

            r = repos.svn_repos_create(REPOS_PATH, b'', b'', None, None)
            repos.svn_repos_load_fs2(r, dumpfile, BytesIO(),
                                     repos.svn_repos_load_uuid_ignore, b'', 0,
                                     0, None)
Example #8
0
    def setUp(self):
        dumpfile = open(
            os.path.join(os.path.split(__file__)[0], 'svnrepos.dump'))

        # Remove the trac-svnrepos directory, so that we can
        # ensure a fresh start.
        self.tearDown()

        r = repos.svn_repos_create(REPOS_PATH, '', '', None, None)
        repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                 repos.svn_repos_load_uuid_ignore, '', 0, 0,
                                 None)
Example #9
0
 def setUp(self):
   """Load the mergeinfo-full Subversion repository.  This dumpfile is
      created by dumping the repository generated for command line log
      tests 16.  If it needs to be updated (mergeinfo format changes, for
      example), we can go there to get a new version."""
   dumpfile = open(os.path.join(os.path.split(__file__)[0],
                                'data', 'mergeinfo.dump'))
   # Remove any existing repository to ensure a fresh start
   self.tearDown()
   self.repos = repos.svn_repos_create(REPOS_PATH, '', '', None, None)
   repos.svn_repos_load_fs2(self.repos, dumpfile, StringIO(),
                            repos.svn_repos_load_uuid_default, '',
                            0, 0, None)
   self.fs = repos.fs(self.repos)
   self.rev = fs.youngest_rev(self.fs)
Example #10
0
 def setUp(self):
     """Load the mergeinfo-full Subversion repository.  This dumpfile is
    created by dumping the repository generated for command line log
    tests 16.  If it needs to be updated (mergeinfo format changes, for
    example), we can go there to get a new version."""
     dumpfile = open(
         os.path.join(os.path.split(__file__)[0], 'data', 'mergeinfo.dump'))
     # Remove any existing repository to ensure a fresh start
     self.tearDown()
     self.repos = repos.svn_repos_create(REPOS_PATH, '', '', None, None)
     repos.svn_repos_load_fs2(self.repos, dumpfile, StringIO(),
                              repos.svn_repos_load_uuid_default, '', 0, 0,
                              None)
     self.fs = repos.fs(self.repos)
     self.rev = fs.youngest_rev(self.fs)
Example #11
0
    def setUp(self):
        dumpfile = open(os.path.join(os.path.split(__file__)[0],
                                     'svnrepos.dump'))

        core.apr_initialize()
        pool = core.svn_pool_create(None)
        dumpstream = None
        try:
            r = repos.svn_repos_create(REPOS_PATH, '', '', None, None, pool)
            if hasattr(repos, 'svn_repos_load_fs2'):
                repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                        repos.svn_repos_load_uuid_default, '',
                                        0, 0, None, pool)
            else:
                dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
                repos.svn_repos_load_fs(r, dumpstream, None,
                                        repos.svn_repos_load_uuid_default, '',
                                        None, None, pool)
        finally:
            if dumpstream:
                core.svn_stream_close(dumpstream)
            core.svn_pool_destroy(pool)
            core.apr_terminate()
Example #12
0
    def setUp(self):
        dumpfile = open(
            os.path.join(os.path.split(__file__)[0], 'svnrepos.dump'))

        core.apr_initialize()
        pool = core.svn_pool_create(None)
        dumpstream = None
        try:
            r = repos.svn_repos_create(REPOS_PATH, '', '', None, None, pool)
            if hasattr(repos, 'svn_repos_load_fs2'):
                repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                         repos.svn_repos_load_uuid_default, '',
                                         0, 0, None, pool)
            else:
                dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
                repos.svn_repos_load_fs(r, dumpstream, None,
                                        repos.svn_repos_load_uuid_default, '',
                                        None, None, pool)
        finally:
            if dumpstream:
                core.svn_stream_close(dumpstream)
            core.svn_pool_destroy(pool)
            core.apr_terminate()
 def setupClass(cls):
     svn_fs._import_svn()
     core.apr_initialize()
     pool = core.svn_pool_create(None)
     dumpstream = None
     cls.repos_path = tempfile.mkdtemp(prefix='svn-tmp')
     shutil.rmtree(cls.repos_path)
     dumpfile = open(os.path.join(os.path.split(__file__)[0], 'svn.dump'))
     try:
         r = repos.svn_repos_create(cls.repos_path, '', '', None, None, pool)
         if hasattr(repos, 'svn_repos_load_fs2'):
             repos.svn_repos_load_fs2(r, dumpfile, StringIO(),
                                     repos.svn_repos_load_uuid_default, '',
                                     0, 0, None, pool)
         else:
             dumpstream = core.svn_stream_from_aprfile(dumpfile, pool)
             repos.svn_repos_load_fs(r, dumpstream, None,
                                     repos.svn_repos_load_uuid_default, '',
                                     None, None, pool)
     finally:
         if dumpstream:
             core.svn_stream_close(dumpstream)
         core.svn_pool_destroy(pool)
         core.apr_terminate()
    auth_file.write(digest_data)
    auth_file.close()

except OSError :
    cli_parser.error( "Can't create password file")

lchown(options.authdir + options.repo + '-passwdfile',0,apachegid)
chmod(options.authdir + options.repo + '-passwdfile',0640)

try:
    # we create the repository using the <rant> undocumented</rant> swig bindings.
    # took me a while to figure how to do this.
    # thanks to folks at #subversion-dev for give me some guidelines.
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    repos.svn_repos_create(options.location + options.repo, '', '', None, {
        fs.SVN_FS_CONFIG_FS_TYPE: options.filesystem }, pool)
    core.svn_pool_destroy(pool)
    core.apr_terminate()

except OSError:
    cli_parser.error( "Failed to create the repository")
else:
    for dire in ['dav','db','locks']:
        lchown(options.location + options.repo + sep + dire, apacheuid, apachegid)
        for root, dirs, files in walk(options.location + options.repo + sep + dire ):
            for name in files :
                lchown(join(root, name) , apacheuid , apachegid)
            for name in dirs:
                lchown(join(root, name), apacheuid , apachegid)

    print "Reloading apache.."