forked from qt-creator/qt-creator
Cvs: Follow the Fossil settings setup
Change-Id: I3cd949fa8dad71531c54392de0402783fb314c19 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -137,34 +137,28 @@ static inline bool messageBoxQuestion(const QString &title, const QString &quest
|
|||||||
class CvsDiffConfig : public VcsBaseEditorConfig
|
class CvsDiffConfig : public VcsBaseEditorConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CvsDiffConfig(CvsSettings &settings, QToolBar *toolBar) :
|
CvsDiffConfig(QToolBar *toolBar)
|
||||||
VcsBaseEditorConfig(toolBar),
|
: VcsBaseEditorConfig(toolBar)
|
||||||
m_settings(settings)
|
|
||||||
{
|
{
|
||||||
mapSetting(addToggleButton("-w", Tr::tr("Ignore Whitespace")),
|
mapSetting(addToggleButton("-w", Tr::tr("Ignore Whitespace")),
|
||||||
&settings.diffIgnoreWhiteSpace);
|
&settings().diffIgnoreWhiteSpace);
|
||||||
mapSetting(addToggleButton("-B", Tr::tr("Ignore Blank Lines")),
|
mapSetting(addToggleButton("-B", Tr::tr("Ignore Blank Lines")),
|
||||||
&settings.diffIgnoreBlankLines);
|
&settings().diffIgnoreBlankLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList arguments() const override
|
QStringList arguments() const override
|
||||||
{
|
{
|
||||||
return m_settings.diffOptions.value().split(' ', Qt::SkipEmptyParts)
|
return settings().diffOptions.value().split(' ', Qt::SkipEmptyParts)
|
||||||
+ VcsBaseEditorConfig::arguments();
|
+ VcsBaseEditorConfig::arguments();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
CvsSettings &m_settings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CvsClient : public VcsBaseClient
|
class CvsClient : public VcsBaseClient
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CvsClient(CvsSettings *settings) : VcsBaseClient(settings)
|
explicit CvsClient() : VcsBaseClient(&Internal::settings())
|
||||||
{
|
{
|
||||||
setDiffConfigCreator([settings](QToolBar *toolBar) {
|
setDiffConfigCreator([](QToolBar *toolBar) { return new CvsDiffConfig(toolBar); });
|
||||||
return new CvsDiffConfig(*settings, toolBar);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override
|
ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override
|
||||||
@@ -294,7 +288,6 @@ private:
|
|||||||
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
|
bool commit(const QString &messageFile, const QStringList &subVersionFileList);
|
||||||
void cleanCommitMessageFile();
|
void cleanCommitMessageFile();
|
||||||
|
|
||||||
CvsSettings m_settings;
|
|
||||||
CvsClient *m_client = nullptr;
|
CvsClient *m_client = nullptr;
|
||||||
|
|
||||||
QString m_commitMessageFileName;
|
QString m_commitMessageFileName;
|
||||||
@@ -327,7 +320,7 @@ private:
|
|||||||
|
|
||||||
QAction *m_menuAction = nullptr;
|
QAction *m_menuAction = nullptr;
|
||||||
|
|
||||||
CvsSettingsPage m_settingsPage{&m_settings};
|
CvsSettingsPage m_settingsPage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VcsSubmitEditorFactory submitEditorFactory {
|
VcsSubmitEditorFactory submitEditorFactory {
|
||||||
@@ -374,7 +367,7 @@ bool CvsPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &filePath) con
|
|||||||
|
|
||||||
bool CvsPluginPrivate::isConfigured() const
|
bool CvsPluginPrivate::isConfigured() const
|
||||||
{
|
{
|
||||||
const Utils::FilePath binary = m_settings.binaryPath.filePath();
|
const FilePath binary = settings().binaryPath.filePath();
|
||||||
if (binary.isEmpty())
|
if (binary.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
QFileInfo fi = binary.toFileInfo();
|
QFileInfo fi = binary.toFileInfo();
|
||||||
@@ -447,7 +440,7 @@ VcsCommand *CvsPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
|||||||
|
|
||||||
auto command = VcsBaseClient::createVcsCommand(baseDirectory, Environment::systemEnvironment());
|
auto command = VcsBaseClient::createVcsCommand(baseDirectory, Environment::systemEnvironment());
|
||||||
command->setDisplayName(Tr::tr("CVS Checkout"));
|
command->setDisplayName(Tr::tr("CVS Checkout"));
|
||||||
command->addJob({m_settings.binaryPath.filePath(), m_settings.addOptions(args)}, -1);
|
command->addJob({settings().binaryPath.filePath(), settings().addOptions(args)}, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -497,7 +490,7 @@ CvsPluginPrivate::CvsPluginPrivate()
|
|||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
Context context(CVS_CONTEXT);
|
Context context(CVS_CONTEXT);
|
||||||
m_client = new CvsClient(&m_settings);
|
m_client = new CvsClient;
|
||||||
|
|
||||||
const QString prefix = QLatin1String("cvs");
|
const QString prefix = QLatin1String("cvs");
|
||||||
m_commandLocator = new CommandLocator("CVS", prefix, prefix, this);
|
m_commandLocator = new CommandLocator("CVS", prefix, prefix, this);
|
||||||
@@ -692,7 +685,7 @@ CvsPluginPrivate::CvsPluginPrivate()
|
|||||||
cvsMenu->addAction(command);
|
cvsMenu->addAction(command);
|
||||||
m_commandLocator->appendCommand(command);
|
m_commandLocator->appendCommand(command);
|
||||||
|
|
||||||
connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged);
|
connect(&settings(), &AspectContainer::applied, this, &IVersionControl::configurationChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvsPluginPrivate::vcsDescribe(const FilePath &source, const QString &changeNr)
|
void CvsPluginPrivate::vcsDescribe(const FilePath &source, const QString &changeNr)
|
||||||
@@ -1230,7 +1223,7 @@ bool CvsPluginPrivate::describe(const FilePath &toplevel, const QString &file,
|
|||||||
*errorMessage = Tr::tr("Parsing of the log output failed.");
|
*errorMessage = Tr::tr("Parsing of the log output failed.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_settings.describeByCommitId.value()) {
|
if (settings().describeByCommitId()) {
|
||||||
// Run a log command over the repo, filtering by the commit date
|
// Run a log command over the repo, filtering by the commit date
|
||||||
// and commit id, collecting all files touched by the commit.
|
// and commit id, collecting all files touched by the commit.
|
||||||
const QString commitId = fileLog.front().revisions.front().commitId;
|
const QString commitId = fileLog.front().revisions.front().commitId;
|
||||||
@@ -1286,7 +1279,7 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath,
|
|||||||
for (QList<CvsLogEntry>::iterator it = entries.begin(); it != lend; ++it) {
|
for (QList<CvsLogEntry>::iterator it = entries.begin(); it != lend; ++it) {
|
||||||
const QString &revision = it->revisions.front().revision;
|
const QString &revision = it->revisions.front().revision;
|
||||||
if (!isFirstRevision(revision)) {
|
if (!isFirstRevision(revision)) {
|
||||||
const QStringList args{"diff", m_settings.diffOptions.value(),
|
const QStringList args{"diff", settings().diffOptions(),
|
||||||
"-r", previousRevision(revision),
|
"-r", previousRevision(revision),
|
||||||
"-r", it->revisions.front().revision, it->file};
|
"-r", it->revisions.front().revision, it->file};
|
||||||
const auto diffResponse = runCvs(repositoryPath, args, RunFlags::None, codec);
|
const auto diffResponse = runCvs(repositoryPath, args, RunFlags::None, codec);
|
||||||
@@ -1329,13 +1322,13 @@ CommandResult CvsPluginPrivate::runCvs(const FilePath &workingDirectory,
|
|||||||
const QStringList &arguments, RunFlags flags,
|
const QStringList &arguments, RunFlags flags,
|
||||||
QTextCodec *outputCodec, int timeoutMultiplier) const
|
QTextCodec *outputCodec, int timeoutMultiplier) const
|
||||||
{
|
{
|
||||||
const FilePath executable = m_settings.binaryPath.filePath();
|
const FilePath executable = settings().binaryPath.filePath();
|
||||||
if (executable.isEmpty())
|
if (executable.isEmpty())
|
||||||
return CommandResult(ProcessResult::StartFailed, Tr::tr("No CVS executable specified."));
|
return CommandResult(ProcessResult::StartFailed, Tr::tr("No CVS executable specified."));
|
||||||
|
|
||||||
const int timeoutS = m_settings.timeout() * timeoutMultiplier;
|
const int timeoutS = settings().timeout() * timeoutMultiplier;
|
||||||
return m_client->vcsSynchronousExec(workingDirectory,
|
return m_client->vcsSynchronousExec(workingDirectory,
|
||||||
{executable, m_settings.addOptions(arguments)},
|
{executable, settings().addOptions(arguments)},
|
||||||
flags, timeoutS, outputCodec);
|
flags, timeoutS, outputCodec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -70,15 +70,15 @@ QStringList CvsSettings::addOptions(const QStringList &args) const
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
CvsSettingsPage::CvsSettingsPage(CvsSettings *settings)
|
CvsSettingsPage::CvsSettingsPage()
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_CVS);
|
setId(VcsBase::Constants::VCS_ID_CVS);
|
||||||
setDisplayName(Tr::tr("CVS"));
|
setDisplayName(Tr::tr("CVS"));
|
||||||
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
||||||
setSettings(settings);
|
setSettings(&settings());
|
||||||
|
|
||||||
setLayouter([settings](QWidget *widget) {
|
setLayouter([](QWidget *widget) {
|
||||||
CvsSettings &s = *settings;
|
CvsSettings &s = settings();
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
@@ -104,4 +104,10 @@ CvsSettingsPage::CvsSettingsPage(CvsSettings *settings)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CvsSettings &settings()
|
||||||
|
{
|
||||||
|
static CvsSettings theSettings;
|
||||||
|
return theSettings;
|
||||||
|
}
|
||||||
|
|
||||||
} // Cvs::Internal
|
} // Cvs::Internal
|
||||||
|
@@ -12,21 +12,23 @@ namespace Cvs::Internal {
|
|||||||
class CvsSettings : public VcsBase::VcsBaseSettings
|
class CvsSettings : public VcsBase::VcsBaseSettings
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
CvsSettings();
|
||||||
|
|
||||||
Utils::StringAspect cvsRoot;
|
Utils::StringAspect cvsRoot;
|
||||||
Utils::StringAspect diffOptions;
|
Utils::StringAspect diffOptions;
|
||||||
Utils::BoolAspect diffIgnoreWhiteSpace;
|
Utils::BoolAspect diffIgnoreWhiteSpace;
|
||||||
Utils::BoolAspect diffIgnoreBlankLines;
|
Utils::BoolAspect diffIgnoreBlankLines;
|
||||||
Utils::BoolAspect describeByCommitId;
|
Utils::BoolAspect describeByCommitId;
|
||||||
|
|
||||||
CvsSettings();
|
|
||||||
|
|
||||||
QStringList addOptions(const QStringList &args) const;
|
QStringList addOptions(const QStringList &args) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CvsSettings &settings();
|
||||||
|
|
||||||
class CvsSettingsPage final : public Core::IOptionsPage
|
class CvsSettingsPage final : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CvsSettingsPage(CvsSettings *settings);
|
CvsSettingsPage();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Cvs::Internal
|
} // Cvs::Internal
|
||||||
|
Reference in New Issue
Block a user