File indexing completed on 2024-05-12 05:44:23

0001 /***************************************************************************
0002  *   Copyright (C) 2005-2009 by Rajko Albrecht  ral@alwins-world.de        *
0003  *   https://kde.org/applications/development/org.kde.kdesvn               *
0004  *                                                                         *
0005  *   This program is free software; you can redistribute it and/or modify  *
0006  *   it under the terms of the GNU General Public License as published by  *
0007  *   the Free Software Foundation; either version 2 of the License, or     *
0008  *   (at your option) any later version.                                   *
0009  *                                                                         *
0010  *   This program is distributed in the hope that it will be useful,       *
0011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0013  *   GNU General Public License for more details.                          *
0014  *                                                                         *
0015  *   You should have received a copy of the GNU General Public License     *
0016  *   along with this program; if not, write to the                         *
0017  *   Free Software Foundation, Inc.,                                       *
0018  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0019  ***************************************************************************/
0020 
0021 #include "svnthread.h"
0022 #include "tcontextlistener.h"
0023 
0024 #include "svnqt/url.h"
0025 
0026 SvnThread::SvnThread(QObject *_parent)
0027     : QThread()
0028     , m_CurrentContext(new svn::Context)
0029     , m_Svnclient(svn::Client::getobject(m_CurrentContext))
0030     , m_SvnContextListener(new ThreadContextListener(_parent))
0031     , m_Parent(_parent)
0032 {
0033     if (m_Parent) {
0034         QObject::connect(m_SvnContextListener, SIGNAL(sendNotify(QString)), m_Parent, SLOT(slotNotifyMessage(QString)));
0035     }
0036 
0037     m_CurrentContext->setListener(m_SvnContextListener);
0038 }
0039 
0040 SvnThread::~SvnThread()
0041 {
0042     m_CurrentContext->setListener(nullptr);
0043     delete m_SvnContextListener;
0044 }
0045 
0046 void SvnThread::cancelMe()
0047 {
0048     m_SvnContextListener->setCanceled(true);
0049 }
0050 
0051 void SvnThread::itemInfo(const QString &what, svn::InfoEntry &target, const svn::Revision &_rev, const svn::Revision &_peg)
0052 {
0053     QString url, cacheKey;
0054     svn::Revision rev = _rev;
0055     svn::Revision peg = _peg;
0056 
0057     if (!svn::Url::isValid(what)) {
0058         // working copy
0059         // url = svn::Wc::getUrl(what);
0060         url = what;
0061         if (url.contains(QLatin1Char('@'))) {
0062             url += QStringLiteral("@BASE");
0063         }
0064         peg = svn::Revision::UNDEFINED;
0065         cacheKey = url;
0066     } else {
0067         // valid url
0068         QUrl _uri(what);
0069         _uri.setScheme(svn::Url::transformProtokoll(_uri.scheme()));
0070         url = _uri.toString();
0071         if (peg == svn::Revision::UNDEFINED) {
0072             peg = rev;
0073         }
0074         if (peg == svn::Revision::UNDEFINED) {
0075             peg = svn::Revision::HEAD;
0076         }
0077     }
0078     const svn::InfoEntries _e = (m_Svnclient->info(url, svn::DepthEmpty, rev, peg));
0079     if (!_e.isEmpty()) {
0080         target = _e[0];
0081     }
0082 }
0083 
0084 #include "moc_svnthread.cpp"