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