2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-15 12:28:40 +02:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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 "cvssettings.h"
|
|
|
|
|
|
2012-08-21 14:45:42 +03:00
|
|
|
#include <utils/environment.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2012-08-21 14:45:42 +03:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
#include <QTextStream>
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char groupC[] = "CVS";
|
|
|
|
|
static const char commandKeyC[] = "Command";
|
|
|
|
|
static const char rootC[] = "Root";
|
|
|
|
|
static const char promptToSubmitKeyC[] = "PromptForSubmit";
|
|
|
|
|
static const char diffOptionsKeyC[] = "DiffOptions";
|
|
|
|
|
static const char describeByCommitIdKeyC[] = "DescribeByCommitId";
|
|
|
|
|
static const char defaultDiffOptions[] = "-du";
|
|
|
|
|
static const char timeOutKeyC[] = "TimeOut";
|
2009-12-14 12:45:45 +01:00
|
|
|
|
|
|
|
|
enum { defaultTimeOutS = 30 };
|
2009-07-15 12:28:40 +02:00
|
|
|
|
|
|
|
|
static QString defaultCommand()
|
|
|
|
|
{
|
2012-08-31 16:39:20 +02:00
|
|
|
return QLatin1String("cvs" QTC_HOST_EXE_SUFFIX);
|
2009-07-15 12:28:40 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
namespace Cvs {
|
2010-04-12 16:34:21 +02:00
|
|
|
namespace Internal {
|
2009-07-15 12:28:40 +02:00
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
CvsSettings::CvsSettings() :
|
2009-07-15 12:28:40 +02:00
|
|
|
cvsCommand(defaultCommand()),
|
|
|
|
|
cvsDiffOptions(QLatin1String(defaultDiffOptions)),
|
2009-12-14 12:45:45 +01:00
|
|
|
timeOutS(defaultTimeOutS),
|
2009-07-15 12:28:40 +02:00
|
|
|
promptToSubmit(true),
|
|
|
|
|
describeByCommitId(true)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsSettings::fromSettings(QSettings *settings)
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(groupC));
|
|
|
|
|
cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
|
2012-08-21 14:45:42 +03:00
|
|
|
cvsBinaryPath = Utils::Environment::systemEnvironment().searchInPath(cvsCommand);
|
2009-07-15 12:28:40 +02:00
|
|
|
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
|
|
|
|
|
cvsRoot = settings->value(QLatin1String(rootC), QString()).toString();
|
|
|
|
|
cvsDiffOptions = settings->value(QLatin1String(diffOptionsKeyC), QLatin1String(defaultDiffOptions)).toString();
|
|
|
|
|
describeByCommitId = settings->value(QLatin1String(describeByCommitIdKeyC), true).toBool();
|
2009-12-14 12:45:45 +01:00
|
|
|
timeOutS = settings->value(QLatin1String(timeOutKeyC), defaultTimeOutS).toInt();
|
2009-07-15 12:28:40 +02:00
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
void CvsSettings::toSettings(QSettings *settings) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
settings->beginGroup(QLatin1String(groupC));
|
|
|
|
|
settings->setValue(QLatin1String(commandKeyC), cvsCommand);
|
|
|
|
|
settings->setValue(QLatin1String(promptToSubmitKeyC), promptToSubmit);
|
|
|
|
|
settings->setValue(QLatin1String(rootC), cvsRoot);
|
|
|
|
|
settings->setValue(QLatin1String(diffOptionsKeyC), cvsDiffOptions);
|
2009-12-14 12:45:45 +01:00
|
|
|
settings->setValue(QLatin1String(timeOutKeyC), timeOutS);
|
2009-07-15 12:28:40 +02:00
|
|
|
settings->setValue(QLatin1String(describeByCommitIdKeyC), describeByCommitId);
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
bool CvsSettings::equals(const CvsSettings &s) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
2011-09-01 14:10:00 +00:00
|
|
|
return promptToSubmit == s.promptToSubmit
|
2009-07-15 12:28:40 +02:00
|
|
|
&& describeByCommitId == s.describeByCommitId
|
|
|
|
|
&& cvsCommand == s.cvsCommand
|
|
|
|
|
&& cvsRoot == s.cvsRoot
|
2009-12-14 12:45:45 +01:00
|
|
|
&& timeOutS == s.timeOutS
|
2009-07-15 12:28:40 +02:00
|
|
|
&& cvsDiffOptions == s.cvsDiffOptions;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-07 16:55:09 +01:00
|
|
|
QStringList CvsSettings::addOptions(const QStringList &args) const
|
2009-07-15 12:28:40 +02:00
|
|
|
{
|
|
|
|
|
if (cvsRoot.isEmpty())
|
|
|
|
|
return args;
|
|
|
|
|
|
|
|
|
|
QStringList rc;
|
|
|
|
|
rc.push_back(QLatin1String("-d"));
|
|
|
|
|
rc.push_back(cvsRoot);
|
|
|
|
|
rc.append(args);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-12 16:34:21 +02:00
|
|
|
} // namespace Internal
|
2012-01-07 16:55:09 +01:00
|
|
|
} // namespace Cvs
|