VCS: Use namespace Utils

Change-Id: I41c818362398fd194995baf5b1adb16899e83217
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
Orgad Shaneh
2018-07-17 22:54:58 +03:00
committed by Orgad Shaneh
parent dc29aafb52
commit afb60d0434
10 changed files with 92 additions and 76 deletions

View File

@@ -37,6 +37,8 @@
#include <QCoreApplication> #include <QCoreApplication>
using namespace Utils;
namespace VcsBase { namespace VcsBase {
namespace Internal { namespace Internal {
@@ -47,13 +49,13 @@ CommonSettingsWidget::CommonSettingsWidget(QWidget *parent) :
m_ui(new Ui::CommonSettingsPage) m_ui(new Ui::CommonSettingsPage)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->submitMessageCheckScriptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_ui->submitMessageCheckScriptChooser->setExpectedKind(PathChooser::ExistingCommand);
m_ui->submitMessageCheckScriptChooser->setHistoryCompleter(QLatin1String("Vcs.MessageCheckScript.History")); m_ui->submitMessageCheckScriptChooser->setHistoryCompleter(QLatin1String("Vcs.MessageCheckScript.History"));
m_ui->nickNameFieldsFileChooser->setExpectedKind(Utils::PathChooser::File); m_ui->nickNameFieldsFileChooser->setExpectedKind(PathChooser::File);
m_ui->nickNameFieldsFileChooser->setHistoryCompleter(QLatin1String("Vcs.NickFields.History")); m_ui->nickNameFieldsFileChooser->setHistoryCompleter(QLatin1String("Vcs.NickFields.History"));
m_ui->nickNameMailMapChooser->setExpectedKind(Utils::PathChooser::File); m_ui->nickNameMailMapChooser->setExpectedKind(PathChooser::File);
m_ui->nickNameMailMapChooser->setHistoryCompleter(QLatin1String("Vcs.NickMap.History")); m_ui->nickNameMailMapChooser->setHistoryCompleter(QLatin1String("Vcs.NickMap.History"));
m_ui->sshPromptChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); m_ui->sshPromptChooser->setExpectedKind(PathChooser::ExistingCommand);
m_ui->sshPromptChooser->setHistoryCompleter(QLatin1String("Vcs.SshPrompt.History")); m_ui->sshPromptChooser->setHistoryCompleter(QLatin1String("Vcs.SshPrompt.History"));
updatePath(); updatePath();
@@ -93,9 +95,9 @@ void CommonSettingsWidget::setSettings(const CommonVcsSettings &s)
void CommonSettingsWidget::updatePath() void CommonSettingsWidget::updatePath()
{ {
Utils::Environment env = Utils::Environment::systemEnvironment(); Environment env = Environment::systemEnvironment();
QStringList toAdd = Core::VcsManager::additionalToolsPath(); QStringList toAdd = Core::VcsManager::additionalToolsPath();
env.appendOrSetPath(toAdd.join(Utils::HostOsInfo::pathListSeparator())); env.appendOrSetPath(toAdd.join(HostOsInfo::pathListSeparator()));
m_ui->sshPromptChooser->setEnvironment(env); m_ui->sshPromptChooser->setEnvironment(env);
} }

View File

@@ -34,6 +34,8 @@
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
using namespace Utils;
enum { NickNameRole = Qt::UserRole + 1 }; enum { NickNameRole = Qt::UserRole + 1 };
/*! /*!
@@ -175,7 +177,7 @@ NickNameDialog::NickNameDialog(QStandardItemModel *model, QWidget *parent) :
m_filterModel->setSourceModel(model); m_filterModel->setSourceModel(model);
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
m_ui->filterTreeView->setModel(m_filterModel); m_ui->filterTreeView->setModel(m_filterModel);
m_ui->filterTreeView->setActivationMode(Utils::DoubleClickActivation); m_ui->filterTreeView->setActivationMode(DoubleClickActivation);
const int columnCount = m_filterModel->columnCount(); const int columnCount = m_filterModel->columnCount();
int treeWidth = 0; int treeWidth = 0;
for (int c = 0; c < columnCount; c++) { for (int c = 0; c < columnCount; c++) {
@@ -188,7 +190,7 @@ NickNameDialog::NickNameDialog(QStandardItemModel *model, QWidget *parent) :
&NickNameDialog::slotActivated); &NickNameDialog::slotActivated);
connect(m_ui->filterTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged, connect(m_ui->filterTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged,
this, &NickNameDialog::slotCurrentItemChanged); this, &NickNameDialog::slotCurrentItemChanged);
connect(m_ui->filterLineEdit, &Utils::FancyLineEdit::filterChanged, connect(m_ui->filterLineEdit, &FancyLineEdit::filterChanged,
m_filterModel, &QSortFilterProxyModel::setFilterFixedString); m_filterModel, &QSortFilterProxyModel::setFilterFixedString);
} }
@@ -242,7 +244,7 @@ bool NickNameDialog::populateModelFromMailCapFile(const QString &fileName,
model->removeRows(0, rowCount); model->removeRows(0, rowCount);
if (fileName.isEmpty()) if (fileName.isEmpty())
return true; return true;
Utils::FileReader reader; FileReader reader;
if (!reader.fetch(fileName, QIODevice::Text, errorMessage)) if (!reader.fetch(fileName, QIODevice::Text, errorMessage))
return false; return false;
// Split into lines and read // Split into lines and read

View File

@@ -42,6 +42,8 @@
#include <QSpacerItem> #include <QSpacerItem>
#include <QShortcut> #include <QShortcut>
using namespace Utils;
enum { debug = 0 }; enum { debug = 0 };
enum { defaultLineWidth = 72 }; enum { defaultLineWidth = 72 };
@@ -252,16 +254,16 @@ void SubmitEditorWidget::unregisterActions(QAction *editorUndoAction, QAction *
QAction *submitAction, QAction *diffAction) QAction *submitAction, QAction *diffAction)
{ {
if (editorUndoAction) { if (editorUndoAction) {
disconnect(d->m_ui.description, &Utils::CompletingTextEdit::undoAvailable, disconnect(d->m_ui.description, &CompletingTextEdit::undoAvailable,
editorUndoAction, &QAction::setEnabled); editorUndoAction, &QAction::setEnabled);
disconnect(editorUndoAction, &QAction::triggered, disconnect(editorUndoAction, &QAction::triggered,
d->m_ui.description, &Utils::CompletingTextEdit::undo); d->m_ui.description, &CompletingTextEdit::undo);
} }
if (editorRedoAction) { if (editorRedoAction) {
disconnect(d->m_ui.description, &Utils::CompletingTextEdit::redoAvailable, disconnect(d->m_ui.description, &CompletingTextEdit::redoAvailable,
editorRedoAction, &QAction::setEnabled); editorRedoAction, &QAction::setEnabled);
disconnect(editorRedoAction, &QAction::triggered, disconnect(editorRedoAction, &QAction::triggered,
d->m_ui.description, &Utils::CompletingTextEdit::redo); d->m_ui.description, &CompletingTextEdit::redo);
} }
if (submitAction) { if (submitAction) {
@@ -446,7 +448,7 @@ QStringList SubmitEditorWidget::checkedFiles() const
return rc; return rc;
} }
Utils::CompletingTextEdit *SubmitEditorWidget::descriptionEdit() const CompletingTextEdit *SubmitEditorWidget::descriptionEdit() const
{ {
return d->m_ui.description; return d->m_ui.description;
} }

View File

@@ -50,6 +50,8 @@
#include <QVariant> #include <QVariant>
#include <QProcessEnvironment> #include <QProcessEnvironment>
using namespace Utils;
/*! /*!
\class VcsBase::VcsBaseClient \class VcsBase::VcsBaseClient
@@ -108,7 +110,7 @@ VcsBaseClientSettings &VcsBaseClientImpl::settings() const
return *d->m_clientSettings; return *d->m_clientSettings;
} }
Utils::FileName VcsBaseClientImpl::vcsBinary() const FileName VcsBaseClientImpl::vcsBinary() const
{ {
return settings().binaryPath(); return settings().binaryPath();
} }
@@ -134,7 +136,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory,
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args, void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
const QString &workingDirectory, const QString &workingDirectory,
const Utils::ExitCodeInterpreter &interpreter) const const ExitCodeInterpreter &interpreter) const
{ {
cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter); cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter);
cmd->execute(); cmd->execute();
@@ -149,7 +151,7 @@ QProcessEnvironment VcsBaseClientImpl::processEnvironment() const
QString VcsBaseClientImpl::commandOutputFromLocal8Bit(const QByteArray &a) QString VcsBaseClientImpl::commandOutputFromLocal8Bit(const QByteArray &a)
{ {
return Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a)); return SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a));
} }
QStringList VcsBaseClientImpl::commandOutputLinesFromLocal8Bit(const QByteArray &a) QStringList VcsBaseClientImpl::commandOutputLinesFromLocal8Bit(const QByteArray &a)
@@ -175,8 +177,8 @@ QString VcsBaseClientImpl::stripLastNewline(const QString &in)
return in; return in;
} }
Utils::SynchronousProcessResponse SynchronousProcessResponse
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const Utils::FileName &binary, VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const FileName &binary,
const QStringList &args, unsigned flags, const QStringList &args, unsigned flags,
int timeoutS, QTextCodec *codec) const int timeoutS, QTextCodec *codec) const
{ {
@@ -205,7 +207,7 @@ void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirector
annotate(workingDirectory, file, changeCopy, line); annotate(workingDirectory, file, changeCopy, line);
} }
Utils::SynchronousProcessResponse SynchronousProcessResponse
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
unsigned flags, int timeoutS, QTextCodec *codec) const unsigned flags, int timeoutS, QTextCodec *codec) const
{ {
@@ -226,10 +228,10 @@ VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QS
return command; return command;
} }
Utils::SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &workingDir, SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &workingDir,
const QStringList &args, const QStringList &args,
unsigned flags, unsigned flags,
QTextCodec *outputCodec) const QTextCodec *outputCodec) const
{ {
return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags, return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags,
outputCodec, processEnvironment()); outputCodec, processEnvironment());
@@ -316,8 +318,8 @@ bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory,
{ {
QStringList args(vcsCommandString(CreateRepositoryCommand)); QStringList args(vcsCommandString(CreateRepositoryCommand));
args << extraOptions; args << extraOptions;
Utils::SynchronousProcessResponse result = vcsFullySynchronousExec(workingDirectory, args); SynchronousProcessResponse result = vcsFullySynchronousExec(workingDirectory, args);
if (result.result != Utils::SynchronousProcessResponse::Finished) if (result.result != SynchronousProcessResponse::Finished)
return false; return false;
VcsOutputWindow::append(result.stdOut()); VcsOutputWindow::append(result.stdOut());
@@ -335,9 +337,9 @@ bool VcsBaseClient::synchronousClone(const QString &workingDir,
args << vcsCommandString(CloneCommand) args << vcsCommandString(CloneCommand)
<< extraOptions << srcLocation << dstLocation; << extraOptions << srcLocation << dstLocation;
Utils::SynchronousProcessResponse result = vcsFullySynchronousExec(workingDir, args); SynchronousProcessResponse result = vcsFullySynchronousExec(workingDir, args);
resetCachedVcsInfo(workingDir); resetCachedVcsInfo(workingDir);
return result.result == Utils::SynchronousProcessResponse::Finished; return result.result == SynchronousProcessResponse::Finished;
} }
bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename, bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &filename,
@@ -345,7 +347,7 @@ bool VcsBaseClient::synchronousAdd(const QString &workingDir, const QString &fil
{ {
QStringList args; QStringList args;
args << vcsCommandString(AddCommand) << extraOptions << filename; args << vcsCommandString(AddCommand) << extraOptions << filename;
return vcsFullySynchronousExec(workingDir, args).result == Utils::SynchronousProcessResponse::Finished; return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished;
} }
bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename, bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &filename,
@@ -353,7 +355,7 @@ bool VcsBaseClient::synchronousRemove(const QString &workingDir, const QString &
{ {
QStringList args; QStringList args;
args << vcsCommandString(RemoveCommand) << extraOptions << filename; args << vcsCommandString(RemoveCommand) << extraOptions << filename;
return vcsFullySynchronousExec(workingDir, args).result == Utils::SynchronousProcessResponse::Finished; return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished;
} }
bool VcsBaseClient::synchronousMove(const QString &workingDir, bool VcsBaseClient::synchronousMove(const QString &workingDir,
@@ -362,7 +364,7 @@ bool VcsBaseClient::synchronousMove(const QString &workingDir,
{ {
QStringList args; QStringList args;
args << vcsCommandString(MoveCommand) << extraOptions << from << to; args << vcsCommandString(MoveCommand) << extraOptions << from << to;
return vcsFullySynchronousExec(workingDir, args).result == Utils::SynchronousProcessResponse::Finished; return vcsFullySynchronousExec(workingDir, args).result == SynchronousProcessResponse::Finished;
} }
bool VcsBaseClient::synchronousPull(const QString &workingDir, bool VcsBaseClient::synchronousPull(const QString &workingDir,
@@ -376,8 +378,8 @@ bool VcsBaseClient::synchronousPull(const QString &workingDir,
VcsCommand::SshPasswordPrompt VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished; const bool ok = resp.result == SynchronousProcessResponse::Finished;
if (ok) if (ok)
emit changed(QVariant(workingDir)); emit changed(QVariant(workingDir));
return ok; return ok;
@@ -394,8 +396,8 @@ bool VcsBaseClient::synchronousPush(const QString &workingDir,
VcsCommand::SshPasswordPrompt VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut | VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage; | VcsCommand::ShowSuccessMessage;
const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
return resp.result == Utils::SynchronousProcessResponse::Finished; return resp.result == SynchronousProcessResponse::Finished;
} }
VcsBaseEditorWidget *VcsBaseClient::annotate( VcsBaseEditorWidget *VcsBaseClient::annotate(
@@ -564,7 +566,7 @@ QString VcsBaseClient::vcsCommandString(VcsCommandTag cmd) const
return QString(); return QString();
} }
Utils::ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const ExitCodeInterpreter VcsBaseClient::exitCodeInterpreter(VcsCommandTag cmd) const
{ {
Q_UNUSED(cmd) Q_UNUSED(cmd)
return Utils::defaultExitCodeInterpreter; return Utils::defaultExitCodeInterpreter;
@@ -640,7 +642,7 @@ QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sour
{ {
return vcsBinary().toFileInfo().baseName() + return vcsBinary().toFileInfo().baseName() +
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') + QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
Utils::FileName::fromString(sourceId).fileName(); FileName::fromString(sourceId).fileName();
} }
void VcsBaseClient::statusParser(const QString &text) void VcsBaseClient::statusParser(const QString &text)

View File

@@ -34,6 +34,8 @@
#include <QSettings> #include <QSettings>
#include <QVariant> #include <QVariant>
using namespace Utils;
namespace { namespace {
class SettingValue class SettingValue
@@ -176,7 +178,7 @@ public:
QHash<QString, SettingValue> m_valueHash; QHash<QString, SettingValue> m_valueHash;
QVariantHash m_defaultValueHash; QVariantHash m_defaultValueHash;
QString m_settingsGroup; QString m_settingsGroup;
mutable Utils::FileName m_binaryFullPath; mutable FileName m_binaryFullPath;
}; };
} // namespace Internal } // namespace Internal
@@ -352,12 +354,12 @@ QVariant::Type VcsBaseClientSettings::valueType(const QString &key) const
return QVariant::Invalid; return QVariant::Invalid;
} }
Utils::FileName VcsBaseClientSettings::binaryPath() const FileName VcsBaseClientSettings::binaryPath() const
{ {
if (d->m_binaryFullPath.isEmpty()) { if (d->m_binaryFullPath.isEmpty()) {
const Utils::FileNameList searchPaths const FileNameList searchPaths
= Utils::transform(searchPathList(), [](const QString &s) { return Utils::FileName::fromString(s); }); = Utils::transform(searchPathList(), [](const QString &s) { return FileName::fromString(s); });
d->m_binaryFullPath = Utils::Environment::systemEnvironment().searchInPath( d->m_binaryFullPath = Environment::systemEnvironment().searchInPath(
stringValue(binaryPathKey), searchPaths); stringValue(binaryPathKey), searchPaths);
} }
return d->m_binaryFullPath; return d->m_binaryFullPath;
@@ -365,7 +367,7 @@ Utils::FileName VcsBaseClientSettings::binaryPath() const
QStringList VcsBaseClientSettings::searchPathList() const QStringList VcsBaseClientSettings::searchPathList() const
{ {
return stringValue(pathKey).split(Utils::HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); return stringValue(pathKey).split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts);
} }
QString VcsBaseClientSettings::settingsGroup() const QString VcsBaseClientSettings::settingsGroup() const

View File

@@ -90,6 +90,7 @@
*/ */
using namespace TextEditor; using namespace TextEditor;
using namespace Utils;
namespace VcsBase { namespace VcsBase {
@@ -563,7 +564,7 @@ public:
QList<AbstractTextCursorHandler *> m_textCursorHandlers; QList<AbstractTextCursorHandler *> m_textCursorHandlers;
QPointer<VcsCommand> m_command; QPointer<VcsCommand> m_command;
VcsBaseEditorWidget::DescribeFunc m_describeFunc = nullptr; VcsBaseEditorWidget::DescribeFunc m_describeFunc = nullptr;
Utils::ProgressIndicator *m_progressIndicator = nullptr; ProgressIndicator *m_progressIndicator = nullptr;
bool m_fileLogAnnotateEnabled = false; bool m_fileLogAnnotateEnabled = false;
bool m_mouseDragging = false; bool m_mouseDragging = false;
@@ -867,7 +868,7 @@ void VcsBaseEditorWidget::slotPopulateDiffBrowser()
lastFileName = file; lastFileName = file;
// ignore any headers // ignore any headers
d->m_entrySections.push_back(d->m_entrySections.empty() ? 0 : lineNumber); d->m_entrySections.push_back(d->m_entrySections.empty() ? 0 : lineNumber);
entriesComboBox->addItem(Utils::FileName::fromString(file).fileName()); entriesComboBox->addItem(FileName::fromString(file).fileName());
} }
} }
} }
@@ -1397,7 +1398,7 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command)
} }
d->m_command = command; d->m_command = command;
if (command) { if (command) {
d->m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicatorSize::Large); d->m_progressIndicator = new ProgressIndicator(ProgressIndicatorSize::Large);
d->m_progressIndicator->attachToWidget(this); d->m_progressIndicator->attachToWidget(this);
connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished); connect(command, &VcsCommand::finished, this, &VcsBaseEditorWidget::reportCommandFinished);
QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator); QTimer::singleShot(100, this, &VcsBaseEditorWidget::showProgressIndicator);

