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 ); }
Py::Object pysvn_client::cmd_export( const Py::Tuple &a_args, const Py::Dict &a_kws ) { static argument_description args_desc[] = { { true, name_src_url_or_path }, { true, name_dest_path }, { false, name_force }, { false, name_revision }, #if defined( PYSVN_HAS_CLIENT_EXPORT2 ) { false, name_native_eol }, #endif #if defined( PYSVN_HAS_CLIENT_EXPORT3 ) { false, name_ignore_externals }, { false, name_recurse }, { false, name_peg_revision }, #endif #if defined( PYSVN_HAS_CLIENT_EXPORT4 ) { false, name_depth }, #endif { false, NULL } }; FunctionArguments args( "export", args_desc, a_args, a_kws ); args.check(); std::string src_path( args.getUtf8String( name_src_url_or_path ) ); std::string dest_path( args.getUtf8String( name_dest_path ) ); bool is_url = is_svn_url( src_path ); bool force = args.getBoolean( name_force, false ); svn_opt_revision_t revision; if( is_url ) revision = args.getRevision( name_revision, svn_opt_revision_head ); else revision = args.getRevision( name_revision, svn_opt_revision_working ); #if defined( PYSVN_HAS_CLIENT_EXPORT2 ) const char *native_eol = NULL; if( args.hasArg( name_native_eol ) ) { Py::Object native_eol_obj = args.getArg( name_native_eol ); if( native_eol_obj != Py::None() ) { Py::String eol_py_str( native_eol_obj ); std::string eol_str = eol_py_str.as_std_string( g_utf_8 ); if( eol_str == "CR" ) native_eol = "CR"; else if( eol_str == "CRLF" ) native_eol = "CRLF"; else if( eol_str == "LF" ) native_eol = "LF"; else throw Py::ValueError( "native_eol must be one of None, \"LF\", \"CRLF\" or \"CR\"" ); } } #endif #if defined( PYSVN_HAS_CLIENT_EXPORT3 ) #if defined( PYSVN_HAS_CLIENT_EXPORT4 ) svn_depth_t depth = args.getDepth( name_depth, name_recurse, svn_depth_infinity, svn_depth_infinity, svn_depth_files ); #else bool recurse = args.getBoolean( name_recurse, true ); #endif bool ignore_externals = args.getBoolean( name_ignore_externals, false ); svn_opt_revision_t peg_revision = args.getRevision( name_peg_revision, revision ); revisionKindCompatibleCheck( is_url, peg_revision, name_peg_revision, name_url_or_path ); #endif revisionKindCompatibleCheck( is_url, revision, name_revision, name_url_or_path ); svn_revnum_t revnum = 0; SvnPool pool( m_context ); try { std::string norm_src_path( svnNormalisedIfPath( src_path, pool ) ); checkThreadPermission(); PythonAllowThreads permission( m_context ); #if defined( PYSVN_HAS_CLIENT_EXPORT4 ) svn_error_t * error = svn_client_export4 ( &revnum, norm_src_path.c_str(), dest_path.c_str(), &peg_revision, &revision, force, ignore_externals, depth, native_eol, m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_EXPORT3 ) svn_error_t * error = svn_client_export3 ( &revnum, norm_src_path.c_str(), dest_path.c_str(), &peg_revision, &revision, force, ignore_externals, recurse, native_eol, m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_EXPORT2 ) svn_error_t * error = svn_client_export2 ( &revnum, norm_src_path.c_str(), dest_path.c_str(), &revision, force, native_eol, m_context, pool ); #else svn_error_t * error = svn_client_export ( &revnum, norm_src_path.c_str(), dest_path.c_str(), &revision, 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 ); } return Py::asObject( new pysvn_revision( svn_opt_revision_number, 0, revnum ) ); }
Py::Object pysvn_client::cmd_copy( 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_src_revision }, { false, NULL } }; FunctionArguments args( "copy", 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_path (arg 1)"; Py::String src_path( args.getUtf8String( name_src_url_or_path ) ); type_error_message = "expecting string for dest_path (arg 2)"; Py::String dest_path( args.getUtf8String( name_dest_url_or_path ) ); type_error_message = "expecting revision for keyword src_revision"; svn_opt_revision_t revision; if( is_svn_url( src_path ) ) revision = args.getRevision( name_src_revision, svn_opt_revision_head ); else revision = args.getRevision( name_src_revision, svn_opt_revision_working ); 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_COPY3 ) // behavior changed svn_error_t *error = svn_client_copy3 ( &commit_info, norm_src_path.c_str(), &revision, norm_dest_path.c_str(), m_context, pool ); #elif defined( PYSVN_HAS_CLIENT_COPY2 ) svn_error_t *error = svn_client_copy2 ( &commit_info, // commit info type changed norm_src_path.c_str(), &revision, norm_dest_path.c_str(), m_context, pool ); #else svn_error_t *error = svn_client_copy ( &commit_info, norm_src_path.c_str(), &revision, norm_dest_path.c_str(), 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 ); }