static int l_move (lua_State *L) { const char *src_path = luaL_checkstring (L, 1); const char *dest_path = luaL_checkstring (L, 2); const char *message = (lua_gettop (L) < 3 || lua_isnil (L, 3)) ? "" : luaL_checkstring (L, 3); apr_pool_t *pool; svn_error_t *err; svn_client_ctx_t *ctx; init_function (&ctx, &pool, L); src_path = svn_path_canonicalize (src_path, pool); dest_path = svn_path_canonicalize (dest_path, pool); svn_commit_info_t *commit_info = NULL; if (svn_path_is_url (dest_path)) { make_log_msg_baton (&(ctx->log_msg_baton2), message, NULL, ctx->config, pool, L); ctx->log_msg_func2 = log_msg_func2; } err = svn_client_move4 (&commit_info, src_path, dest_path, FALSE, ctx, pool); IF_ERROR_RETURN (err, pool, L); if (commit_info == NULL) { lua_pushnil (L); } else { lua_pushinteger (L, commit_info->revision); } svn_pool_destroy (pool); return 1; }
Py::Object pysvn_client::cmd_move( const Py::Tuple &a_args, const Py::Dict &a_kws ) { static argument_description args_desc[] = { { true, name_src_url_or_path }, { true, name_dest_url_or_path }, { false, name_force }, { false, NULL } }; FunctionArguments args( "move", args_desc, a_args, a_kws ); args.check(); SvnPool pool( m_context ); pysvn_commit_info_t *commit_info = NULL; std::string type_error_message; try { type_error_message = "expecting string for src_url_or_path (arg 1)"; Py::String src_path( args.getUtf8String( name_src_url_or_path ) ); type_error_message = "expecting string for dest_url_or_path (arg 2)"; Py::String dest_path( args.getUtf8String( name_dest_url_or_path ) ); #ifndef PYSVN_HAS_CLIENT_MOVE2 svn_opt_revision_t revision; revision.kind = svn_opt_revision_head; #endif type_error_message = "expecting boolean for keyword force"; bool force = args.getBoolean( name_force, false ); try { std::string norm_src_path( svnNormalisedIfPath( src_path, pool ) ); std::string norm_dest_path( svnNormalisedIfPath( dest_path, pool ) ); checkThreadPermission(); PythonAllowThreads permission( m_context ); #if defined( PYSVN_HAS_CLIENT_MOVE4 ) // behavior changed svn_error_t *error = svn_client_move4 ( &commit_info, norm_src_path.c_str(), norm_dest_path.c_str(), force, m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_MOVE3 ) svn_error_t *error = svn_client_move3 ( &commit_info, // changed type norm_src_path.c_str(), norm_dest_path.c_str(), force, m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_MOVE2 ) svn_error_t *error = svn_client_move2 ( &commit_info, norm_src_path.c_str(), norm_dest_path.c_str(), force, m_context, pool ); #else svn_error_t *error = svn_client_move ( &commit_info, norm_src_path.c_str(), &revision, norm_dest_path.c_str(), force, 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 ); } } catch( Py::TypeError & ) { throw Py::TypeError( type_error_message ); } return toObject( commit_info ); }