1 /***************************************************************************
2 * This file is part of KDevelop *
3 * Copyright 2007 Andreas Pakulat <apaku@gmx.de> *
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. *
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. *
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>
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()
44 svn::Client
cli(m_ctxt
);
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() ) );
66 void SvnInternalCheckoutJob::setMapping( const KDevelop::VcsMapping
& mapping
)
68 QMutexLocker
l( m_mutex
);
72 KDevelop::VcsMapping
SvnInternalCheckoutJob::mapping() const
74 QMutexLocker
l( m_mutex
);
78 SvnCheckoutJob::SvnCheckoutJob( KDevSvnPlugin
* parent
)
79 : SvnJobBase( parent
)
81 setType( KDevelop::VcsJob::Import
);
82 m_job
= new SvnInternalCheckoutJob( this );
85 QVariant
SvnCheckoutJob::fetchResults()
90 void SvnCheckoutJob::start()
92 if( m_job
->mapping().sourceLocations().isEmpty() )
94 internalJobFailed( m_job
);
95 setErrorText( i18n( "Not enough information to checkout" ) );
98 kDebug(9510) << "checking out:" << m_job
->mapping().sourceLocations().first().repositoryServer();
99 ThreadWeaver::Weaver::instance()->enqueue( m_job
);
103 SvnInternalJobBase
* SvnCheckoutJob::internalJob() const
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"