forked from qt-creator/qt-creator
ClearCase: Drop QRegExp use
Change-Id: Ia47d2efec42e9df59c5d30a695b4becee942e085 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -89,7 +89,7 @@
|
|||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
@@ -490,7 +490,7 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const QString &fileName
|
|||||||
return FileStatus::Derived;
|
return FileStatus::Derived;
|
||||||
|
|
||||||
// find first whitespace. anything before that is not interesting
|
// find first whitespace. anything before that is not interesting
|
||||||
const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
|
const int wspos = buffer.indexOf(QRegularExpression("\\s"));
|
||||||
if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
|
if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
|
||||||
return FileStatus::CheckedOut;
|
return FileStatus::CheckedOut;
|
||||||
else
|
else
|
||||||
@@ -1303,7 +1303,7 @@ void ClearCasePluginPrivate::diffActivity()
|
|||||||
|
|
||||||
// pre-first version. only for the first occurrence
|
// pre-first version. only for the first occurrence
|
||||||
if (filever[file].first.isEmpty()) {
|
if (filever[file].first.isEmpty()) {
|
||||||
int verpos = shortver.lastIndexOf(QRegExp(QLatin1String("[^0-9]"))) + 1;
|
int verpos = shortver.lastIndexOf(QRegularExpression("[^0-9]")) + 1;
|
||||||
int vernum = shortver.midRef(verpos).toInt();
|
int vernum = shortver.midRef(verpos).toInt();
|
||||||
if (vernum)
|
if (vernum)
|
||||||
--vernum;
|
--vernum;
|
||||||
@@ -1890,11 +1890,12 @@ bool ClearCasePluginPrivate::vcsCheckIn(const QString &messageFile, const QStrin
|
|||||||
const ClearCaseResponse response =
|
const ClearCaseResponse response =
|
||||||
runCleartool(m_checkInView, args, m_settings.longTimeOutS(),
|
runCleartool(m_checkInView, args, m_settings.longTimeOutS(),
|
||||||
VcsCommand::ShowStdOut);
|
VcsCommand::ShowStdOut);
|
||||||
QRegExp checkedIn(QLatin1String("Checked in \\\"([^\"]*)\\\""));
|
const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\"");
|
||||||
|
QRegularExpressionMatch match = checkedIn.match(response.stdOut);
|
||||||
bool anySucceeded = false;
|
bool anySucceeded = false;
|
||||||
int offset = checkedIn.indexIn(response.stdOut);
|
int offset = match.capturedStart();
|
||||||
while (offset != -1) {
|
while (match.hasMatch()) {
|
||||||
QString file = checkedIn.cap(1);
|
QString file = match.captured(1);
|
||||||
QFileInfo fi(m_checkInView, file);
|
QFileInfo fi(m_checkInView, file);
|
||||||
QString absPath = fi.absoluteFilePath();
|
QString absPath = fi.absoluteFilePath();
|
||||||
|
|
||||||
@@ -1902,7 +1903,8 @@ bool ClearCasePluginPrivate::vcsCheckIn(const QString &messageFile, const QStrin
|
|||||||
setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn);
|
setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn);
|
||||||
emit filesChanged(files);
|
emit filesChanged(files);
|
||||||
anySucceeded = true;
|
anySucceeded = true;
|
||||||
offset = checkedIn.indexIn(response.stdOut, offset + 12);
|
match = checkedIn.match(response.stdOut, offset + 12);
|
||||||
|
offset = match.capturedStart();
|
||||||
}
|
}
|
||||||
return anySucceeded;
|
return anySucceeded;
|
||||||
}
|
}
|
||||||
@@ -2139,7 +2141,7 @@ bool ClearCasePluginPrivate::ccCheckUcm(const QString &viewname, const QString &
|
|||||||
QString catcsData = runCleartoolSync(workingDir, catcsArgs);
|
QString catcsData = runCleartoolSync(workingDir, catcsArgs);
|
||||||
|
|
||||||
// check output for the word "ucm"
|
// check output for the word "ucm"
|
||||||
return QRegExp(QLatin1String("(^|\\n)ucm\\n")).indexIn(catcsData) != -1;
|
return catcsData.indexOf(QRegularExpression("(^|\\n)ucm\\n")) != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClearCasePluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
|
bool ClearCasePluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
|
||||||
@@ -2182,9 +2184,10 @@ void ClearCasePluginPrivate::updateStreamAndView()
|
|||||||
const QString sresponse = runCleartoolSync(m_topLevel, args);
|
const QString sresponse = runCleartoolSync(m_topLevel, args);
|
||||||
int tabPos = sresponse.indexOf(QLatin1Char('\t'));
|
int tabPos = sresponse.indexOf(QLatin1Char('\t'));
|
||||||
m_stream = sresponse.left(tabPos);
|
m_stream = sresponse.left(tabPos);
|
||||||
QRegExp intStreamExp(QLatin1String("stream:([^@]*)"));
|
const QRegularExpression intStreamExp("stream:([^@]*)");
|
||||||
if (intStreamExp.indexIn(sresponse.mid(tabPos + 1)) != -1)
|
const QRegularExpressionMatch match = intStreamExp.match(sresponse.mid(tabPos + 1));
|
||||||
m_intStream = intStreamExp.cap(1);
|
if (match.hasMatch())
|
||||||
|
m_intStream = match.captured(1);
|
||||||
m_viewData = ccGetView(m_topLevel);
|
m_viewData = ccGetView(m_topLevel);
|
||||||
m_updateViewAction->setParameter(m_viewData.isDynamic ? QString() : m_viewData.name);
|
m_updateViewAction->setParameter(m_viewData.isDynamic ? QString() : m_viewData.name);
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -85,17 +85,19 @@ void ClearCaseSync::processCleartoolLsLine(const QDir &viewRootDir, const QStrin
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// find first whitespace. anything before that is not interesting
|
// find first whitespace. anything before that is not interesting
|
||||||
const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
|
const int wspos = buffer.indexOf(QRegularExpression("\\s"));
|
||||||
const QString absFile =
|
const QString absFile =
|
||||||
viewRootDir.absoluteFilePath(
|
viewRootDir.absoluteFilePath(
|
||||||
QDir::fromNativeSeparators(buffer.left(atatpos)));
|
QDir::fromNativeSeparators(buffer.left(atatpos)));
|
||||||
QTC_CHECK(QFileInfo::exists(absFile));
|
QTC_CHECK(QFileInfo::exists(absFile));
|
||||||
QTC_CHECK(!absFile.isEmpty());
|
QTC_CHECK(!absFile.isEmpty());
|
||||||
|
|
||||||
QString ccState;
|
const QRegularExpression reState("^\\s*\\[[^\\]]*\\]"); // [hijacked]; [loaded but missing]
|
||||||
const QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing]
|
const QRegularExpressionMatch match = reState.match(buffer, wspos + 1,
|
||||||
if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
|
QRegularExpression::NormalMatch,
|
||||||
ccState = reState.cap();
|
QRegularExpression::AnchorAtOffsetMatchOption);
|
||||||
|
if (match.hasMatch()) {
|
||||||
|
const QString ccState = match.captured();
|
||||||
if (ccState.indexOf(QLatin1String("hijacked")) != -1)
|
if (ccState.indexOf(QLatin1String("hijacked")) != -1)
|
||||||
ClearCasePlugin::setStatus(absFile, FileStatus::Hijacked, true);
|
ClearCasePlugin::setStatus(absFile, FileStatus::Hijacked, true);
|
||||||
else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
|
else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include "versionselector.h"
|
#include "versionselector.h"
|
||||||
#include "ui_versionselector.h"
|
#include "ui_versionselector.h"
|
||||||
|
|
||||||
#include <QRegExp>
|
#include <QRegularExpression>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
namespace ClearCase {
|
namespace ClearCase {
|
||||||
@@ -73,20 +73,26 @@ bool VersionSelector::readValues()
|
|||||||
{
|
{
|
||||||
QString line;
|
QString line;
|
||||||
line = m_stream->readLine();
|
line = m_stream->readLine();
|
||||||
QRegExp id(QLatin1String("Version ID: (.*)"));
|
const QRegularExpression id("Version ID: (.*)");
|
||||||
if (id.indexIn(line) == -1)
|
const QRegularExpressionMatch idMatch = id.match(line);
|
||||||
|
if (!idMatch.hasMatch())
|
||||||
return false;
|
return false;
|
||||||
m_versionID = id.cap(1);
|
m_versionID = idMatch.captured(1);
|
||||||
|
|
||||||
line = m_stream->readLine();
|
line = m_stream->readLine();
|
||||||
QRegExp owner(QLatin1String("Created by: (.*)"));
|
const QRegularExpression owner("Created by: (.*)");
|
||||||
if (owner.indexIn(line) == -1)
|
const QRegularExpressionMatch ownerMatch = owner.match(line);
|
||||||
|
if (!ownerMatch.hasMatch())
|
||||||
return false;
|
return false;
|
||||||
m_createdBy = owner.cap(1);
|
m_createdBy = ownerMatch.captured(1);
|
||||||
|
|
||||||
line = m_stream->readLine();
|
line = m_stream->readLine();
|
||||||
QRegExp dateTimeRE(QLatin1String("Created on: (.*)"));
|
const QRegularExpression dateTimeRE("Created on: (.*)");
|
||||||
if (dateTimeRE.indexIn(line) == -1)
|
const QRegularExpressionMatch dateTimeMatch = dateTimeRE.match(line);
|
||||||
|
if (!dateTimeMatch.hasMatch())
|
||||||
return false;
|
return false;
|
||||||
m_createdOn = dateTimeRE.cap(1);
|
m_createdOn = dateTimeMatch.captured(1);
|
||||||
|
|
||||||
QStringList messageLines;
|
QStringList messageLines;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user