Py::Object pysvn_client::cmd_revproplist( const Py::Tuple &a_args, const Py::Dict &a_kws )
{
    static argument_description args_desc[] =
    {
    { true,  name_url },
    { false, name_revision },
    { false, NULL }
    };
    FunctionArguments args( "revproplist", args_desc, a_args, a_kws );
    args.check();

    std::string path( args.getUtf8String( name_url ) );
    svn_opt_revision_t revision = args.getRevision( name_revision, svn_opt_revision_head );

    SvnPool pool( m_context );

    apr_hash_t *props = NULL;
    svn_revnum_t revnum = 0;

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

        checkThreadPermission();

        PythonAllowThreads permission( m_context );

        svn_error_t *error = svn_client_revprop_list
            (
            &props,
            norm_path.c_str(),
            &revision,
            &revnum,
            m_context,
            pool
            );
        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 );
    }


    Py::Tuple result(2);
    result[0] = Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, revnum ) );
    result[1] = propsToObject( props, pool );

    return result;
}
Example #2
0
void proplistToObject( Py::List &py_path_propmap_list, apr_array_header_t *props, SvnPool &pool )
{
    for (int j = 0; j < props->nelts; ++j)
    {
        svn_client_proplist_item_t *item = ((svn_client_proplist_item_t **)props->elts)[j];

        Py::Object py_prop_dict( propsToObject( item->prop_hash, pool ) );

        std::string node_name( item->node_name->data, item->node_name->len );

        Py::Tuple py_path_proplist( 2 );
        py_path_proplist[0] = Py::String( osNormalisedPath( node_name, pool ) );
        py_path_proplist[1] = py_prop_dict;

        py_path_propmap_list.append( py_path_proplist );
    }
}
Example #3
0
    svn_error_t *proplist_receiver_c
    (
        void *baton_,
        const char *path,
        apr_hash_t *prop_hash,
        apr_pool_t *pool
    )
    {
        ProplistReceiveBaton *baton = reinterpret_cast<ProplistReceiveBaton *>( baton_ );

        PythonDisallowThreads callback_permission( baton->m_permission );

        Py::Dict prop_dict;

        Py::Tuple py_tuple( 2 );
        py_tuple[0] = Py::String( path );
        py_tuple[1] = propsToObject( prop_hash, baton->m_pool );

        baton->m_prop_list.append( py_tuple );

        return SVN_NO_ERROR;
    }
Example #4
0
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 );
}
Example #5
0
static svn_error_t *log4Receiver
    (
    void *baton_,
    svn_log_entry_t *log_entry,
    apr_pool_t *pool
    )
{
    Log4Baton *baton = reinterpret_cast<Log4Baton *>( baton_ );

    if( log_entry->revision == 0 )
    {
        // skip this blank entry
        // as the svn log command does
        return NULL;
    }

    PythonDisallowThreads callback_permission( baton->m_permission );

    Py::Dict entry_dict;

    Py::Object revprops;
    if( log_entry->revprops == NULL )
    {
        revprops = Py::None();
    }
    else
    {
        revprops = propsToObject( log_entry->revprops, baton->m_pool );
        Py::Dict revprops_dict;
        revprops_dict = revprops;

        if( revprops_dict.hasKey( "svn:date" ) )
        {
            Py::String date( revprops_dict[ "svn:date" ] );
            Py::Object int_date = toObject( convertStringToTime( date.as_std_string( g_utf_8 ), baton->m_now, baton->m_pool ) );
            revprops_dict[ "svn:date" ] = int_date;
            entry_dict[ name_date ] = int_date;
        }
        if( revprops_dict.hasKey( "svn:author" ) )
        {
            entry_dict[ name_author ] = revprops_dict[ "svn:author" ];
        }
        if( revprops_dict.hasKey( "svn:log" ) )
        {
            Py::String message( revprops_dict[ "svn:log" ] );
            revprops_dict[ "svn:log" ] = message;
            entry_dict[ name_message ] = message;
        }
    }
    entry_dict[ name_revprops ] = revprops;
    entry_dict[ name_revision ] = Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, log_entry->revision ) );

    Py::List changed_paths_list;
#if defined( PYSVN_HAS_CLIENT_LOG5 )
    if( log_entry->changed_paths2 != NULL )
    {
        for( apr_hash_index_t *hi = apr_hash_first( pool, log_entry->changed_paths2 );
                hi != NULL;
                    hi = apr_hash_next( hi ) )
        {
            Py::Dict changed_entry_dict;

            char *path = NULL;
            void *val = NULL;
            apr_hash_this( hi, (const void **) &path, NULL, &val );

            svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *> (val);

            changed_entry_dict[ name_path ] = Py::String( path );

            char action[2]; action[0] = log_item->action; action[1] = 0;
            changed_entry_dict[ name_action ] = Py::String( action );

            changed_entry_dict[ name_copyfrom_path ] = utf8_string_or_none( log_item->copyfrom_path );

            if( SVN_IS_VALID_REVNUM( log_item->copyfrom_rev ) )
                changed_entry_dict[ name_copyfrom_revision ] =
                    Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, log_item->copyfrom_rev ) );
            else
                changed_entry_dict[ name_copyfrom_revision ] = Py::None();

            changed_paths_list.append( baton->m_wrapper_log_changed_path->wrapDict( changed_entry_dict ) );
        }
    }
#else
    if( log_entry->changed_paths != NULL )
    {
        for( apr_hash_index_t *hi = apr_hash_first( pool, log_entry->changed_paths );
                hi != NULL;
                    hi = apr_hash_next( hi ) )
        {
            Py::Dict changed_entry_dict;

            char *path = NULL;
            void *val = NULL;
            apr_hash_this( hi, (const void **) &path, NULL, &val );

            svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *> (val);

            changed_entry_dict[ name_path ] = Py::String( path );

            char action[2]; action[0] = log_item->action; action[1] = 0;
            changed_entry_dict[ name_action ] = Py::String( action );

            changed_entry_dict[ name_copyfrom_path ] = utf8_string_or_none( log_item->copyfrom_path );

            if( SVN_IS_VALID_REVNUM( log_item->copyfrom_rev ) )
                changed_entry_dict[ name_copyfrom_revision ] =
                    Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, log_item->copyfrom_rev ) );
            else
                changed_entry_dict[ name_copyfrom_revision ] = Py::None();

            changed_paths_list.append( baton->m_wrapper_log_changed_path->wrapDict( changed_entry_dict ) );
        }
    }
#endif

    entry_dict[ name_changed_paths ] = changed_paths_list;
    entry_dict[ "has_children" ] = Py::Int( log_entry->has_children != 0 ? 1 : 0 );

    baton->m_log_list.append( baton->m_wrapper_log->wrapDict( entry_dict ) );

    return NULL;
}