Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / subversion / svnlogjob.cpp
blob59eaa41c1504d9fd878b6f0af33e6df32a5eaf98
1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Library General Public License as *
7 * published by the Free Software Foundation; either version 2 of the *
8 * License, or (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Library General Public *
16 * License along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
21 #include "svnlogjob.h"
22 #include "svnlogjob_p.h"
24 #include <QMutexLocker>
26 #include <klocale.h>
27 #include <kdebug.h>
28 #include <ThreadWeaver.h>
30 #include "svnclient.h"
32 SvnInternalLogJob::SvnInternalLogJob( SvnJobBase* parent )
33 : SvnInternalJobBase( parent )
35 m_endRevision.setRevisionValue( qVariantFromValue( KDevelop::VcsRevision::Start ),
36 KDevelop::VcsRevision::Special );
37 m_startRevision.setRevisionValue( qVariantFromValue( KDevelop::VcsRevision::Head ),
38 KDevelop::VcsRevision::Special );
39 m_limit = 0;
42 void SvnInternalLogJob::run()
44 initBeforeRun();
46 SvnClient cli(m_ctxt);
47 connect( &cli, SIGNAL( logEventReceived( const KDevelop::VcsEvent& ) ),
48 this, SIGNAL(logEvent( const KDevelop::VcsEvent&) ) );
49 try
51 QByteArray ba = location().path().toUtf8();
52 cli.log( ba.data(),
53 createSvnCppRevisionFromVcsRevision( startRevision() ),
54 createSvnCppRevisionFromVcsRevision( endRevision() ),
55 limit() );
56 }catch( svn::ClientException ce )
58 kDebug(9510) << "Exception while logging file: "
59 << location()
60 << QString::fromUtf8( ce.message() );
61 setErrorMessage( QString::fromUtf8( ce.message() ) );
62 m_success = false;
66 void SvnInternalLogJob::setLocation( const KUrl& url )
68 QMutexLocker l( m_mutex );
69 m_location = url;
72 KUrl SvnInternalLogJob::location() const
74 QMutexLocker l( m_mutex );
75 return m_location;
78 KDevelop::VcsRevision SvnInternalLogJob::startRevision() const
80 QMutexLocker l( m_mutex );
81 return m_startRevision;
84 KDevelop::VcsRevision SvnInternalLogJob::endRevision() const
86 QMutexLocker l( m_mutex );
87 return m_endRevision;
90 int SvnInternalLogJob::limit() const
92 QMutexLocker l( m_mutex );
93 return m_limit;
96 void SvnInternalLogJob::setStartRevision( const KDevelop::VcsRevision& rev )
98 QMutexLocker l( m_mutex );
99 m_startRevision = rev;
102 void SvnInternalLogJob::setEndRevision( const KDevelop::VcsRevision& rev )
104 QMutexLocker l( m_mutex );
105 m_endRevision = rev;
108 void SvnInternalLogJob::setLimit( int limit )
110 QMutexLocker l( m_mutex );
111 m_limit = limit;
114 SvnLogJob::SvnLogJob( KDevSvnPlugin* parent )
115 : SvnJobBase( parent )
117 setType( KDevelop::VcsJob::Log );
118 m_job = new SvnInternalLogJob( this );
121 QVariant SvnLogJob::fetchResults()
123 QList<QVariant> list = m_eventList;
124 m_eventList.clear();
125 return list;
128 void SvnLogJob::start()
130 if( !m_job->location().isValid() )
132 internalJobFailed( m_job );
133 setErrorText( i18n( "Not enough information to log location" ) );
134 }else
136 connect( m_job, SIGNAL(logEvent(const KDevelop::VcsEvent&)),
137 this, SLOT(logEventReceived(const KDevelop::VcsEvent&)), Qt::QueuedConnection );
138 kDebug(9510) << "logging url:" << m_job->location();
139 ThreadWeaver::Weaver::instance()->enqueue( m_job );
143 SvnInternalJobBase* SvnLogJob::internalJob() const
145 return m_job;
148 void SvnLogJob::setLocation( const KUrl& url )
150 if( status() == KDevelop::VcsJob::JobNotStarted )
151 m_job->setLocation( url );
154 void SvnLogJob::setStartRevision( const KDevelop::VcsRevision& rev )
156 if( status() == KDevelop::VcsJob::JobNotStarted )
157 m_job->setStartRevision( rev );
160 void SvnLogJob::setEndRevision( const KDevelop::VcsRevision& rev )
162 if( status() == KDevelop::VcsJob::JobNotStarted )
163 m_job->setEndRevision( rev );
166 void SvnLogJob::setLimit( int limit )
168 if( status() == KDevelop::VcsJob::JobNotStarted )
169 m_job->setLimit( limit );
172 void SvnLogJob::logEventReceived( const KDevelop::VcsEvent& ev )
174 m_eventList << qVariantFromValue( ev );
175 emit resultsReady( this );
178 #include "svnlogjob.moc"
179 #include "svnlogjob_p.moc"