2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://www.qt.io/licensing
|
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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/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
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company 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"
|
2015-03-26 12:22:29 +01:00
|
|
|
|
|
|
|
|
#include "cvsclient.h"
|
2009-07-15 12:28:40 +02:00
|
|
|
#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>
|
|
|
|
|
|
2015-02-26 09:33:24 +01:00
|
|
|
#include <utils/fileutils.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-11-20 07:18:01 +02:00
|
|
|
return Core::Id(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
|
|
|
{
|
2015-03-26 12:22:29 +01:00
|
|
|
const Utils::FileName binary = m_plugin->client()->vcsBinary();
|
2011-04-15 16:02:44 +02:00
|
|
|
if (binary.isEmpty())
|
|
|
|
|
return false;
|
2014-07-15 23:32:11 +03:00
|
|
|
QFileInfo fi = binary.toFileInfo();
|
2011-04-15 16:02:44 +02:00
|
|
|
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:
|
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:
|
2009-07-15 12:28:40 +02:00
|
|
|
rc = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-07 12:31:22 +01:00
|
|
|
Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode(const QString &fileName) const
|
2013-02-22 14:02:24 +01:00
|
|
|
{
|
2013-11-07 12:31:22 +01:00
|
|
|
Q_UNUSED(fileName);
|
2013-02-22 14:02:24 +01:00
|
|
|
return OpenOptional;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
bool CvsControl::vcsAnnotate(const QString &file, int line)
|
2010-03-19 17:22:18 +01:00
|
|
|
{
|
2013-10-06 20:47:29 +03:00
|
|
|
const QFileInfo fi(file);
|
|
|
|
|
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
|
2010-03-19 17:22:18 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-24 23:54:00 +02:00
|
|
|
QString CvsControl::vcsOpenText() const
|
|
|
|
|
{
|
|
|
|
|
return tr("&Edit");
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2013-10-02 00:18:39 +03:00
|
|
|
bool CvsControl::managesFile(const QString &workingDirectory, const QString &fileName) const
|
|
|
|
|
{
|
|
|
|
|
return m_plugin->managesFile(workingDirectory, fileName);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|