File indexing completed on 2024-05-05 04:41:02
0001 /* 0002 SPDX-FileCopyrightText: 2007 Andreas Pakulat <apaku@gmx.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "svnupdatejob.h" 0008 #include "svnupdatejob_p.h" 0009 0010 #include <QMutexLocker> 0011 0012 #include <KLocalizedString> 0013 0014 #include "kdevsvncpp/client.hpp" 0015 #include "kdevsvncpp/path.hpp" 0016 #include "kdevsvncpp/targets.hpp" 0017 0018 0019 SvnInternalUpdateJob::SvnInternalUpdateJob( SvnJobBase* parent ) 0020 : SvnInternalJobBase( parent ) 0021 { 0022 } 0023 0024 void SvnInternalUpdateJob::run(ThreadWeaver::JobPointer /*self*/, ThreadWeaver::Thread* /*thread*/) 0025 { 0026 initBeforeRun(); 0027 0028 svn::Client cli(m_ctxt); 0029 std::vector<svn::Path> targets; 0030 const QList<QUrl> l = locations(); 0031 for (const QUrl& url : l) { 0032 QByteArray ba = url.toString( QUrl::PreferLocalFile | QUrl::StripTrailingSlash ).toUtf8(); 0033 targets.push_back( svn::Path( ba.data() ) ); 0034 } 0035 try 0036 { 0037 svn::Revision rev = createSvnCppRevisionFromVcsRevision( m_revision ); 0038 if( rev.kind() == svn_opt_revision_unspecified ) 0039 { 0040 m_success = false; 0041 return; 0042 } 0043 cli.update( svn::Targets( targets ), rev, recursive(), ignoreExternals() ); 0044 }catch( const svn::ClientException& ce ) 0045 { 0046 qCDebug(PLUGIN_SVN) << "Exception while updating files: " 0047 << m_locations 0048 << QString::fromUtf8( ce.message() ); 0049 setErrorMessage( QString::fromUtf8( ce.message() ) ); 0050 m_success = false; 0051 } 0052 } 0053 0054 void SvnInternalUpdateJob::setRecursive( bool recursive ) 0055 { 0056 QMutexLocker l( &m_mutex ); 0057 m_recursive = recursive; 0058 } 0059 0060 void SvnInternalUpdateJob::setLocations( const QList<QUrl>& urls ) 0061 { 0062 QMutexLocker l( &m_mutex ); 0063 m_locations = urls; 0064 } 0065 0066 0067 void SvnInternalUpdateJob::setIgnoreExternals( bool ignore ) 0068 { 0069 QMutexLocker l( &m_mutex ); 0070 m_ignoreExternals = ignore; 0071 } 0072 0073 bool SvnInternalUpdateJob::ignoreExternals() const 0074 { 0075 QMutexLocker l( &m_mutex ); 0076 return m_ignoreExternals; 0077 } 0078 0079 void SvnInternalUpdateJob::setRevision( const KDevelop::VcsRevision& rev ) 0080 { 0081 QMutexLocker l( &m_mutex ); 0082 m_revision = rev; 0083 } 0084 0085 QList<QUrl> SvnInternalUpdateJob::locations() const 0086 { 0087 QMutexLocker l( &m_mutex ); 0088 return m_locations; 0089 } 0090 0091 KDevelop::VcsRevision SvnInternalUpdateJob::revision() const 0092 { 0093 QMutexLocker l( &m_mutex ); 0094 return m_revision; 0095 } 0096 0097 bool SvnInternalUpdateJob::recursive() const 0098 { 0099 QMutexLocker l( &m_mutex ); 0100 return m_recursive; 0101 } 0102 0103 SvnUpdateJob::SvnUpdateJob( KDevSvnPlugin* parent ) 0104 : SvnJobBaseImpl(parent, KDevelop::OutputJob::Verbose ) 0105 { 0106 setType( KDevelop::VcsJob::Add ); 0107 setObjectName(i18n("Subversion Update")); 0108 } 0109 0110 QVariant SvnUpdateJob::fetchResults() 0111 { 0112 return QVariant(); 0113 } 0114 0115 void SvnUpdateJob::start() 0116 { 0117 if( m_job->locations().isEmpty() ) 0118 { 0119 internalJobFailed(); 0120 setErrorText( i18n( "Not enough Information to execute update" ) ); 0121 }else 0122 { 0123 qCDebug(PLUGIN_SVN) << "updating urls:" << m_job->locations(); 0124 startInternalJob(); 0125 } 0126 } 0127 0128 void SvnUpdateJob::setLocations( const QList<QUrl>& urls ) 0129 { 0130 if( status() == KDevelop::VcsJob::JobNotStarted ) 0131 m_job->setLocations( urls ); 0132 } 0133 0134 void SvnUpdateJob::setRecursive( bool recursive ) 0135 { 0136 if( status() == KDevelop::VcsJob::JobNotStarted ) 0137 m_job->setRecursive( recursive ); 0138 } 0139 0140 void SvnUpdateJob::setRevision( const KDevelop::VcsRevision& rev ) 0141 { 0142 if( status() == KDevelop::VcsJob::JobNotStarted ) 0143 m_job->setRevision( rev ); 0144 } 0145 0146 void SvnUpdateJob::setIgnoreExternals( bool ignore ) 0147 { 0148 if( status() == KDevelop::VcsJob::JobNotStarted ) 0149 m_job->setIgnoreExternals( ignore ); 0150 } 0151 0152 #include "moc_svnupdatejob_p.cpp" 0153 #include "moc_svnupdatejob.cpp"