File indexing completed on 2024-05-05 16:47:01
0001 /* 0002 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "svnmovejob.h" 0008 #include "svnmovejob_p.h" 0009 0010 #include <QMutexLocker> 0011 0012 #include <KLocalizedString> 0013 0014 #include "kdevsvncpp/client.hpp" 0015 #include "kdevsvncpp/path.hpp" 0016 0017 SvnInternalMoveJob::SvnInternalMoveJob( SvnJobBase* parent ) 0018 : SvnInternalJobBase( parent ) 0019 { 0020 } 0021 0022 void SvnInternalMoveJob::run(ThreadWeaver::JobPointer /*self*/, ThreadWeaver::Thread* /*thread*/) 0023 { 0024 initBeforeRun(); 0025 0026 svn::Client cli(m_ctxt); 0027 try 0028 { 0029 QByteArray srcba = sourceLocation().toString( QUrl::PreferLocalFile | QUrl::StripTrailingSlash ).toUtf8(); 0030 QByteArray dstba = destinationLocation().toString( QUrl::PreferLocalFile | QUrl::StripTrailingSlash ).toUtf8(); 0031 cli.move( svn::Path( srcba.data() ), svn::Revision(), svn::Path( dstba.data() ), force() ); 0032 }catch( const svn::ClientException& ce ) 0033 { 0034 qCDebug(PLUGIN_SVN) << "Exception while moving file: " 0035 << sourceLocation() << "to" << destinationLocation() 0036 << QString::fromUtf8( ce.message() ); 0037 setErrorMessage( QString::fromUtf8( ce.message() ) ); 0038 m_success = false; 0039 } 0040 } 0041 0042 0043 void SvnInternalMoveJob::setDestinationLocation( const QUrl &url ) 0044 { 0045 QMutexLocker l( &m_mutex ); 0046 m_destinationLocation = url; 0047 } 0048 0049 QUrl SvnInternalMoveJob::destinationLocation() const 0050 { 0051 QMutexLocker l( &m_mutex ); 0052 return m_destinationLocation; 0053 } 0054 0055 void SvnInternalMoveJob::setSourceLocation( const QUrl &url ) 0056 { 0057 QMutexLocker l( &m_mutex ); 0058 m_sourceLocation = url; 0059 } 0060 0061 QUrl SvnInternalMoveJob::sourceLocation() const 0062 { 0063 QMutexLocker l( &m_mutex ); 0064 return m_sourceLocation; 0065 } 0066 0067 bool SvnInternalMoveJob::force() const 0068 { 0069 QMutexLocker l( &m_mutex ); 0070 return m_force; 0071 } 0072 0073 void SvnInternalMoveJob::setForce( bool force ) 0074 { 0075 QMutexLocker l( &m_mutex ); 0076 m_force = force; 0077 } 0078 0079 SvnMoveJob::SvnMoveJob( KDevSvnPlugin* parent ) 0080 : SvnJobBaseImpl( parent, KDevelop::OutputJob::Silent ) 0081 { 0082 setType( KDevelop::VcsJob::Move ); 0083 setObjectName(i18n("Subversion Move")); 0084 } 0085 0086 QVariant SvnMoveJob::fetchResults() 0087 { 0088 return QVariant(); 0089 } 0090 0091 void SvnMoveJob::start() 0092 { 0093 if ( m_job->sourceLocation().isEmpty() || m_job->destinationLocation().isEmpty() ) { 0094 internalJobFailed(); 0095 setErrorText( i18n( "Not enough information to move file" ) ); 0096 } else { 0097 qCDebug(PLUGIN_SVN) << "moving url:" << m_job->sourceLocation() << "to url" << m_job->destinationLocation(); 0098 startInternalJob(); 0099 } 0100 } 0101 0102 void SvnMoveJob::setDestinationLocation( const QUrl &url ) 0103 { 0104 if( status() == KDevelop::VcsJob::JobNotStarted ) 0105 m_job->setDestinationLocation( url ); 0106 } 0107 0108 void SvnMoveJob::setSourceLocation( const QUrl &url ) 0109 { 0110 if( status() == KDevelop::VcsJob::JobNotStarted ) 0111 m_job->setSourceLocation( url ); 0112 } 0113 0114 void SvnMoveJob::setForce( bool force ) 0115 { 0116 if( status() == KDevelop::VcsJob::JobNotStarted ) 0117 m_job->setForce( force ); 0118 } 0119 0120 #include "moc_svnmovejob_p.cpp" 0121 #include "moc_svnmovejob.cpp"