forked from qt-creator/qt-creator
Do some cleanup
Change-Id: Ia63ed85397a4a86f8037797aa899253e9bcf3913 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -58,8 +58,7 @@ void CommitEditor::setFields(const QString &repositoryRoot, const BranchInfo &br
|
||||
|
||||
m_fileModel = new VcsBase::SubmitFileModel(this);
|
||||
m_fileModel->setRepositoryRoot(repositoryRoot);
|
||||
m_fileModel->setFileStatusQualifier([](const QString &status, const QVariant &)
|
||||
-> VcsBase::SubmitFileModel::FileStatusHint {
|
||||
m_fileModel->setFileStatusQualifier([](const QString &status, const QVariant &) {
|
||||
if (status == Constants::FSTATUS_ADDED
|
||||
|| status == Constants::FSTATUS_ADDED_BY_MERGE
|
||||
|| status == Constants::FSTATUS_ADDED_BY_INTEGRATE) {
|
||||
|
||||
@@ -37,12 +37,12 @@ namespace Internal {
|
||||
|
||||
class ConfigureDialogPrivate {
|
||||
public:
|
||||
RepositorySettings settings() {
|
||||
m_settings.user = m_ui.userLineEdit->text().trimmed();
|
||||
m_settings.sslIdentityFile = m_ui.sslIdentityFilePathChooser->filePath().toString();
|
||||
m_settings.autosync = m_ui.disableAutosyncCheckBox->isChecked()
|
||||
? RepositorySettings::AutosyncOff : RepositorySettings::AutosyncOn;
|
||||
return m_settings;
|
||||
RepositorySettings settings() const
|
||||
{
|
||||
return {m_ui.userLineEdit->text().trimmed(),
|
||||
m_ui.sslIdentityFilePathChooser->filePath().toString(),
|
||||
m_ui.disableAutosyncCheckBox->isChecked()
|
||||
? RepositorySettings::AutosyncOff : RepositorySettings::AutosyncOn};
|
||||
}
|
||||
|
||||
void updateUi() {
|
||||
|
||||
@@ -121,7 +121,6 @@ public:
|
||||
QTC_ASSERT(client, return);
|
||||
addReloadButton();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class FossilLogConfig : public VcsBaseEditorConfig
|
||||
@@ -214,12 +213,10 @@ public:
|
||||
}
|
||||
args << params[i];
|
||||
}
|
||||
|
||||
} else {
|
||||
args << arg;
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
@@ -283,7 +280,8 @@ unsigned int FossilClient::synchronousBinaryVersion() const
|
||||
return makeVersionNumber(major, minor, patch);
|
||||
}
|
||||
|
||||
QList<BranchInfo> FossilClient::branchListFromOutput(const QString &output, const BranchInfo::BranchFlags defaultFlags)
|
||||
QList<BranchInfo> FossilClient::branchListFromOutput(const QString &output,
|
||||
const BranchInfo::BranchFlags defaultFlags)
|
||||
{
|
||||
// Branch list format:
|
||||
// " branch-name"
|
||||
@@ -301,12 +299,12 @@ QList<BranchInfo> FossilClient::branchListFromOutput(const QString &output, cons
|
||||
BranchInfo FossilClient::synchronousCurrentBranch(const FilePath &workingDirectory)
|
||||
{
|
||||
if (workingDirectory.isEmpty())
|
||||
return BranchInfo();
|
||||
return {};
|
||||
|
||||
// First try to get the current branch from the list of open branches
|
||||
const CommandResult result = vcsSynchronousExec(workingDirectory, {"branch", "list"});
|
||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||
return BranchInfo();
|
||||
return {};
|
||||
|
||||
const QString output = sanitizeFossilOutput(result.cleanedStdOut());
|
||||
BranchInfo currentBranch = Utils::findOrDefault(branchListFromOutput(output), [](const BranchInfo &b) {
|
||||
@@ -318,7 +316,7 @@ BranchInfo FossilClient::synchronousCurrentBranch(const FilePath &workingDirecto
|
||||
const CommandResult result = vcsSynchronousExec(workingDirectory,
|
||||
{"branch", "list", "--closed"});
|
||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||
return BranchInfo();
|
||||
return {};
|
||||
|
||||
const QString output = sanitizeFossilOutput(result.cleanedStdOut());
|
||||
currentBranch = Utils::findOrDefault(branchListFromOutput(output, BranchInfo::Closed), [](const BranchInfo &b) {
|
||||
@@ -532,20 +530,17 @@ bool FossilClient::synchronousConfigureRepository(const FilePath &workingDirecto
|
||||
const bool applyAll = (currentSettings == RepositorySettings());
|
||||
|
||||
if (!newSettings.user.isEmpty()
|
||||
&& (applyAll
|
||||
|| newSettings.user != currentSettings.user)
|
||||
&& (applyAll || newSettings.user != currentSettings.user)
|
||||
&& !synchronousSetUserDefault(workingDirectory, newSettings.user)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((applyAll
|
||||
|| newSettings.sslIdentityFile != currentSettings.sslIdentityFile)
|
||||
if ((applyAll || newSettings.sslIdentityFile != currentSettings.sslIdentityFile)
|
||||
&& !synchronousSetSetting(workingDirectory, "ssl-identity", newSettings.sslIdentityFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (applyAll
|
||||
|| newSettings.autosync != currentSettings.autosync) {
|
||||
if (applyAll || newSettings.autosync != currentSettings.autosync) {
|
||||
QString value;
|
||||
switch (newSettings.autosync) {
|
||||
case RepositorySettings::AutosyncOff:
|
||||
@@ -758,8 +753,6 @@ VcsBaseEditorWidget *FossilClient::annotate(const FilePath &workingDir, const QS
|
||||
if (VcsBaseEditorConfig *editorConfig = fossilEditor->editorConfig())
|
||||
effectiveArgs = editorConfig->arguments();
|
||||
|
||||
VcsCommand *cmd = createCommand(workingDir, fossilEditor);
|
||||
|
||||
// here we introduce a "|BLAME|" meta-option to allow both annotate and blame modes
|
||||
int pos = effectiveArgs.indexOf("|BLAME|");
|
||||
if (pos != -1) {
|
||||
@@ -767,10 +760,8 @@ VcsBaseEditorWidget *FossilClient::annotate(const FilePath &workingDir, const QS
|
||||
effectiveArgs.removeAt(pos);
|
||||
}
|
||||
QStringList args(vcsCmdString);
|
||||
if (!revision.isEmpty()
|
||||
&& supportedFeatures().testFlag(AnnotateRevisionFeature))
|
||||
if (!revision.isEmpty() && supportedFeatures().testFlag(AnnotateRevisionFeature))
|
||||
args << "-r" << revision;
|
||||
|
||||
args << effectiveArgs << file;
|
||||
|
||||
// When version list requested, ignore the source line.
|
||||
@@ -778,7 +769,7 @@ VcsBaseEditorWidget *FossilClient::annotate(const FilePath &workingDir, const QS
|
||||
lineNumber = -1;
|
||||
editor->setDefaultLineNumber(lineNumber);
|
||||
|
||||
enqueueJob(cmd, args);
|
||||
enqueueJob(createCommand(workingDir, fossilEditor), args);
|
||||
return fossilEditor;
|
||||
}
|
||||
|
||||
@@ -816,8 +807,7 @@ unsigned int FossilClient::binaryVersion() const
|
||||
|
||||
// Invalidate cache on failed version result.
|
||||
// Assume that fossil client options have been changed and will change again.
|
||||
if (!cachedBinaryVersion
|
||||
|| currentBinaryPath != cachedBinaryPath) {
|
||||
if (!cachedBinaryVersion || currentBinaryPath != cachedBinaryPath) {
|
||||
cachedBinaryVersion = synchronousBinaryVersion();
|
||||
if (cachedBinaryVersion)
|
||||
cachedBinaryPath = currentBinaryPath;
|
||||
@@ -1037,12 +1027,11 @@ void FossilClient::revertFile(const FilePath &workingDir,
|
||||
QStringList args(vcsCommandString(RevertCommand));
|
||||
if (!revision.isEmpty())
|
||||
args << "-r" << revision;
|
||||
|
||||
args << extraOptions << file;
|
||||
|
||||
// Indicate file list
|
||||
VcsCommand *cmd = createCommand(workingDir);
|
||||
const QStringList files = QStringList(workingDir.toString() + "/" + file);
|
||||
const QStringList files = {workingDir.toString() + "/" + file};
|
||||
connect(cmd, &VcsCommand::done, this, [this, files, cmd] {
|
||||
if (cmd->result() == ProcessResult::FinishedWithSuccess)
|
||||
emit changed(files);
|
||||
@@ -1059,15 +1048,10 @@ void FossilClient::revertAll(const FilePath &workingDir, const QString &revision
|
||||
// Thus undo for whole tree revert should not be possible.
|
||||
|
||||
QStringList args;
|
||||
if (revision.isEmpty()) {
|
||||
args << vcsCommandString(RevertCommand)
|
||||
<< extraOptions;
|
||||
|
||||
} else {
|
||||
args << "checkout" << revision
|
||||
<< "--force"
|
||||
<< extraOptions;
|
||||
}
|
||||
if (revision.isEmpty())
|
||||
args << vcsCommandString(RevertCommand) << extraOptions;
|
||||
else
|
||||
args << "checkout" << revision << "--force" << extraOptions;
|
||||
|
||||
// Indicate repository change
|
||||
VcsCommand *cmd = createCommand(workingDir);
|
||||
@@ -1183,16 +1167,15 @@ FossilClient::StatusItem FossilClient::parseStatusLine(const QString &line) cons
|
||||
else if (label == "NOT_A_FILE")
|
||||
flags = Constants::FSTATUS_UNKNOWN;
|
||||
|
||||
|
||||
if (flags.isEmpty())
|
||||
return {};
|
||||
|
||||
// adjust the position to the last space before the file name
|
||||
for (int size = line.size(); (pos+1) < size && line[pos+1].isSpace(); ++pos) {}
|
||||
for (int size = line.size(); (pos + 1) < size && line[pos + 1].isSpace(); ++pos)
|
||||
;
|
||||
|
||||
item.flags = flags;
|
||||
item.file = line.mid(pos + 1);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
@@ -298,11 +298,6 @@ FossilClient *FossilPlugin::client()
|
||||
return &dd->m_client;
|
||||
}
|
||||
|
||||
void FossilPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &status)
|
||||
{
|
||||
dd->showCommitWidget(status);
|
||||
}
|
||||
|
||||
FossilPluginPrivate::FossilPluginPrivate()
|
||||
: VcsBase::VcsBasePluginPrivate(Core::Context(Constants::FOSSIL_CONTEXT))
|
||||
{
|
||||
@@ -688,12 +683,8 @@ void FossilPluginPrivate::commit()
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
m_submitRepository = state.topLevel();
|
||||
|
||||
connect(&m_client, &VcsBaseClient::parsedStatus,
|
||||
this, &FossilPluginPrivate::showCommitWidget);
|
||||
|
||||
QStringList extraOptions;
|
||||
m_client.emitParsedStatus(m_submitRepository, extraOptions);
|
||||
connect(&m_client, &VcsBaseClient::parsedStatus, this, &FossilPluginPrivate::showCommitWidget);
|
||||
m_client.emitParsedStatus(m_submitRepository, {});
|
||||
}
|
||||
|
||||
void FossilPluginPrivate::showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status)
|
||||
|
||||
@@ -50,8 +50,6 @@ public:
|
||||
static const FossilSettings &settings();
|
||||
static FossilClient *client();
|
||||
|
||||
static void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
private slots:
|
||||
void testDiffFileResolving_data();
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#include "fossilsettings.h"
|
||||
|
||||
#include "constants.h"
|
||||
#include "fossilclient.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
@@ -119,11 +118,6 @@ FossilSettings::FossilSettings()
|
||||
"Choose 0 to see all entries."));
|
||||
};
|
||||
|
||||
RepositorySettings::RepositorySettings()
|
||||
: autosync(AutosyncOn)
|
||||
{
|
||||
}
|
||||
|
||||
// OptionsPage
|
||||
|
||||
class OptionsPageWidget final : public Core::IOptionsPageWidget
|
||||
|
||||
@@ -51,20 +51,18 @@ public:
|
||||
|
||||
struct RepositorySettings
|
||||
{
|
||||
enum AutosyncMode {AutosyncOff = 0, AutosyncOn = 1, AutosyncPullOnly};
|
||||
enum AutosyncMode {AutosyncOff, AutosyncOn, AutosyncPullOnly};
|
||||
|
||||
QString user;
|
||||
AutosyncMode autosync;
|
||||
QString sslIdentityFile;
|
||||
|
||||
RepositorySettings();
|
||||
AutosyncMode autosync = AutosyncOn;
|
||||
};
|
||||
|
||||
inline bool operator==(const RepositorySettings &lh, const RepositorySettings &rh)
|
||||
{
|
||||
return (lh.user == rh.user
|
||||
&& lh.autosync == rh.autosync
|
||||
&& lh.sslIdentityFile == rh.sslIdentityFile);
|
||||
return (lh.user == rh.user &&
|
||||
lh.sslIdentityFile == rh.sslIdentityFile &&
|
||||
lh.autosync == rh.autosync);
|
||||
}
|
||||
|
||||
class OptionsPage : public Core::IOptionsPage
|
||||
|
||||
Reference in New Issue
Block a user