示例#1
0
    def __init__(self, name, rootpath):
        # Init the client app
        core.apr_initialize()
        pool = core.svn_pool_create(None)
        core.svn_config_ensure(None, pool)

        # Start populating our members
        self.pool = pool
        self.name = name
        self.rootpath = rootpath

        # Setup the client context baton, complete with non-prompting authstuffs.
        ctx = client.svn_client_ctx_t()
        providers = []
        providers.append(client.svn_client_get_simple_provider(pool))
        providers.append(client.svn_client_get_username_provider(pool))
        providers.append(
            client.svn_client_get_ssl_server_trust_file_provider(pool))
        providers.append(
            client.svn_client_get_ssl_client_cert_file_provider(pool))
        providers.append(
            client.svn_client_get_ssl_client_cert_pw_file_provider(pool))
        ctx.auth_baton = core.svn_auth_open(providers, pool)
        ctx.config = core.svn_config_get_config(None, pool)
        self.ctx = ctx

        ra_callbacks = ra.svn_ra_callbacks_t()
        ra_callbacks.auth_baton = ctx.auth_baton
        self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                         ctx.config, pool)
        self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session, pool)
        self._dirent_cache = {}
示例#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()
示例#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()
示例#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()
示例#5
0
  def __init__(self, name, rootpath):
    # Init the client app
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)

    # Start populating our members
    self.pool = pool
    self.name = name
    self.rootpath = rootpath

    # Setup the client context baton, complete with non-prompting authstuffs.
    ctx = client.svn_client_ctx_t()
    providers = []
    providers.append(client.svn_client_get_simple_provider(pool))
    providers.append(client.svn_client_get_username_provider(pool))
    providers.append(client.svn_client_get_ssl_server_trust_file_provider(pool))
    providers.append(client.svn_client_get_ssl_client_cert_file_provider(pool))
    providers.append(client.svn_client_get_ssl_client_cert_pw_file_provider(pool))
    ctx.auth_baton = core.svn_auth_open(providers, pool)
    ctx.config = core.svn_config_get_config(None, pool)
    self.ctx = ctx

    ra_callbacks = ra.svn_ra_callbacks_t()
    ra_callbacks.auth_baton = ctx.auth_baton
    self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None,
                                     ctx.config, pool)
    self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session, pool)
    self._dirent_cache = { }
示例#6
0
def svn_uri(path):
    # init
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)
    # get commit date
    uri = client.svn_client_url_from_path(path, pool)
    # cleanup
    core.svn_pool_destroy(pool)
    core.apr_terminate()
    return uri
示例#7
0
def svn_uri(path):
    # init
    core.apr_initialize()
    pool = core.svn_pool_create(None)
    core.svn_config_ensure(None, pool)
    # get commit date
    uri = client.svn_client_url_from_path(path, pool)
    # cleanup
    core.svn_pool_destroy(pool)
    core.apr_terminate()
    return uri
示例#8
0
def open_svn_repos(repos_dir):
    from svn import util, repos, core

    core.apr_initialize()
    pool = core.svn_pool_create(None)
    # Remove any trailing slash or else subversion might abort
    if not os.path.split(repos_dir)[1]:
        repos_dir = os.path.split(repos_dir)[0]

    rep = repos.svn_repos_open(repos_dir, pool)
    fs_ptr = repos.svn_repos_fs(rep)
    return pool, rep, fs_ptr
示例#9
0
 def __init__(self, parent_pool=None):
     global application_pool
     self._parent_pool = parent_pool or application_pool
     
     if self._parent_pool:
         self._pool = core.svn_pool_create(self._parent_pool())
     else:
         core.apr_initialize()
         application_pool = self
         
         self._pool = core.svn_pool_create(None)
     self._mark_valid()
示例#10
0
    def __init__(self, parent_pool=None):
        """Create a new memory pool"""

        global application_pool
        self._parent_pool = parent_pool or application_pool

        # Create pool
        if self._parent_pool:
            self._pool = core.svn_pool_create(self._parent_pool())
        else:
            # If we are an application-level pool,
            # then initialize APR and set this pool
            # to be the application-level pool
            core.apr_initialize()
            application_pool = self

            self._pool = core.svn_pool_create(None)
        self._mark_valid()
示例#11
0
    def __init__(self, name, rootpath, svn_path):
        if not os.path.isdir(rootpath):
            raise vclib.ReposNotFound(name)

        # Initialize some stuff.
        self.pool = None
        self.apr_init = 0
        self.rootpath = rootpath
        self.name = name
        self.svn_client_path = os.path.normpath(os.path.join(svn_path, 'svn'))

        # Register a handler for SIGTERM so we can have a chance to
        # cleanup.  If ViewVC takes too long to start generating CGI
        # output, Apache will grow impatient and SIGTERM it.  While we
        # don't mind getting told to bail, we want to gracefully close the
        # repository before we bail.
        def _sigterm_handler(signum, frame, self=self):
            self._close()
            sys.exit(-1)

        try:
            signal.signal(signal.SIGTERM, _sigterm_handler)
        except ValueError:
            # This is probably "ValueError: signal only works in main
            # thread", which will get thrown by the likes of mod_python
            # when trying to install a signal handler from a thread that
            # isn't the main one.  We'll just not care.
            pass

        # Initialize APR and get our top-level pool.
        core.apr_initialize()
        self.apr_init = 1
        self.pool = core.svn_pool_create(None)
        self.scratch_pool = core.svn_pool_create(self.pool)

        # Open the repository and init some other variables.
        self.repos = repos.svn_repos_open(rootpath, self.pool)
        self.fs_ptr = repos.svn_repos_fs(self.repos)
        self.youngest = fs.youngest_rev(self.fs_ptr, self.pool)
        self._fsroots = {}
示例#12
0
  def __init__(self, name, rootpath, svn_path):
    if not os.path.isdir(rootpath):
      raise vclib.ReposNotFound(name)

    # Initialize some stuff.
    self.pool = None
    self.apr_init = 0
    self.rootpath = rootpath
    self.name = name
    self.svn_client_path = os.path.normpath(os.path.join(svn_path, 'svn'))

    # Register a handler for SIGTERM so we can have a chance to
    # cleanup.  If ViewVC takes too long to start generating CGI
    # output, Apache will grow impatient and SIGTERM it.  While we
    # don't mind getting told to bail, we want to gracefully close the
    # repository before we bail.
    def _sigterm_handler(signum, frame, self=self):
      self._close()
      sys.exit(-1)
    try:
      signal.signal(signal.SIGTERM, _sigterm_handler)
    except ValueError:
      # This is probably "ValueError: signal only works in main
      # thread", which will get thrown by the likes of mod_python
      # when trying to install a signal handler from a thread that
      # isn't the main one.  We'll just not care.
      pass

    # Initialize APR and get our top-level pool.
    core.apr_initialize()
    self.apr_init = 1
    self.pool = core.svn_pool_create(None)
    self.scratch_pool = core.svn_pool_create(self.pool)
    
    # Open the repository and init some other variables.
    self.repos = repos.svn_repos_open(rootpath, self.pool)
    self.fs_ptr = repos.svn_repos_fs(self.repos)
    self.youngest = fs.youngest_rev(self.fs_ptr, self.pool)
    self._fsroots = {}
示例#13
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()
示例#14
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()
示例#16
0
    # write the data into the auth file used by apache
    auth_file = file(options.authdir + options.repo + '-passwdfile','wb')
    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: