forked from qt-creator/qt-creator
ClearCasePlugin: Introduce runCleartoolProc
Don't use VcsCommand when the only passed flag is NoOutput as in this case VcsCommand is the same as QtcProcess. Add runCleartoolProc and implement it using QtcProcess. Use it whenever NoOutput has been passed to runCommand. Some codepath, like runCleartoolSync() or ccGetActiveVobs() has been called from non-GUI thread - be on the safe side and use QtcProcess in these cases. Change-Id: I2d29947393bd43af193a53e3f8e89e1b6b4b86fa Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -255,6 +255,8 @@ private:
|
|||||||
IEditor *showOutputInEditor(const QString& title, const QString &output, Id id,
|
IEditor *showOutputInEditor(const QString& title, const QString &output, Id id,
|
||||||
const QString &source, QTextCodec *codec) const;
|
const QString &source, QTextCodec *codec) const;
|
||||||
QString runCleartoolSync(const FilePath &workingDir, const QStringList &arguments) const;
|
QString runCleartoolSync(const FilePath &workingDir, const QStringList &arguments) const;
|
||||||
|
CommandResult runCleartoolProc(const FilePath &workingDir,
|
||||||
|
const QStringList &arguments) const;
|
||||||
CommandResult runCleartool(const FilePath &workingDir, const QStringList &arguments,
|
CommandResult runCleartool(const FilePath &workingDir, const QStringList &arguments,
|
||||||
unsigned flags = 0, QTextCodec *codec = nullptr,
|
unsigned flags = 0, QTextCodec *codec = nullptr,
|
||||||
int timeoutMultiplier = 1) const;
|
int timeoutMultiplier = 1) const;
|
||||||
@@ -375,10 +377,7 @@ bool ClearCasePluginPrivate::isCheckInEditorOpen() const
|
|||||||
/// Files in this directories are under ClearCase control
|
/// Files in this directories are under ClearCase control
|
||||||
QStringList ClearCasePluginPrivate::getVobList() const
|
QStringList ClearCasePluginPrivate::getVobList() const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("lsvob"));
|
const CommandResult result = runCleartoolProc(currentState().topLevel(), {"lsvob", "-s"});
|
||||||
args << QLatin1String("-s");
|
|
||||||
const CommandResult result = runCleartool(currentState().topLevel(), args,
|
|
||||||
VcsCommand::NoOutput);
|
|
||||||
return result.cleanedStdOut().split(QLatin1Char('\n'), Qt::SkipEmptyParts);
|
return result.cleanedStdOut().split(QLatin1Char('\n'), Qt::SkipEmptyParts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -499,8 +498,7 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const QString &fileName
|
|||||||
/// \returns The ClearCase topLevel/VOB directory for this directory
|
/// \returns The ClearCase topLevel/VOB directory for this directory
|
||||||
QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) const
|
QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("pwv"));
|
const CommandResult result = runCleartoolProc(directory, {"pwv"});
|
||||||
const CommandResult result = runCleartool(directory, args, VcsCommand::NoOutput);
|
|
||||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -543,9 +541,7 @@ QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) co
|
|||||||
/// Find the root path of a clearcase view. Precondition: This is a clearcase managed dir
|
/// Find the root path of a clearcase view. Precondition: This is a clearcase managed dir
|
||||||
QString ClearCasePluginPrivate::ccViewRoot(const FilePath &directory) const
|
QString ClearCasePluginPrivate::ccViewRoot(const FilePath &directory) const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("pwv"));
|
const CommandResult result = runCleartoolProc(directory, {"pwv", "-root"});
|
||||||
args << QLatin1String("-root");
|
|
||||||
const CommandResult result = runCleartool(directory, args, VcsCommand::NoOutput);
|
|
||||||
QString root = result.cleanedStdOut().trimmed();
|
QString root = result.cleanedStdOut().trimmed();
|
||||||
if (root.isEmpty()) {
|
if (root.isEmpty()) {
|
||||||
if (HostOsInfo::isWindowsHost())
|
if (HostOsInfo::isWindowsHost())
|
||||||
@@ -817,10 +813,8 @@ static void setWorkingDirectory(IEditor *editor, const FilePath &wd)
|
|||||||
//! retrieve full location of predecessor of \a version
|
//! retrieve full location of predecessor of \a version
|
||||||
QString ClearCasePluginPrivate::ccGetPredecessor(const QString &version) const
|
QString ClearCasePluginPrivate::ccGetPredecessor(const QString &version) const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("describe"));
|
const CommandResult result = runCleartoolProc(currentState().topLevel(),
|
||||||
args << QLatin1String("-fmt") << QLatin1String("%En@@%PSn") << version;
|
{"describe", "-fmt", "%En@@%PSn", version});
|
||||||
const CommandResult result = runCleartool(currentState().topLevel(), args,
|
|
||||||
VcsCommand::NoOutput);
|
|
||||||
if (result.result() != ProcessResult::FinishedWithSuccess
|
if (result.result() != ProcessResult::FinishedWithSuccess
|
||||||
|| result.cleanedStdOut().endsWith(QLatin1Char('@'))) {// <name-unknown>@@
|
|| result.cleanedStdOut().endsWith(QLatin1Char('@'))) {// <name-unknown>@@
|
||||||
return {};
|
return {};
|
||||||
@@ -832,11 +826,9 @@ QString ClearCasePluginPrivate::ccGetPredecessor(const QString &version) const
|
|||||||
//! Paths are relative to viewRoot
|
//! Paths are relative to viewRoot
|
||||||
QStringList ClearCasePluginPrivate::ccGetActiveVobs() const
|
QStringList ClearCasePluginPrivate::ccGetActiveVobs() const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("lsvob"));
|
|
||||||
const QString theViewRoot = viewRoot();
|
const QString theViewRoot = viewRoot();
|
||||||
|
|
||||||
const CommandResult result = runCleartool(FilePath::fromString(theViewRoot), args,
|
const CommandResult result = runCleartoolProc(FilePath::fromString(theViewRoot), {"lsvob"});
|
||||||
VcsCommand::NoOutput);
|
|
||||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
@@ -886,10 +878,7 @@ FileStatus ClearCasePluginPrivate::vcsStatus(const QString &file) const
|
|||||||
|
|
||||||
QString ClearCasePluginPrivate::ccGetFileActivity(const FilePath &workingDir, const QString &file)
|
QString ClearCasePluginPrivate::ccGetFileActivity(const FilePath &workingDir, const QString &file)
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("lscheckout"));
|
return runCleartoolProc(workingDir, {"lscheckout", "-fmt", "%[activity]p", file}).cleanedStdOut();
|
||||||
args << QLatin1String("-fmt") << QLatin1String("%[activity]p");
|
|
||||||
args << file;
|
|
||||||
return runCleartool(workingDir, args, VcsCommand::NoOutput).cleanedStdOut();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearCaseSubmitEditor *ClearCasePluginPrivate::openClearCaseSubmitEditor(const FilePath &filePath, bool isUcm)
|
ClearCaseSubmitEditor *ClearCasePluginPrivate::openClearCaseSubmitEditor(const FilePath &filePath, bool isUcm)
|
||||||
@@ -1238,9 +1227,8 @@ void ClearCasePluginPrivate::ccDiffWithPred(const FilePath &workingDir, const QS
|
|||||||
|
|
||||||
QStringList ClearCasePluginPrivate::ccGetActivityVersions(const FilePath &workingDir, const QString &activity)
|
QStringList ClearCasePluginPrivate::ccGetActivityVersions(const FilePath &workingDir, const QString &activity)
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("lsactivity"));
|
const CommandResult result = runCleartoolProc(workingDir, {"lsactivity", "-fmt",
|
||||||
args << QLatin1String("-fmt") << QLatin1String("%[versions]Cp") << activity;
|
"%[versions]Cp", activity});
|
||||||
const CommandResult result = runCleartool(workingDir, args, VcsCommand::NoOutput);
|
|
||||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
QStringList versions = result.cleanedStdOut().split(QLatin1String(", "));
|
QStringList versions = result.cleanedStdOut().split(QLatin1String(", "));
|
||||||
@@ -1640,7 +1628,24 @@ void ClearCasePluginPrivate::commitFromEditor()
|
|||||||
QString ClearCasePluginPrivate::runCleartoolSync(const FilePath &workingDir,
|
QString ClearCasePluginPrivate::runCleartoolSync(const FilePath &workingDir,
|
||||||
const QStringList &arguments) const
|
const QStringList &arguments) const
|
||||||
{
|
{
|
||||||
return runCleartool(workingDir, arguments, VcsCommand::NoOutput).cleanedStdOut();
|
return runCleartoolProc(workingDir, arguments).cleanedStdOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandResult ClearCasePluginPrivate::runCleartoolProc(const FilePath &workingDir,
|
||||||
|
const QStringList &arguments) const
|
||||||
|
{
|
||||||
|
if (m_settings.ccBinaryPath.isEmpty())
|
||||||
|
return CommandResult(ProcessResult::StartFailed, Tr::tr("No ClearCase executable specified."));
|
||||||
|
|
||||||
|
QtcProcess process;
|
||||||
|
Environment env = Environment::systemEnvironment();
|
||||||
|
VcsBase::setProcessEnvironment(&env);
|
||||||
|
process.setEnvironment(env);
|
||||||
|
process.setCommand({m_settings.ccBinaryPath, arguments});
|
||||||
|
process.setWorkingDirectory(workingDir);
|
||||||
|
process.setTimeoutS(m_settings.timeOutS);
|
||||||
|
process.runBlocking();
|
||||||
|
return CommandResult(&process);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult ClearCasePluginPrivate::runCleartool(const FilePath &workingDir,
|
CommandResult ClearCasePluginPrivate::runCleartool(const FilePath &workingDir,
|
||||||
@@ -2228,9 +2233,7 @@ QString ClearCasePluginPrivate::getFile(const QString &nativeFile, const QString
|
|||||||
bool res = QFile::copy(QDir(m_topLevel.toString()).absoluteFilePath(file), tempFile);
|
bool res = QFile::copy(QDir(m_topLevel.toString()).absoluteFilePath(file), tempFile);
|
||||||
return res ? tempFile : QString();
|
return res ? tempFile : QString();
|
||||||
}
|
}
|
||||||
QStringList args(QLatin1String("get"));
|
const CommandResult result = runCleartoolProc(m_topLevel, {"get", "-to", tempFile, nativeFile});
|
||||||
args << QLatin1String("-to") << tempFile << nativeFile;
|
|
||||||
const CommandResult result = runCleartool(m_topLevel, args, VcsCommand::NoOutput);
|
|
||||||
if (result.result() != ProcessResult::FinishedWithSuccess)
|
if (result.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return {};
|
return {};
|
||||||
QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser |
|
QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser |
|
||||||
|
Reference in New Issue
Block a user