View File

@@ -33,6 +33,8 @@
#include <QProcessEnvironment> #include <QProcessEnvironment>
using namespace Utils;
namespace VcsBase { namespace VcsBase {
VcsCommand::VcsCommand(const QString &workingDirectory, VcsCommand::VcsCommand(const QString &workingDirectory,
@@ -40,19 +42,19 @@ VcsCommand::VcsCommand(const QString &workingDirectory,
Core::ShellCommand(workingDirectory, environment), Core::ShellCommand(workingDirectory, environment),
m_preventRepositoryChanged(false) m_preventRepositoryChanged(false)
{ {
setOutputProxyFactory([this]() -> Utils::OutputProxy * { setOutputProxyFactory([this]() -> OutputProxy * {
auto proxy = new Utils::OutputProxy; auto proxy = new OutputProxy;
VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); VcsOutputWindow *outputWindow = VcsOutputWindow::instance();
connect(proxy, &Utils::OutputProxy::append, connect(proxy, &OutputProxy::append,
outputWindow, [](const QString &txt) { VcsOutputWindow::append(txt); }); outputWindow, [](const QString &txt) { VcsOutputWindow::append(txt); });
connect(proxy, &Utils::OutputProxy::appendSilently, connect(proxy, &OutputProxy::appendSilently,
outputWindow, &VcsOutputWindow::appendSilently); outputWindow, &VcsOutputWindow::appendSilently);
connect(proxy, &Utils::OutputProxy::appendError, connect(proxy, &OutputProxy::appendError,
outputWindow, &VcsOutputWindow::appendError); outputWindow, &VcsOutputWindow::appendError);
connect(proxy, &Utils::OutputProxy::appendCommand, connect(proxy, &OutputProxy::appendCommand,
outputWindow, &VcsOutputWindow::appendCommand); outputWindow, &VcsOutputWindow::appendCommand);
connect(proxy, &Utils::OutputProxy::appendMessage, connect(proxy, &OutputProxy::appendMessage,
outputWindow, &VcsOutputWindow::appendMessage); outputWindow, &VcsOutputWindow::appendMessage);
return proxy; return proxy;
@@ -74,12 +76,12 @@ const QProcessEnvironment VcsCommand::processEnvironment() const
return env; return env;
} }
Utils::SynchronousProcessResponse VcsCommand::runCommand(const Utils::FileName &binary, SynchronousProcessResponse VcsCommand::runCommand(const FileName &binary,
const QStringList &arguments, int timeoutS, const QStringList &arguments, int timeoutS,
const QString &workingDirectory, const QString &workingDirectory,
const Utils::ExitCodeInterpreter &interpreter) const ExitCodeInterpreter &interpreter)
{ {
Utils::SynchronousProcessResponse response SynchronousProcessResponse response
= Core::ShellCommand::runCommand(binary, arguments, timeoutS, workingDirectory, = Core::ShellCommand::runCommand(binary, arguments, timeoutS, workingDirectory,
interpreter); interpreter);
emitRepositoryChanged(workingDirectory); emitRepositoryChanged(workingDirectory);
@@ -99,7 +101,7 @@ unsigned VcsCommand::processFlags() const
{ {
unsigned processFlags = 0; unsigned processFlags = 0;
if (!VcsBasePlugin::sshPrompt().isEmpty() && (flags() & SshPasswordPrompt)) if (!VcsBasePlugin::sshPrompt().isEmpty() && (flags() & SshPasswordPrompt))
processFlags |= Utils::SynchronousProcess::UnixTerminalDisabled; processFlags |= SynchronousProcess::UnixTerminalDisabled;
return processFlags; return processFlags;
} }

View File

@@ -52,6 +52,8 @@
#include <QPoint> #include <QPoint>
#include <QFileInfo> #include <QFileInfo>
using namespace Utils;
/*! /*!
\class VcsBase::VcsBaseOutputWindow \class VcsBase::VcsBaseOutputWindow
@@ -107,7 +109,7 @@ private:
QTextCharFormat m_warningFormat; QTextCharFormat m_warningFormat;
QTextCharFormat m_commandFormat; QTextCharFormat m_commandFormat;
QTextCharFormat m_messageFormat; QTextCharFormat m_messageFormat;
Utils::OutputFormatter *m_formatter; OutputFormatter *m_formatter;
}; };
OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) : OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) :
@@ -118,7 +120,6 @@ OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) :
m_commandFormat(m_defaultFormat), m_commandFormat(m_defaultFormat),
m_messageFormat(m_defaultFormat) m_messageFormat(m_defaultFormat)
{ {
using Utils::Theme;
setReadOnly(true); setReadOnly(true);
setUndoRedoEnabled(false); setUndoRedoEnabled(false);
setFrameStyle(QFrame::NoFrame); setFrameStyle(QFrame::NoFrame);
@@ -126,7 +127,7 @@ OutputWindowPlainTextEdit::OutputWindowPlainTextEdit(QWidget *parent) :
m_warningFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_WarningMessageTextColor)); m_warningFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_WarningMessageTextColor));
m_commandFormat.setFontWeight(QFont::Bold); m_commandFormat.setFontWeight(QFont::Bold);
m_messageFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_MessageOutput)); m_messageFormat.setForeground(Utils::creatorTheme()->color(Theme::OutputPanes_MessageOutput));
m_formatter = new Utils::OutputFormatter; m_formatter = new OutputFormatter;
m_formatter->setPlainTextEdit(this); m_formatter->setPlainTextEdit(this);
Aggregation::Aggregate *agg = new Aggregation::Aggregate; Aggregation::Aggregate *agg = new Aggregation::Aggregate;
agg->add(this); agg->add(this);
@@ -435,12 +436,12 @@ static inline QString formatArguments(const QStringList &args)
if (i) if (i)
str << ' '; str << ' ';
if (arg.startsWith(QString::fromLatin1(passwordOptionC) + QLatin1Char('='))) { if (arg.startsWith(QString::fromLatin1(passwordOptionC) + QLatin1Char('='))) {
str << Utils::QtcProcess::quoteArg("--password=********"); str << QtcProcess::quoteArg("--password=********");
continue; continue;
} }
str << Utils::QtcProcess::quoteArg(arg); str << QtcProcess::quoteArg(arg);
if (arg == QLatin1String(passwordOptionC)) { if (arg == QLatin1String(passwordOptionC)) {
str << ' ' << Utils::QtcProcess::quoteArg("********"); str << ' ' << QtcProcess::quoteArg("********");
i++; i++;
} }
} }
@@ -448,11 +449,11 @@ static inline QString formatArguments(const QStringList &args)
} }
QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir, QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir,
const Utils::FileName &executable, const FileName &executable,
const QStringList &arguments) const QStringList &arguments)
{ {
const QString args = formatArguments(arguments); const QString args = formatArguments(arguments);
const QString nativeExecutable = Utils::QtcProcess::quoteArg(executable.toUserOutput()); const QString nativeExecutable = QtcProcess::quoteArg(executable.toUserOutput());
if (workingDir.isEmpty()) if (workingDir.isEmpty())
return tr("Running: %1 %2").arg(nativeExecutable, args) + QLatin1Char('\n'); return tr("Running: %1 %2").arg(nativeExecutable, args) + QLatin1Char('\n');
return tr("Running in %1: %2 %3"). return tr("Running in %1: %2 %3").
@@ -465,7 +466,7 @@ void VcsOutputWindow::appendShellCommandLine(const QString &text)
} }
void VcsOutputWindow::appendCommand(const QString &workingDirectory, void VcsOutputWindow::appendCommand(const QString &workingDirectory,
const Utils::FileName &binary, const FileName &binary,
const QStringList &args) const QStringList &args)
{ {
appendShellCommandLine(msgExecutionLogEntry(workingDirectory, binary, args)); appendShellCommandLine(msgExecutionLogEntry(workingDirectory, binary, args));

View File

@@ -35,6 +35,8 @@
#include <limits> #include <limits>
using namespace Utils;
namespace { namespace {
class PathMatcher class PathMatcher
@@ -44,7 +46,7 @@ public:
ProjectExplorer::Project *project() { return m_project; } ProjectExplorer::Project *project() { return m_project; }
void match(ProjectExplorer::Project *project, void match(ProjectExplorer::Project *project,
const Utils::FileName &base, const Utils::FileName &child) { const FileName &base, const FileName &child) {
int count = std::numeric_limits<int>::max(); int count = std::numeric_limits<int>::max();
if (child.isChildOf(base)) { if (child.isChildOf(base)) {
const QString relative = child.toString().mid(base.count() + 1); const QString relative = child.toString().mid(base.count() + 1);
@@ -98,7 +100,7 @@ ProjectExplorer::Project *VcsProjectCache::projectFor(const QString &repo)
return m_instance->m_cache.at(0).project; return m_instance->m_cache.at(0).project;
} }
project = projectForToplevel(Utils::FileName::fromString(repo)); project = projectForToplevel(FileName::fromString(repo));
m_instance->m_cache.prepend(CacheNode(repo, project)); m_instance->m_cache.prepend(CacheNode(repo, project));
while (m_instance->m_cache.count() > 10) while (m_instance->m_cache.count() > 10)
m_instance->m_cache.removeLast(); m_instance->m_cache.removeLast();
@@ -121,12 +123,12 @@ void VcsProjectCache::destroy()
delete m_instance; delete m_instance;
} }
ProjectExplorer::Project *VcsProjectCache::projectForToplevel(const Utils::FileName &vcsTopLevel) ProjectExplorer::Project *VcsProjectCache::projectForToplevel(const FileName &vcsTopLevel)
{ {
PathMatcher parentMatcher; PathMatcher parentMatcher;
PathMatcher childMatcher; PathMatcher childMatcher;
for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) { for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) {
const Utils::FileName projectDir = project->projectDirectory(); const FileName projectDir = project->projectDirectory();
if (projectDir == vcsTopLevel) if (projectDir == vcsTopLevel)
return project; return project;
parentMatcher.match(project, vcsTopLevel, projectDir); parentMatcher.match(project, vcsTopLevel, projectDir);

View File

@@ -40,6 +40,7 @@
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace VcsBase { namespace VcsBase {
namespace Internal { namespace Internal {
@@ -68,8 +69,7 @@ VcsCommandPageFactory::VcsCommandPageFactory()
setTypeIdsSuffix(QLatin1String("VcsCommand")); setTypeIdsSuffix(QLatin1String("VcsCommand"));
} }
Utils::WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, const QVariant &data)
const QVariant &data)
{ {
Q_UNUSED(wizard); Q_UNUSED(wizard);
@@ -286,8 +286,8 @@ void VcsCommandPage::delayedInitialize()
extraArgs << tmp; extraArgs << tmp;
} }
ShellCommand *command Core::ShellCommand *command
= vc->createInitialCheckoutCommand(repo, Utils::FileName::fromString(base), = vc->createInitialCheckoutCommand(repo, FileName::fromString(base),
name, extraArgs); name, extraArgs);
foreach (const JobData &job, m_additionalJobs) { foreach (const JobData &job, m_additionalJobs) {
@@ -310,7 +310,7 @@ void VcsCommandPage::delayedInitialize()
const QString dir = wiz->expander()->expand(job.workDirectory); const QString dir = wiz->expander()->expand(job.workDirectory);
const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor; const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor;
command->addJob(Utils::FileName::fromUserInput(commandString), args, timeoutS, dir); command->addJob(FileName::fromUserInput(commandString), args, timeoutS, dir);
} }
start(command); start(command);