/** * lists properties in @a path no matter whether local or * repository * * @param path * @param revision * @param recurse * @return PropertiesList */ PathPropertiesMapList Client::proplist(const Path & path, const Revision & revision, bool recurse) { Pool pool; apr_array_header_t * props; svn_error_t * error = svn_client_proplist(&props, path.c_str(), revision.revision(), recurse, *m_context, pool); if (error != nullptr) { throw ClientException(error); } PathPropertiesMapList path_prop_map_list; for (int j = 0; j < props->nelts; ++j) { svn_client_proplist_item_t *item = ((svn_client_proplist_item_t **)props->elts)[j]; PropertiesMap prop_map; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, item->prop_hash); hi; hi = apr_hash_next(hi)) { const void *key; void *val; apr_hash_this(hi, &key, nullptr, &val); prop_map [std::string((const char *)key)] = std::string(((const svn_string_t *)val)->data); } path_prop_map_list.push_back(PathPropertiesMapEntry(item->node_name->data, prop_map)); } return path_prop_map_list; }
void Property::list() { Pool pool; Revision revision; m_entries.clear(); apr_array_header_t * props; svn_error_t * error = svn_client_proplist(&props, m_path.c_str(), revision, false, /* recurse */ *m_context, pool); if (error != NULL) { throw ClientException(error); } for (int j = 0; j < props->nelts; ++j) { svn_client_proplist_item_t *item = ((svn_client_proplist_item_t **)props->elts)[j]; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, item->prop_hash); hi; hi = apr_hash_next(hi)) { const void *key; void *val; apr_hash_this(hi, &key, NULL, &val); m_entries.push_back(PropertyEntry( (const char *)key, getValue((const char *)key).c_str())); } } }
Py::Object pysvn_client::cmd_proplist( const Py::Tuple &a_args, const Py::Dict &a_kws ) { static argument_description args_desc[] = { { true, name_url_or_path }, { false, name_revision }, { false, name_recurse }, #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) { false, name_peg_revision }, #endif #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) { false, name_depth }, { false, name_changelists }, #endif { false, NULL } }; FunctionArguments args( "proplist", args_desc, a_args, a_kws ); args.check(); Py::List path_list( toListOfStrings( args.getArg( name_url_or_path ) ) ); SvnPool pool( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) apr_array_header_t *changelists = NULL; if( args.hasArg( name_changelists ) ) { changelists = arrayOfStringsFromListOfStrings( args.getArg( name_changelists ), pool ); } svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_files, svn_depth_empty ); #else bool recurse = args.getBoolean( name_recurse, false ); #endif bool is_revision_setup = false; bool is_url = false; svn_opt_revision_t revision_url; svn_opt_revision_t revision_file; if( args.hasArg( name_revision ) ) { revision_url = args.getRevision( name_revision ); revision_file = revision_url; } else { revision_url.kind = svn_opt_revision_head; revision_file.kind = svn_opt_revision_working; } #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) svn_opt_revision_t peg_revision_url; svn_opt_revision_t peg_revision_file; if( args.hasArg( name_peg_revision ) ) { peg_revision_url = args.getRevision( name_peg_revision ); peg_revision_file = peg_revision_url; } else { peg_revision_url = revision_url; peg_revision_file = revision_file; } #endif Py::List list_of_proplists; for( Py::List::size_type i=0; i<path_list.length(); i++ ) { Py::String path_str( asUtf8String( path_list[i] ) ); std::string path( path_str.as_std_string() ); std::string norm_path( svnNormalisedIfPath( path, pool ) ); svn_opt_revision_t revision; svn_opt_revision_t peg_revision; if( !is_revision_setup ) if( is_svn_url( path ) ) { revision = revision_url; #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) peg_revision = peg_revision_url; #endif is_url = true; } else { revision = revision_file; #if defined( PYSVN_HAS_CLIENT_PROPLIST2 ) peg_revision = peg_revision_file; #endif } else if( is_svn_url( path ) && !is_url ) { throw Py::AttributeError( "cannot mix URL and PATH in name_path" ); } try { const char *norm_path_c_str= norm_path.c_str(); checkThreadPermission(); PythonAllowThreads permission( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPLIST3 ) ProplistReceiveBaton proplist_baton( &permission, pool, list_of_proplists ); svn_error_t *error = svn_client_proplist3 ( norm_path_c_str, &peg_revision, &revision, depth, changelists, proplist_receiver_c, reinterpret_cast<void *>( &proplist_baton ), m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_PROPLIST2 ) apr_array_header_t *props = NULL; svn_error_t *error = svn_client_proplist2 ( &props, norm_path_c_str, &peg_revision, &revision, recurse, m_context, pool ); #else apr_array_header_t *props = NULL; svn_error_t *error = svn_client_proplist ( &props, norm_path_c_str, &revision, recurse, m_context, pool ); #endif permission.allowThisThread(); if( error != NULL ) throw SvnException( error ); #if !defined( PYSVN_HAS_CLIENT_PROPLIST3 ) proplistToObject( list_of_proplists, props, pool ); #endif } catch( SvnException &e ) { // use callback error over ClientException m_context.checkForError( m_module.client_error ); throw_client_error( e ); } } return list_of_proplists; }
int main( int argc, char **argv ) { if( argc < 4 ) { std::cout << "Usage: " << argv[0] << " <path-to-wc-file> <num-calls> <recurse>" << std::endl; std::cout << " " << argv[0] << " readme.txt 50 0" << std::endl; std::cout << " " << argv[0] << " ../Sources 1 1" << std::endl; return 1; } apr_initialize(); apr_pool_initialize(); apr_pool_t *m_pool; apr_pool_create( &m_pool, NULL ); svn_config_ensure( "", m_pool ); svn_client_ctx_t m_context; memset( &m_context, 0, sizeof( m_context ) ); // get the config based on the config dir passed in svn_config_get_config( &m_context.config, "", m_pool ); apr_pool_t *pool = svn_pool_create( NULL ); svn_opt_revision_t revision; revision.kind = svn_opt_revision_working; char *path = argv[1]; svn_boolean_t recurse = atoi( argv[3] ); int t0 = elapse_time(); int max_calls = atoi( argv[2] ); int i; for( i=0; i<max_calls; i++ ) { apr_array_header_t *props = NULL; svn_error_t *error = svn_client_proplist ( &props, path, &revision, recurse, &m_context, pool ); } int t1 = elapse_time(); int total = t1 - t0; std::cout << "Time for " << max_calls << " calls " << total << "ms recurse=" << recurse << std::endl; std::cout << "Time for " << 1 << " call " << total/max_calls << "ms recurse=" << recurse << std::endl; return 0; }