def setup_client_ctx(config_dir): # Ensure that the configuration directory exists. core.svn_config_ensure(config_dir) # Fetch the configuration (and 'config' bit thereof). cfg = core.svn_config_get_config(config_dir) config = cfg.get(core.SVN_CONFIG_CATEGORY_CONFIG) # Here's the compat-sensitive part: try to use # svn_cmdline_create_auth_baton(), and fall back to making our own # if that fails. try: auth_baton = core.svn_cmdline_create_auth_baton( 1, None, None, config_dir, 1, 1, config, None) except AttributeError: auth_baton = core.svn_auth_open([ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), client.svn_client_get_ssl_server_trust_file_provider(), client.svn_client_get_ssl_client_cert_file_provider(), client.svn_client_get_ssl_client_cert_pw_file_provider(), ]) if config_dir is not None: core.svn_auth_set_parameter(auth_baton, core.SVN_AUTH_PARAM_CONFIG_DIR, config_dir) # Create, setup, and return the client context baton. ctx = client.svn_client_create_context() ctx.config = cfg ctx.auth_baton = auth_baton return ctx
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 = {}
def setup_client_ctx(config_dir): # Ensure that the configuration directory exists. core.svn_config_ensure(config_dir) # Fetch the configuration (and 'config' bit thereof). cfg = core.svn_config_get_config(config_dir) config = cfg.get(core.SVN_CONFIG_CATEGORY_CONFIG) # Here's the compat-sensitive part: try to use # svn_cmdline_create_auth_baton(), and fall back to making our own # if that fails. try: auth_baton = core.svn_cmdline_create_auth_baton(1, None, None, config_dir, 1, 1, config, None) except AttributeError: auth_baton = core.svn_auth_open([ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), client.svn_client_get_ssl_server_trust_file_provider(), client.svn_client_get_ssl_client_cert_file_provider(), client.svn_client_get_ssl_client_cert_pw_file_provider(), ]) if config_dir is not None: core.svn_auth_set_parameter(auth_baton, core.SVN_AUTH_PARAM_CONFIG_DIR, config_dir) # Create, setup, and return the client context baton. ctx = client.svn_client_create_context() ctx.config = cfg ctx.auth_baton = auth_baton return ctx
def open(self): # Setup the client context baton, complete with non-prompting authstuffs. # TODO: svn_cmdline_setup_auth_baton() is mo' better (when available) core.svn_config_ensure(self.config_dir) self.ctx = client.svn_client_create_context() self.ctx.auth_baton = core.svn_auth_open([ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), client.svn_client_get_ssl_server_trust_file_provider(), client.svn_client_get_ssl_client_cert_file_provider(), client.svn_client_get_ssl_client_cert_pw_file_provider(), ]) self.ctx.config = core.svn_config_get_config(self.config_dir) if self.config_dir is not None: core.svn_auth_set_parameter(self.ctx.auth_baton, core.SVN_AUTH_PARAM_CONFIG_DIR, self.config_dir) ra_callbacks = ra.svn_ra_callbacks_t() ra_callbacks.auth_baton = self.ctx.auth_baton self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None, self.ctx.config) self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session) self._dirent_cache = {} self._revinfo_cache = {} # See if a universal read access determination can be made. if self.auth and self.auth.check_universal_access(self.name) == 1: self.auth = None
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 = { }
def setUp(self): """Load a Subversion repository""" self.temper = utils.Temper() (self.repos, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo( 'trac/versioncontrol/tests/svnrepos.dump', suffix='-repository') self.fs = repos.fs(self.repos) self.rev = fs.youngest_rev(self.fs) self.tmpfile = None self.unistr = u'⊙_ʘ' tmpfd, self.tmpfile = mkstemp() tmpfp = os.fdopen(tmpfd, "wb") # Use a unicode file to ensure proper non-ascii handling. tmpfp.write(self.unistr.encode('utf8')) tmpfp.close() clientctx = client.svn_client_create_context() clientctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func clientctx.log_msg_baton3 = self.log_message_func providers = [ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] clientctx.auth_baton = core.svn_auth_open(providers) commitinfo = client.import2(self.tmpfile, urljoin(self.repos_uri +"/", "trunk/UniTest.txt"), True, True, clientctx) self.commitedrev = commitinfo.revision
def open(self): # Setup the client context baton, complete with non-prompting authstuffs. # TODO: svn_cmdline_setup_auth_baton() is mo' better (when available) core.svn_config_ensure(self.config_dir) self.ctx = client.svn_client_create_context() self.ctx.auth_baton = core.svn_auth_open([ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), client.svn_client_get_ssl_server_trust_file_provider(), client.svn_client_get_ssl_client_cert_file_provider(), client.svn_client_get_ssl_client_cert_pw_file_provider(), ]) self.ctx.config = core.svn_config_get_config(self.config_dir) if self.config_dir is not None: core.svn_auth_set_parameter(self.ctx.auth_baton, core.SVN_AUTH_PARAM_CONFIG_DIR, self.config_dir) ra_callbacks = ra.svn_ra_callbacks_t() ra_callbacks.auth_baton = self.ctx.auth_baton self.ra_session = ra.svn_ra_open(self.rootpath, ra_callbacks, None, self.ctx.config) self.youngest = ra.svn_ra_get_latest_revnum(self.ra_session) self._dirent_cache = { } self._revinfo_cache = { } # See if a universal read access determination can be made. if self.auth and self.auth.check_universal_access(self.name) == 1: self.auth = None
def svn_move(src_path, dst_path, username='', commitmsg=''): '''Move src_path to dst_path, where each is the url to a file or directory in a Subversion repository. Apply the change as username, and log with commitmsg. ''' def log_message(items, pool): '''Return a commit log message, use as a callback ''' def fname(s): return s.rstrip('/').rsplit('/', 1)[1] src_fname = fname(items[1][2]) dst_fname = fname(items[0][2]) default_msg = 'Moved %s to %s' % (src_fname, dst_fname) return commitmsg or default_msg src_path = core.svn_path_canonicalize(src_path) dst_path = core.svn_path_canonicalize(dst_path) force = False # Ignored for repository -> repository moves move_as_child = False # If dst_path exists don't attempt to move src_path # as it's child make_parents = False # Make parents of dst_path as needed (like mkdir -p) revprop_tbl = None # Use a dict of str prop: vals to set custom svn props # The move operation is coordinated by a client context, suitbly populated # To set the commit message we provide a callback that returns commitmsg client_ctx = client.create_context() client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func client_ctx.log_msg_baton3 = log_message # Configure minimal authentication, this is an example only auth_providers = [ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] client_ctx.auth_baton = core.svn_auth_open(auth_providers) # libsvn normally infers the username from the environment the working copy # and the configuration. If requested override all that. if username is not None: core.svn_auth_set_parameter(client_ctx.auth_baton, core.SVN_AUTH_PARAM_DEFAULT_USERNAME, username) # Move one directory or file to another location in the same repository # svn_client_move5 can mv a number of files/directories at once if dst_path # is a directory, we ignore this and pass a 1-tuple commit_info = client.svn_client_move5( (src_path, ), dst_path, force, # Ignored move_as_child, make_parents, revprop_tbl, client_ctx, ) print commit_info.revision
def setUp(self): """Load a Subversion repository""" self.client_ctx = client.svn_client_create_context() providers = [ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] self.client_ctx.auth_baton = core.svn_auth_open(providers)
def svn_move(src_path, dst_path, username='', commitmsg=''): '''Move src_path to dst_path, where each is the url to a file or directory in a Subversion repository. Apply the change as username, and log with commitmsg. ''' def log_message(items, pool): '''Return a commit log message, use as a callback ''' def fname(s): return s.rstrip('/').rsplit('/', 1)[1] src_fname = fname(items[1][2]) dst_fname = fname(items[0][2]) default_msg = 'Moved %s to %s' % (src_fname, dst_fname) return commitmsg or default_msg src_path = core.svn_path_canonicalize(src_path) dst_path = core.svn_path_canonicalize(dst_path) force = False # Ignored for repository -> repository moves move_as_child = False # If dst_path exists don't attempt to move src_path # as it's child make_parents = False # Make parents of dst_path as needed (like mkdir -p) revprop_tbl = None # Use a dict of str prop: vals to set custom svn props # The move operation is coordinated by a client context, suitbly populated # To set the commit message we provide a callback that returns commitmsg client_ctx = client.create_context() client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func client_ctx.log_msg_baton3 = log_message # Configure minimal authentication, this is an example only auth_providers = [client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] client_ctx.auth_baton = core.svn_auth_open(auth_providers) # libsvn normally infers the username from the environment the working copy # and the configuration. If requested override all that. if username is not None: core.svn_auth_set_parameter(client_ctx.auth_baton, core.SVN_AUTH_PARAM_DEFAULT_USERNAME, username) # Move one directory or file to another location in the same repository # svn_client_move5 can mv a number of files/directories at once if dst_path # is a directory, we ignore this and pass a 1-tuple commit_info = client.svn_client_move5((src_path,), dst_path, force, # Ignored move_as_child, make_parents, revprop_tbl, client_ctx, ) print commit_info.revision
def setUp(self): """Set up authentication and client context""" self.client_ctx = client.svn_client_create_context() self.assertEquals(self.client_ctx.log_msg_baton2, None) self.assertEquals(self.client_ctx.log_msg_func2, None) self.assertEquals(self.client_ctx.log_msg_baton3, None) self.assertEquals(self.client_ctx.log_msg_func3, None) self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func self.client_ctx.log_msg_baton3 = self.log_message_func self.log_message_func_calls = 0 self.log_message = None self.changed_paths = None self.change_author = None providers = [ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] self.client_ctx.auth_baton = core.svn_auth_open(providers)
def setUp(self): """Set up authentication and client context""" self.client_ctx = client.svn_client_create_context() self.assertEquals(self.client_ctx.log_msg_baton2, None) self.assertEquals(self.client_ctx.log_msg_func2, None) self.assertEquals(self.client_ctx.log_msg_baton3, None) self.assertEquals(self.client_ctx.log_msg_func3, None) self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func self.client_ctx.log_msg_baton3 = self.log_message_func self.log_message_func_calls = 0 self.log_message = None self.changed_paths = None self.change_author = None providers = [client.svn_client_get_simple_provider(), client.svn_client_get_username_provider()] self.client_ctx.auth_baton = core.svn_auth_open(providers) self.temper = utils.Temper() (_, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo( "trac/versioncontrol/tests/svnrepos.dump", suffix="-client" )
def setUp(self): """Set up authentication and client context""" self.client_ctx = client.svn_client_create_context() self.assertEqual(self.client_ctx.log_msg_baton2, None) self.assertEqual(self.client_ctx.log_msg_func2, None) self.assertEqual(self.client_ctx.log_msg_baton3, None) self.assertEqual(self.client_ctx.log_msg_func3, None) self.client_ctx.log_msg_func3 = client.svn_swig_py_get_commit_log_func self.client_ctx.log_msg_baton3 = self.log_message_func self.log_message_func_calls = 0 self.log_message = None self.changed_paths = None self.change_author = None providers = [ client.svn_client_get_simple_provider(), client.svn_client_get_username_provider(), ] self.client_ctx.auth_baton = core.svn_auth_open(providers) self.temper = utils.Temper() (_, self.repos_path, self.repos_uri) = self.temper.alloc_known_repo( 'trac/versioncontrol/tests/svnrepos.dump', suffix='-client')