File indexing completed on 2024-05-05 04:41: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 "svncopyjob.h" 0008 #include "svncopyjob_p.h" 0009 0010 #include <QMutexLocker> 0011 0012 #include <KLocalizedString> 0013 0014 #include "kdevsvncpp/client.hpp" 0015 #include "kdevsvncpp/path.hpp" 0016 0017 SvnInternalCopyJob::SvnInternalCopyJob( SvnJobBase* parent ) 0018 : SvnInternalJobBase( parent ) 0019 { 0020 } 0021 0022 void SvnInternalCopyJob::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.copy( svn::Path( srcba.data() ), svn::Revision(), svn::Path( dstba.data() ) ); 0032 }catch( const svn::ClientException& ce ) 0033 { 0034 qCDebug(PLUGIN_SVN) << "Exception while copying 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 SvnInternalCopyJob::setDestinationLocation( const QUrl &url ) 0044 { 0045 QMutexLocker l( &m_mutex ); 0046 m_destinationLocation = url; 0047 } 0048 0049 QUrl SvnInternalCopyJob::destinationLocation() const 0050 { 0051 QMutexLocker l( &m_mutex ); 0052 return m_destinationLocation; 0053 } 0054 0055 void SvnInternalCopyJob::setSourceLocation( const QUrl &url ) 0056 { 0057 QMutexLocker l( &m_mutex ); 0058 m_sourceLocation = url; 0059 } 0060 0061 QUrl SvnInternalCopyJob::sourceLocation() const 0062 { 0063 QMutexLocker l( &m_mutex ); 0064 return m_sourceLocation; 0065 } 0066 0067 SvnCopyJob::SvnCopyJob( KDevSvnPlugin* parent ) 0068 : SvnJobBaseImpl( parent, KDevelop::OutputJob::Silent ) 0069 { 0070 setType( KDevelop::VcsJob::Copy ); 0071 setObjectName(i18n("Subversion Copy")); 0072 } 0073 0074 QVariant SvnCopyJob::fetchResults() 0075 { 0076 return QVariant(); 0077 } 0078 0079 void SvnCopyJob::start() 0080 { 0081 if ( m_job->sourceLocation().isEmpty() || m_job->destinationLocation().isEmpty() ) { 0082 internalJobFailed(); 0083 setErrorText( i18n( "Not enough information to copy file" ) ); 0084 } else { 0085 qCDebug(PLUGIN_SVN) << "copying url:" << m_job->sourceLocation() << "to url" << m_job->destinationLocation(); 0086 startInternalJob(); 0087 } 0088 } 0089 0090 void SvnCopyJob::setDestinationLocation( const QUrl &url ) 0091 { 0092 if( status() == KDevelop::VcsJob::JobNotStarted ) 0093 m_job->setDestinationLocation( url ); 0094 } 0095 0096 void SvnCopyJob::setSourceLocation( const QUrl &url ) 0097 { 0098 if( status() == KDevelop::VcsJob::JobNotStarted ) 0099 m_job->setSourceLocation( url ); 0100 } 0101 0102 #include "moc_svncopyjob.cpp" 0103 #include "moc_svncopyjob_p.cpp"