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 "svnlogjob.h" 0008 #include "svnlogjob_p.h" 0009 0010 #include <QMutexLocker> 0011 0012 #include <KLocalizedString> 0013 0014 #include "svnclient.h" 0015 0016 SvnInternalLogJob::SvnInternalLogJob( SvnJobBase* parent ) 0017 : SvnInternalJobBase( parent ) 0018 { 0019 m_endRevision.setRevisionValue(QVariant::fromValue(KDevelop::VcsRevision::Start), 0020 KDevelop::VcsRevision::Special ); 0021 m_startRevision.setRevisionValue(QVariant::fromValue(KDevelop::VcsRevision::Head), 0022 KDevelop::VcsRevision::Special ); 0023 m_limit = 0; 0024 } 0025 0026 void SvnInternalLogJob::run(ThreadWeaver::JobPointer /*self*/, ThreadWeaver::Thread* /*thread*/) 0027 { 0028 initBeforeRun(); 0029 0030 SvnClient cli(m_ctxt); 0031 connect( &cli, &SvnClient::logEventReceived, 0032 this, &SvnInternalLogJob::logEvent ); 0033 try 0034 { 0035 QByteArray ba = location().toString( QUrl::PreferLocalFile | QUrl::StripTrailingSlash ).toUtf8(); 0036 cli.log( ba.data(), 0037 createSvnCppRevisionFromVcsRevision( startRevision() ), 0038 createSvnCppRevisionFromVcsRevision( endRevision() ), 0039 limit() ); 0040 }catch( const svn::ClientException& ce ) 0041 { 0042 qCDebug(PLUGIN_SVN) << "Exception while logging file: " 0043 << location() 0044 << QString::fromUtf8( ce.message() ); 0045 setErrorMessage( QString::fromUtf8( ce.message() ) ); 0046 m_success = false; 0047 } 0048 } 0049 0050 void SvnInternalLogJob::setLocation( const QUrl &url ) 0051 { 0052 QMutexLocker l( &m_mutex ); 0053 m_location = url; 0054 } 0055 0056 QUrl SvnInternalLogJob::location() const 0057 { 0058 QMutexLocker l( &m_mutex ); 0059 return m_location; 0060 } 0061 0062 KDevelop::VcsRevision SvnInternalLogJob::startRevision() const 0063 { 0064 QMutexLocker l( &m_mutex ); 0065 return m_startRevision; 0066 } 0067 0068 KDevelop::VcsRevision SvnInternalLogJob::endRevision() const 0069 { 0070 QMutexLocker l( &m_mutex ); 0071 return m_endRevision; 0072 } 0073 0074 int SvnInternalLogJob::limit() const 0075 { 0076 QMutexLocker l( &m_mutex ); 0077 return m_limit; 0078 } 0079 0080 void SvnInternalLogJob::setStartRevision( const KDevelop::VcsRevision& rev ) 0081 { 0082 QMutexLocker l( &m_mutex ); 0083 m_startRevision = rev; 0084 } 0085 0086 void SvnInternalLogJob::setEndRevision( const KDevelop::VcsRevision& rev ) 0087 { 0088 QMutexLocker l( &m_mutex ); 0089 m_endRevision = rev; 0090 } 0091 0092 void SvnInternalLogJob::setLimit( int limit ) 0093 { 0094 QMutexLocker l( &m_mutex ); 0095 m_limit = limit; 0096 } 0097 0098 SvnLogJob::SvnLogJob( KDevSvnPlugin* parent ) 0099 : SvnJobBaseImpl( parent, KDevelop::OutputJob::Silent ) 0100 { 0101 setType( KDevelop::VcsJob::Log ); 0102 connect( m_job.data(), &SvnInternalLogJob::logEvent, 0103 this, &SvnLogJob::logEventReceived ); 0104 0105 setObjectName(i18n("Subversion Log")); 0106 } 0107 0108 QVariant SvnLogJob::fetchResults() 0109 { 0110 QList<QVariant> list = m_eventList; 0111 m_eventList.clear(); 0112 return list; 0113 } 0114 0115 void SvnLogJob::start() 0116 { 0117 if( !m_job->location().isValid() ) 0118 { 0119 internalJobFailed(); 0120 setErrorText( i18n( "Not enough information to log location" ) ); 0121 }else 0122 { 0123 qCDebug(PLUGIN_SVN) << "logging url:" << m_job->location(); 0124 startInternalJob(); 0125 } 0126 } 0127 0128 void SvnLogJob::setLocation( const QUrl &url ) 0129 { 0130 if( status() == KDevelop::VcsJob::JobNotStarted ) 0131 m_job->setLocation( url ); 0132 } 0133 0134 void SvnLogJob::setStartRevision( const KDevelop::VcsRevision& rev ) 0135 { 0136 if( status() == KDevelop::VcsJob::JobNotStarted ) 0137 m_job->setStartRevision( rev ); 0138 } 0139 0140 void SvnLogJob::setEndRevision( const KDevelop::VcsRevision& rev ) 0141 { 0142 if( status() == KDevelop::VcsJob::JobNotStarted ) 0143 m_job->setEndRevision( rev ); 0144 } 0145 0146 void SvnLogJob::setLimit( int limit ) 0147 { 0148 if( status() == KDevelop::VcsJob::JobNotStarted ) 0149 m_job->setLimit( limit ); 0150 } 0151 0152 void SvnLogJob::logEventReceived( const KDevelop::VcsEvent& ev ) 0153 { 0154 m_eventList << QVariant::fromValue(ev); 0155 emit resultsReady( this ); 0156 } 0157 0158 #include "moc_svnlogjob_p.cpp" 0159 #include "moc_svnlogjob.cpp"