2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-07-15 12:28:40 +02:00
|
|
|
|
|
|
|
|
#include "cvscontrol.h"
|
|
|
|
|
#include "cvsplugin.h"
|
2011-04-15 16:02:44 +02:00
|
|
|
#include "cvssettings.h"
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2011-04-20 15:46:48 +02:00
|
|
|
#include <vcsbase/vcsbaseconstants.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QFileInfo>
|
2009-12-09 12:41:10 +01:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
using namespace Cvs;
|
|
|
|
|
using namespace Cvs::Internal;
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
CvsControl::CvsControl(CvsPlugin *plugin) :
|
2009-07-15 12:28:40 +02:00
|
|
|
m_plugin(plugin)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QString CvsControl::displayName() const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
return QLatin1String("cvs");
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
Core::Id CvsControl::id() const
|
2011-04-20 15:46:48 +02:00
|
|
|
{
|
2012-01-07 14:59:08 +01:00
|
|
|
return VcsBase::Constants::VCS_ID_CVS;
|
2011-04-20 15:46:48 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::isConfigured() const
|
2011-04-15 16:02:44 +02:00
|
|
|
{
|
2012-08-21 14:45:42 +03:00
|
|
|
const QString binary = m_plugin->settings().cvsBinaryPath;
|
2011-04-15 16:02:44 +02:00
|
|
|
if (binary.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
QFileInfo fi(binary);
|
|
|
|
|
return fi.exists() && fi.isFile() && fi.isExecutable();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::supportsOperation(Operation operation) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2011-04-15 16:02:44 +02:00
|
|
|
bool rc = isConfigured();
|
2009-07-15 12:28:40 +02:00
|
|
|
switch (operation) {
|
|
|
|
|
case AddOperation:
|
|
|
|
|
case DeleteOperation:
|
2010-03-19 17:22:18 +01:00
|
|
|
case AnnotateOperation:
|
2010-08-06 16:12:24 +02:00
|
|
|
case OpenOperation:
|
2009-07-15 12:28:40 +02:00
|
|
|
break;
|
2010-05-11 14:13:38 +02:00
|
|
|
case MoveOperation:
|
2010-01-12 16:45:21 +01:00
|
|
|
case CreateRepositoryOperation:
|
2010-01-15 12:24:06 +01:00
|
|
|
case SnapshotOperations:
|
2010-09-29 12:16:35 +02:00
|
|
|
case CheckoutOperation:
|
|
|
|
|
case GetRepositoryRootOperation:
|
2009-07-15 12:28:40 +02:00
|
|
|
rc = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsOpen(const QString &fileName)
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2010-08-06 16:12:24 +02:00
|
|
|
const QFileInfo fi(fileName);
|
|
|
|
|
return m_plugin->edit(fi.absolutePath(), QStringList(fi.fileName()));
|
2009-07-15 12:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsAdd(const QString &fileName)
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2009-12-09 12:41:10 +01:00
|
|
|
const QFileInfo fi(fileName);
|
|
|
|
|
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
|
2009-07-15 12:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsDelete(const QString &fileName)
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2009-12-09 12:41:10 +01:00
|
|
|
const QFileInfo fi(fileName);
|
|
|
|
|
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
|
2009-07-15 12:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsMove(const QString &from, const QString &to)
|
2010-05-11 14:13:38 +02:00
|
|
|
{
|
2010-05-12 16:26:47 +02:00
|
|
|
Q_UNUSED(from);
|
|
|
|
|
Q_UNUSED(to);
|
2010-05-11 14:13:38 +02:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsCreateRepository(const QString &)
|
2010-01-12 16:45:21 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QString CvsControl::vcsGetRepositoryURL(const QString &)
|
2010-09-29 12:16:35 +02:00
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsCheckout(const QString &, const QByteArray &)
|
2010-09-29 12:16:35 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QString CvsControl::vcsCreateSnapshot(const QString &)
|
2010-01-15 12:24:06 +01:00
|
|
|
{
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QStringList CvsControl::vcsSnapshots(const QString &)
|
2010-01-15 12:24:06 +01:00
|
|
|
{
|
|
|
|
|
return QStringList();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsRestoreSnapshot(const QString &, const QString &)
|
2010-01-15 12:24:06 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsRemoveSnapshot(const QString &, const QString &)
|
2010-01-15 12:24:06 +01:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::vcsAnnotate(const QString &file, int line)
|
2010-03-19 17:22:18 +01:00
|
|
|
{
|
|
|
|
|
m_plugin->vcsAnnotate(file, QString(), line);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsControl::managesDirectory(const QString &directory, QString *topLevel) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2010-05-20 16:24:39 +02:00
|
|
|
return m_plugin->managesDirectory(directory, topLevel);
|
2009-07-15 12:28:40 +02:00
|
|
|
}
|
2009-11-11 14:32:54 +01:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsControl::emitRepositoryChanged(const QString &s)
|
2009-11-11 14:32:54 +01:00
|
|
|
{
|
|
|
|
|
emit repositoryChanged(s);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsControl::emitFilesChanged(const QStringList &l)
|
2009-11-11 14:32:54 +01:00
|
|
|
{
|
|
|
|
|
emit filesChanged(l);
|
|
|
|
|
}
|
2011-04-15 17:43:44 +02:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsControl::emitConfigurationChanged()
|
2011-04-15 17:43:44 +02:00
|
|
|
{
|
|
|
|
|
emit configurationChanged();
|
|
|
|
|
}
|