std::string Property::getValue(const char * name) { Pool pool; Revision revision; apr_hash_t *props; svn_client_propget(&props, name, m_path.c_str(), revision, false, // recurse *m_context, pool); apr_hash_index_t *hi; hi = apr_hash_first(pool, props); if (!hi) { return ""; } const void *key; void *val; const svn_string_t *propval; apr_hash_this(hi, &key, NULL, &val); propval = (const svn_string_t *)val; return propval->data; }
PathPropertiesMapList Client::propget(const char *propName, const Path &path, const Revision &revision, bool recurse) { Pool pool; apr_hash_t *props; svn_error_t * error = svn_client_propget(&props, propName, path.c_str(), revision.revision(), recurse, *m_context, pool); if (error != nullptr) { throw ClientException(error); } PathPropertiesMapList path_prop_map_list; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) { PropertiesMap prop_map; const void *key; void *val; apr_hash_this(hi, &key, nullptr, &val); prop_map [std::string(propName)] = std::string(((const svn_string_t *)val)->data); path_prop_map_list.push_back(PathPropertiesMapEntry((const char *)key, prop_map)); } return path_prop_map_list; }
Py::Object pysvn_client::cmd_propget( const Py::Tuple &a_args, const Py::Dict &a_kws ) { static argument_description args_desc[] = { { true, name_prop_name }, { true, name_url_or_path }, { false, name_revision }, { false, name_recurse }, #if defined( PYSVN_HAS_CLIENT_PROPGET2 ) { false, name_peg_revision }, #endif #if defined( PYSVN_HAS_CLIENT_PROPGET3 ) { false, name_depth }, { false, name_changelists }, #endif { false, NULL } }; FunctionArguments args( "propget", args_desc, a_args, a_kws ); args.check(); std::string propname( args.getUtf8String( name_prop_name ) ); std::string path( args.getUtf8String( name_url_or_path ) ); SvnPool pool( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPGET3 ) 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 svn_opt_revision_t revision; if( is_svn_url( path ) ) revision = args.getRevision( name_revision, svn_opt_revision_head ); else revision = args.getRevision( name_revision, svn_opt_revision_working ); #if defined( PYSVN_HAS_CLIENT_PROPGET2 ) svn_opt_revision_t peg_revision = args.getRevision( name_peg_revision, revision ); #endif bool is_url = is_svn_url( path ); #if defined( PYSVN_HAS_CLIENT_PROPGET2 ) revisionKindCompatibleCheck( is_url, peg_revision, name_peg_revision, name_url_or_path ); #endif revisionKindCompatibleCheck( is_url, revision, name_revision, name_url_or_path ); apr_hash_t *props = NULL; #if defined( PYSVN_HAS_CLIENT_PROPGET3 ) svn_revnum_t actual_revnum = 0; #endif try { std::string norm_path( svnNormalisedIfPath( path, pool ) ); checkThreadPermission(); PythonAllowThreads permission( m_context ); #if defined( PYSVN_HAS_CLIENT_PROPGET3 ) svn_error_t *error = svn_client_propget3 ( &props, propname.c_str(), norm_path.c_str(), &peg_revision, &revision, &actual_revnum, depth, changelists, m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_PROPGET2 ) svn_error_t *error = svn_client_propget2 ( &props, propname.c_str(), norm_path.c_str(), &peg_revision, &revision, recurse, m_context, pool ); #else svn_error_t *error = svn_client_propget ( &props, propname.c_str(), norm_path.c_str(), &revision, recurse, m_context, pool ); #endif permission.allowThisThread(); if( error != NULL ) throw SvnException( error ); } catch( SvnException &e ) { // use callback error over ClientException m_context.checkForError( m_module.client_error ); throw_client_error( e ); } return propsToObject( props, pool ); }
void Client::ignore(const Path & path) throw(ClientException) { static const char s_svnIgnore[] = "svn:ignore"; Pool pool; std::string dirpath, basename; path.split(dirpath, basename); Revision revision; apr_hash_t *props; svn_error_t * error = svn_client_propget(&props, s_svnIgnore, dirpath.c_str(), Revision::UNSPECIFIED.revision(), false, // recursive *m_context, pool); if (error != NULL) throw ClientException(error); PathPropertiesMapList path_prop_map_list; apr_hash_index_t *hi; for (hi = apr_hash_first(pool, props); hi; hi = apr_hash_next(hi)) { PropertiesMap prop_map; const void *key; void *val; apr_hash_this(hi, &key, NULL, &val); prop_map [std::string(s_svnIgnore)] = std::string(((const svn_string_t *)val)->data); path_prop_map_list.push_back(PathPropertiesMapEntry((const char *)key, prop_map)); } std::string str = basename; for (PathPropertiesMapList::const_iterator i=path_prop_map_list.begin(), ei=path_prop_map_list.end();i!=ei;++i) { if (dirpath != i->first) continue; for (PropertiesMap::const_iterator j=i->second.begin(), ej=i->second.end(); j != ej; ++j) { if (s_svnIgnore != j->first) continue; str += '\n'+j->second; } } const svn_string_t * propval = svn_string_create(str.c_str(), pool); error = svn_client_propset2(s_svnIgnore, propval, dirpath.c_str(), false, false, *m_context, pool); if (error != NULL) throw ClientException(error); }