Don't keep compiling/run if something failed.
[kdevelopdvcssupport.git] / plugins / subversion / svncheckoutjob.cpp
blob578b321b0c0b4b6a30b9a3655ce68a0ccb980f4a
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 "svncheckoutjob.h"
22 #include "svncheckoutjob_p.h"
24 #include <QMutexLocker>
26 #include <klocale.h>
27 #include <kdebug.h>
28 #include <ThreadWeaver.h>
30 #include "kdevsvncpp/client.hpp"
31 #include "kdevsvncpp/path.hpp"
33 #include <vcs/vcslocation.h>
35 SvnInternalCheckoutJob::SvnInternalCheckoutJob( SvnJobBase* parent )
36 : SvnInternalJobBase( parent )
40 void SvnInternalCheckoutJob::run()
42 initBeforeRun();
44 svn::Client cli(m_ctxt);
45 try
47 KDevelop::VcsMapping map = mapping();
48 KDevelop::VcsLocation src = map.sourceLocations().first();
49 KDevelop::VcsLocation dest = map.destinationLocation( src );
50 bool recurse = ( map.mappingFlag( src ) == KDevelop::VcsMapping::Recursive );
51 QByteArray srcba = src.repositoryServer().toUtf8();
52 QByteArray destba = dest.localUrl().toLocalFile().toUtf8();
53 kDebug(9510) << srcba << destba;
54 cli.checkout( srcba.data(), svn::Path( destba.data() ), svn::Revision(svn::Revision::HEAD), recurse );
55 }catch( svn::ClientException ce )
57 kDebug(9510) << "Exception while checking out: "
58 << mapping().sourceLocations().first().repositoryServer()
59 << QString::fromUtf8( ce.message() );
60 setErrorMessage( QString::fromUtf8( ce.message() ) );
61 m_success = false;
66 void SvnInternalCheckoutJob::setMapping( const KDevelop::VcsMapping& mapping )
68 QMutexLocker l( m_mutex );
69 m_mapping = mapping;
72 KDevelop::VcsMapping SvnInternalCheckoutJob::mapping() const
74 QMutexLocker l( m_mutex );
75 return m_mapping;
78 SvnCheckoutJob::SvnCheckoutJob( KDevSvnPlugin* parent )
79 : SvnJobBase( parent )
81 setType( KDevelop::VcsJob::Import );
82 m_job = new SvnInternalCheckoutJob( this );
85 QVariant SvnCheckoutJob::fetchResults()
87 return QVariant();
90 void SvnCheckoutJob::start()
92 if( m_job->mapping().sourceLocations().isEmpty() )
94 internalJobFailed( m_job );
95 setErrorText( i18n( "Not enough information to checkout" ) );
96 }else
98 kDebug(9510) << "checking out:" << m_job->mapping().sourceLocations().first().repositoryServer();
99 ThreadWeaver::Weaver::instance()->enqueue( m_job );
103 SvnInternalJobBase* SvnCheckoutJob::internalJob() const
105 return m_job;
108 void SvnCheckoutJob::setMapping( const KDevelop::VcsMapping& mapping )
110 if( status() == KDevelop::VcsJob::JobNotStarted )
111 m_job->setMapping( mapping );
115 #include "svncheckoutjob.moc"
116 #include "svncheckoutjob_p.moc"