2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://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
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
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-04-29 14:34:07 +02:00
|
|
|
#include <vcsbase/vcscommand.h>
|
2011-04-20 15:46:48 +02:00
|
|
|
|
2015-02-26 09:33:24 +01:00
|
|
|
#include <utils/fileutils.h>
|
2016-10-20 13:06:11 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2015-04-29 14:34:07 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2015-02-26 09:33:24 +01:00
|
|
|
|
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)
|
2016-02-04 13:07:35 +01:00
|
|
|
{ }
|
2009-07-15 12:28:40 +02:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2016-10-20 13:06:11 +02:00
|
|
|
bool CvsControl::isVcsFileOrDirectory(const Utils::FileName &fileName) const
|
|
|
|
|
{
|
|
|
|
|
return fileName.toFileInfo().isDir()
|
2016-10-22 21:10:00 +03:00
|
|
|
&& !fileName.fileName().compare("CVS", Utils::HostOsInfo::fileNameCaseSensitivity());
|
2016-10-20 13:06:11 +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:
|
2015-04-29 14:34:07 +02:00
|
|
|
case InitialCheckoutOperation:
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 14:34:07 +02:00
|
|
|
Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url,
|
|
|
|
|
const Utils::FileName &baseDirectory,
|
|
|
|
|
const QString &localName,
|
|
|
|
|
const QStringList &extraArgs)
|
|
|
|
|
{
|
2018-09-20 00:56:53 +03:00
|
|
|
QTC_ASSERT(localName == url, return nullptr);
|
2015-04-29 14:34:07 +02:00
|
|
|
|
|
|
|
|
const CvsSettings settings = CvsPlugin::instance()->client()->settings();
|
|
|
|
|
|
|
|
|
|
QStringList args;
|
|
|
|
|
args << QLatin1String("checkout") << url << extraArgs;
|
|
|
|
|
|
|
|
|
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
|
|
|
|
QProcessEnvironment::systemEnvironment());
|
2015-05-29 16:24:39 +02:00
|
|
|
command->setDisplayName(tr("CVS Checkout"));
|
2015-04-29 14:34:07 +02:00
|
|
|
command->addJob(m_plugin->client()->vcsBinary(), settings.addOptions(args), -1);
|
|
|
|
|
return command;
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
|
}
|