forked from qt-creator/qt-creator
Fossil: Adapt to Make SynchronousProcess results more directly accessible
Change-Id: Ifd5f79ba50e38fdec9e3f5c412210a95d53e8a96 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -261,11 +261,12 @@ unsigned int FossilClient::synchronousBinaryVersion() const
|
|||||||
|
|
||||||
QStringList args("version");
|
QStringList args("version");
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(QString(), args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, QString(), args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
QString output = response.stdOut();
|
QString output = proc.stdOut();
|
||||||
output = output.trimmed();
|
output = output.trimmed();
|
||||||
|
|
||||||
// fossil version:
|
// fossil version:
|
||||||
@@ -299,22 +300,24 @@ BranchInfo FossilClient::synchronousCurrentBranch(const QString &workingDirector
|
|||||||
return BranchInfo();
|
return BranchInfo();
|
||||||
|
|
||||||
// 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 SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, {"branch", "list"});
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, {"branch", "list"});
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return BranchInfo();
|
return BranchInfo();
|
||||||
|
|
||||||
const QString output = sanitizeFossilOutput(response.stdOut());
|
const QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
BranchInfo currentBranch = Utils::findOrDefault(branchListFromOutput(output), [](const BranchInfo &b) {
|
BranchInfo currentBranch = Utils::findOrDefault(branchListFromOutput(output), [](const BranchInfo &b) {
|
||||||
return b.isCurrent();
|
return b.isCurrent();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!currentBranch.isCurrent()) {
|
if (!currentBranch.isCurrent()) {
|
||||||
// If not available from open branches, request it from the list of closed branches.
|
// If not available from open branches, request it from the list of closed branches.
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, {"branch", "list", "--closed"});
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, {"branch", "list", "--closed"});
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return BranchInfo();
|
return BranchInfo();
|
||||||
|
|
||||||
const QString output = sanitizeFossilOutput(response.stdOut());
|
const QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
currentBranch = Utils::findOrDefault(branchListFromOutput(output, BranchInfo::Closed), [](const BranchInfo &b) {
|
currentBranch = Utils::findOrDefault(branchListFromOutput(output, BranchInfo::Closed), [](const BranchInfo &b) {
|
||||||
return b.isCurrent();
|
return b.isCurrent();
|
||||||
});
|
});
|
||||||
@@ -332,19 +335,20 @@ QList<BranchInfo> FossilClient::synchronousBranchQuery(const QString &workingDir
|
|||||||
return QList<BranchInfo>();
|
return QList<BranchInfo>();
|
||||||
|
|
||||||
// First get list of open branches
|
// First get list of open branches
|
||||||
SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, {"branch", "list"});
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, {"branch", "list"});
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return QList<BranchInfo>();
|
return QList<BranchInfo>();
|
||||||
|
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
QList<BranchInfo> branches = branchListFromOutput(output);
|
QList<BranchInfo> branches = branchListFromOutput(output);
|
||||||
|
|
||||||
// Append a list of closed branches.
|
// Append a list of closed branches.
|
||||||
response = vcsFullySynchronousExec(workingDirectory, {"branch", "list", "--closed"});
|
vcsFullySynchronousExec(proc, workingDirectory, {"branch", "list", "--closed"});
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return QList<BranchInfo>();
|
return QList<BranchInfo>();
|
||||||
|
|
||||||
output = sanitizeFossilOutput(response.stdOut());
|
output = sanitizeFossilOutput(proc.stdOut());
|
||||||
branches.append(branchListFromOutput(output, BranchInfo::Closed));
|
branches.append(branchListFromOutput(output, BranchInfo::Closed));
|
||||||
|
|
||||||
std::sort(branches.begin(), branches.end(),
|
std::sort(branches.begin(), branches.end(),
|
||||||
@@ -379,12 +383,12 @@ RevisionInfo FossilClient::synchronousRevisionQuery(const QString &workingDirect
|
|||||||
if (!id.isEmpty())
|
if (!id.isEmpty())
|
||||||
args << id;
|
args << id;
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(
|
SynchronousProcess proc;
|
||||||
workingDirectory, args, ShellCommand::SuppressCommandLogging);
|
vcsFullySynchronousExec(proc, workingDirectory, args, ShellCommand::SuppressCommandLogging);
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return RevisionInfo();
|
return RevisionInfo();
|
||||||
|
|
||||||
const QString output = sanitizeFossilOutput(response.stdOut());
|
const QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
|
|
||||||
QString revisionId;
|
QString revisionId;
|
||||||
QString parentId;
|
QString parentId;
|
||||||
@@ -443,11 +447,12 @@ QStringList FossilClient::synchronousTagQuery(const QString &workingDirectory, c
|
|||||||
if (!id.isEmpty())
|
if (!id.isEmpty())
|
||||||
args << id;
|
args << id;
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return QStringList();
|
return QStringList();
|
||||||
|
|
||||||
const QString output = sanitizeFossilOutput(response.stdOut());
|
const QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
|
|
||||||
return output.split('\n', Qt::SkipEmptyParts);
|
return output.split('\n', Qt::SkipEmptyParts);
|
||||||
}
|
}
|
||||||
@@ -465,11 +470,12 @@ RepositorySettings FossilClient::synchronousSettingsQuery(const QString &working
|
|||||||
|
|
||||||
const QStringList args("settings");
|
const QStringList args("settings");
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return RepositorySettings();
|
return RepositorySettings();
|
||||||
|
|
||||||
const QString output = sanitizeFossilOutput(response.stdOut());
|
const QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
|
|
||||||
for (const QString &line : output.split('\n', Qt::SkipEmptyParts)) {
|
for (const QString &line : output.split('\n', Qt::SkipEmptyParts)) {
|
||||||
// parse settings line:
|
// parse settings line:
|
||||||
@@ -519,8 +525,9 @@ bool FossilClient::synchronousSetSetting(const QString &workingDirectory,
|
|||||||
if (isGlobal)
|
if (isGlobal)
|
||||||
args << "--global";
|
args << "--global";
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
return (response.result == SynchronousProcessResponse::Finished);
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
return (proc.result() == QtcProcess::Finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -575,11 +582,12 @@ QString FossilClient::synchronousUserDefaultQuery(const QString &workingDirector
|
|||||||
|
|
||||||
const QStringList args({"user", "default"});
|
const QStringList args({"user", "default"});
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
|
|
||||||
return output.trimmed();
|
return output.trimmed();
|
||||||
}
|
}
|
||||||
@@ -591,8 +599,9 @@ bool FossilClient::synchronousSetUserDefault(const QString &workingDirectory, co
|
|||||||
|
|
||||||
// set repository-default user
|
// set repository-default user
|
||||||
const QStringList args({"user", "default", userName, "--user", userName});
|
const QStringList args({"user", "default", userName, "--user", userName});
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
return (response.result == SynchronousProcessResponse::Finished);
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
return (proc.result() == QtcProcess::Finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString FossilClient::synchronousGetRepositoryURL(const QString &workingDirectory)
|
QString FossilClient::synchronousGetRepositoryURL(const QString &workingDirectory)
|
||||||
@@ -602,11 +611,12 @@ QString FossilClient::synchronousGetRepositoryURL(const QString &workingDirector
|
|||||||
|
|
||||||
const QStringList args("remote-url");
|
const QStringList args("remote-url");
|
||||||
|
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
output = output.trimmed();
|
output = output.trimmed();
|
||||||
|
|
||||||
// Fossil returns "off" when no remote-url is set.
|
// Fossil returns "off" when no remote-url is set.
|
||||||
@@ -655,40 +665,39 @@ bool FossilClient::synchronousCreateRepository(const QString &workingDirectory,
|
|||||||
if (!adminUser.isEmpty())
|
if (!adminUser.isEmpty())
|
||||||
args << "--admin-user" << adminUser;
|
args << "--admin-user" << adminUser;
|
||||||
args << extraOptions << repoFilePath.toUserOutput();
|
args << extraOptions << repoFilePath.toUserOutput();
|
||||||
SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
outputWindow->append(output);
|
outputWindow->append(output);
|
||||||
|
|
||||||
// check out the created repository file into the working directory
|
// check out the created repository file into the working directory
|
||||||
|
|
||||||
args.clear();
|
args.clear();
|
||||||
response.clear();
|
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
args << "open" << repoFilePath.toUserOutput();
|
args << "open" << repoFilePath.toUserOutput();
|
||||||
response = vcsFullySynchronousExec(workingDirectory, args);
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
output = sanitizeFossilOutput(response.stdOut());
|
output = sanitizeFossilOutput(proc.stdOut());
|
||||||
outputWindow->append(output);
|
outputWindow->append(output);
|
||||||
|
|
||||||
// set user default to admin if specified
|
// set user default to admin if specified
|
||||||
|
|
||||||
if (!adminUser.isEmpty()) {
|
if (!adminUser.isEmpty()) {
|
||||||
args.clear();
|
args.clear();
|
||||||
response.clear();
|
|
||||||
output.clear();
|
output.clear();
|
||||||
|
|
||||||
args << "user" << "default" << adminUser << "--user" << adminUser;
|
args << "user" << "default" << adminUser << "--user" << adminUser;
|
||||||
response = vcsFullySynchronousExec(workingDirectory, args);
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
outputWindow->append(output);
|
outputWindow->append(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -710,8 +719,9 @@ bool FossilClient::synchronousMove(const QString &workingDir,
|
|||||||
|
|
||||||
QStringList args(vcsCommandString(MoveCommand));
|
QStringList args(vcsCommandString(MoveCommand));
|
||||||
args << extraOptions << from << to;
|
args << extraOptions << from << to;
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDir, args);
|
SynchronousProcess proc;
|
||||||
return (response.result == SynchronousProcessResponse::Finished);
|
vcsFullySynchronousExec(proc, workingDir, args);
|
||||||
|
return (proc.result() == QtcProcess::Finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FossilClient::synchronousPull(const QString &workingDir, const QString &srcLocation, const QStringList &extraOptions)
|
bool FossilClient::synchronousPull(const QString &workingDir, const QString &srcLocation, const QStringList &extraOptions)
|
||||||
@@ -731,8 +741,9 @@ bool FossilClient::synchronousPull(const QString &workingDir, const QString &src
|
|||||||
VcsBase::VcsCommand::SshPasswordPrompt
|
VcsBase::VcsCommand::SshPasswordPrompt
|
||||||
| VcsBase::VcsCommand::ShowStdOut
|
| VcsBase::VcsCommand::ShowStdOut
|
||||||
| VcsBase::VcsCommand::ShowSuccessMessage;
|
| VcsBase::VcsCommand::ShowSuccessMessage;
|
||||||
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
|
SynchronousProcess proc;
|
||||||
const bool success = (resp.result == SynchronousProcessResponse::Finished);
|
vcsSynchronousExec(proc, workingDir, args, flags);
|
||||||
|
const bool success = (proc.result() == QtcProcess::Finished);
|
||||||
if (success)
|
if (success)
|
||||||
emit changed(QVariant(workingDir));
|
emit changed(QVariant(workingDir));
|
||||||
return success;
|
return success;
|
||||||
@@ -755,8 +766,9 @@ bool FossilClient::synchronousPush(const QString &workingDir, const QString &dst
|
|||||||
VcsBase::VcsCommand::SshPasswordPrompt
|
VcsBase::VcsCommand::SshPasswordPrompt
|
||||||
| VcsBase::VcsCommand::ShowStdOut
|
| VcsBase::VcsCommand::ShowStdOut
|
||||||
| VcsBase::VcsCommand::ShowSuccessMessage;
|
| VcsBase::VcsCommand::ShowSuccessMessage;
|
||||||
const SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags);
|
SynchronousProcess proc;
|
||||||
return (resp.result == SynchronousProcessResponse::Finished);
|
vcsSynchronousExec(proc, workingDir, args, flags);
|
||||||
|
return (proc.result() == QtcProcess::Finished);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FossilClient::commit(const QString &repositoryRoot, const QStringList &files,
|
void FossilClient::commit(const QString &repositoryRoot, const QStringList &files,
|
||||||
@@ -846,10 +858,11 @@ QString FossilClient::findTopLevelForFile(const QFileInfo &file) const
|
|||||||
bool FossilClient::managesFile(const QString &workingDirectory, const QString &fileName) const
|
bool FossilClient::managesFile(const QString &workingDirectory, const QString &fileName) const
|
||||||
{
|
{
|
||||||
const QStringList args({"finfo", fileName});
|
const QStringList args({"finfo", fileName});
|
||||||
const SynchronousProcessResponse response = vcsFullySynchronousExec(workingDirectory, args);
|
SynchronousProcess proc;
|
||||||
if (response.result != SynchronousProcessResponse::Finished)
|
vcsFullySynchronousExec(proc, workingDirectory, args);
|
||||||
|
if (proc.result() != QtcProcess::Finished)
|
||||||
return false;
|
return false;
|
||||||
QString output = sanitizeFossilOutput(response.stdOut());
|
QString output = sanitizeFossilOutput(proc.stdOut());
|
||||||
return !output.startsWith("no history for file", Qt::CaseInsensitive);
|
return !output.startsWith("no history for file", Qt::CaseInsensitive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user