Exemple #1
0
  void
  Property::remove(const char * name)
  {
    Pool pool;

    svn_error_t * error =
      svn_client_propset(name,
                         NULL, // value = NULL
                         m_path.c_str(),
                         false, //dont recurse
                         pool);
    if (error != NULL)
      throw ClientException(error);
  }
Exemple #2
0
  /**
   * delete property in @a path no matter whether local or
   * repository
   *
   * @param path
   * @param revision
   * @param propName
   * @param propValue
   * @param recurse
   * @return PropertiesList
   */
  void
  Client::propdel(const char *propName,
                  const Path &path,
                  const Revision & /*revision*/,
                  bool recurse)
  {
    Pool pool;

    svn_error_t * error =
      svn_client_propset(propName,
                         nullptr, // value = NULL
                         path.c_str(),
                         recurse,
                         pool);
    if (error != nullptr)
      throw ClientException(error);
  }
Py::Object pysvn_client::cmd_propset( const Py::Tuple &a_args, const Py::Dict &a_kws )
{
    static argument_description args_desc[] =
    {
        { true,  name_prop_name },
        { true,  name_prop_value },
        { true,  name_url_or_path },
        { false, name_revision },
        { false, name_recurse },
#if defined( PYSVN_HAS_CLIENT_PROPSET2 )
        { false, name_skip_checks },
#endif
#if defined( PYSVN_HAS_CLIENT_PROPSET3 )
        { false, name_depth },
        { false, name_base_revision_for_url },
        { false, name_changelists },
        { false, name_revprops },
#endif
        { false, NULL }
    };
    FunctionArguments args( "propset", args_desc, a_args, a_kws );
    args.check();

    std::string propname( args.getUtf8String( name_prop_name ) );
    std::string propval( args.getUtf8String( name_prop_value ) );
    std::string path( args.getUtf8String( name_url_or_path ) );

    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 );

    SvnPool pool( m_context );

#if defined( PYSVN_HAS_CLIENT_PROPSET3 )
    apr_array_header_t *changelists = NULL;

    if( args.hasArg( name_changelists ) )
    {
        changelists = arrayOfStringsFromListOfStrings( args.getArg( name_changelists ), pool );
    }

    svn_revnum_t base_revision_for_url = args.getInteger( name_base_revision_for_url, 0 );
    svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_files, svn_depth_empty );

    apr_hash_t *revprops = NULL;
    if( args.hasArg( name_revprops ) )
    {
        Py::Object py_revprop = args.getArg( name_revprops );
        if( !py_revprop.isNone() )
        {
            revprops = hashOfStringsFromDistOfStrings( py_revprop, pool );
        }
    }
#else
    bool recurse = args.getBoolean( name_recurse, false );
#endif
#if defined( PYSVN_HAS_CLIENT_PROPSET2 )
    bool skip_checks = args.getBoolean( name_skip_checks, false );
#endif

#if defined( PYSVN_HAS_CLIENT_PROPSET3 )
    pysvn_commit_info_t *commit_info = NULL;
#endif

    try
    {
        std::string norm_path( svnNormalisedIfPath( path, pool ) );

        checkThreadPermission();

        PythonAllowThreads permission( m_context );

        const svn_string_t *svn_propval = svn_string_ncreate( propval.c_str(), propval.size(), pool );

#if defined( PYSVN_HAS_CLIENT_PROPSET3 )
        svn_error_t *error = svn_client_propset3
                             (
                                 &commit_info,
                                 propname.c_str(),
                                 svn_propval,
                                 norm_path.c_str(),
                                 depth,
                                 skip_checks,
                                 base_revision_for_url,
                                 changelists,
                                 revprops,
                                 m_context.ctx(),
                                 pool
                             );
#elif defined( PYSVN_HAS_CLIENT_PROPSET2 )
        svn_error_t *error = svn_client_propset2
                             (
                                 propname.c_str(),
                                 svn_propval,
                                 norm_path.c_str(),
                                 recurse,
                                 skip_checks,
                                 m_context.ctx(),
                                 pool
                             );
#else
        svn_error_t *error = svn_client_propset
                             (
                                 propname.c_str(),
                                 svn_propval,
                                 norm_path.c_str(),
                                 recurse,
                                 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 );
    }

#if defined( PYSVN_HAS_CLIENT_PROPSET3 )
    return toObject( commit_info );
#else
    return Py::None();
#endif
}