forked from qt-creator/qt-creator
ClearCase: Fix checking if a directory is managed
Now both dynamic and snapshot views are supported under both Unix/Linux and Windows. The implementation is based on "cleartool pwv" which gets the working view. Change-Id: I0d21d2c84fae4a641a3bac8b1087cfeffb89c447 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Knut Petter Svendsen <knutpett@pvv.org>
This commit is contained in:
committed by
Eike Ziller
parent
bedc477943
commit
c222a4f623
@@ -44,7 +44,7 @@ ClearCaseSync::ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap>
|
||||
{
|
||||
}
|
||||
|
||||
void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, QStringList &files)
|
||||
void ClearCaseSync::run(QFutureInterface<void> &future, QStringList &files)
|
||||
{
|
||||
ClearCaseSettings settings = m_plugin->settings();
|
||||
const QString program = settings.ccBinaryPath;
|
||||
@@ -66,8 +66,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
if (settings.disableIndexer)
|
||||
return;
|
||||
|
||||
const QDir topLevelDir(topLevel);
|
||||
const bool isDynamic = m_plugin->isDynamic();
|
||||
const QString viewRoot = m_plugin->viewRoot();
|
||||
const QDir viewRootDir(viewRoot);
|
||||
|
||||
QStringList args(QLatin1String("ls"));
|
||||
if (hot) {
|
||||
@@ -75,7 +76,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
// (might have become checked out)
|
||||
const StatusMap::Iterator send = m_statusMap->end();
|
||||
for (StatusMap::Iterator it = m_statusMap->begin(); it != send; ++it) {
|
||||
const QFileInfo fi(topLevel, it.key());
|
||||
const QFileInfo fi(viewRoot, it.key());
|
||||
const bool permChanged = it.value().permissions != fi.permissions();
|
||||
if (permChanged || it.value().status == FileStatus::Hijacked) {
|
||||
files.append(it.key());
|
||||
@@ -90,11 +91,11 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
} else {
|
||||
foreach (const QString &file, files) {
|
||||
if (isDynamic) { // assume a read only file is checked in
|
||||
const QFileInfo fi(topLevelDir, file);
|
||||
const QFileInfo fi(viewRootDir, file);
|
||||
if (!fi.isWritable())
|
||||
m_plugin->setStatus(topLevelDir.relativeFilePath(file), FileStatus::CheckedIn, false);
|
||||
m_plugin->setStatus(fi.absoluteFilePath(), FileStatus::CheckedIn, false);
|
||||
} else {
|
||||
m_plugin->setStatus(topLevelDir.relativeFilePath(file), FileStatus::Unknown, false);
|
||||
m_plugin->setStatus(viewRootDir.absoluteFilePath(file), FileStatus::Unknown, false);
|
||||
}
|
||||
}
|
||||
args << QLatin1String("-recurse");
|
||||
@@ -112,7 +113,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
// (we don't want it to become green)
|
||||
future.setProgressRange(0, total + 1);
|
||||
QProcess process;
|
||||
process.setWorkingDirectory(topLevel);
|
||||
process.setWorkingDirectory(viewRoot);
|
||||
|
||||
process.start(program, args);
|
||||
if (!process.waitForStarted())
|
||||
@@ -130,21 +131,24 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
if (atatpos != -1) { // probably managed file
|
||||
// find first whitespace. anything before that is not interesting
|
||||
const int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s")));
|
||||
const QString relFile = topLevelDir.relativeFilePath(QDir::fromNativeSeparators(buffer.left(atatpos)));
|
||||
const QString absFile =
|
||||
viewRootDir.absoluteFilePath(
|
||||
QDir::fromNativeSeparators(buffer.left(atatpos)));
|
||||
|
||||
QString ccState;
|
||||
const QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing]
|
||||
if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
|
||||
ccState = reState.cap();
|
||||
if (ccState.indexOf(QLatin1String("hijacked")) != -1)
|
||||
m_plugin->setStatus(relFile, FileStatus::Hijacked, true);
|
||||
m_plugin->setStatus(absFile, FileStatus::Hijacked, true);
|
||||
else if (ccState.indexOf(QLatin1String("loaded but missing")) != -1)
|
||||
m_plugin->setStatus(relFile, FileStatus::Missing, false);
|
||||
m_plugin->setStatus(absFile, FileStatus::Missing, false);
|
||||
}
|
||||
else if (buffer.lastIndexOf(QLatin1String("CHECKEDOUT"), wspos) != -1)
|
||||
m_plugin->setStatus(relFile, FileStatus::CheckedOut, true);
|
||||
m_plugin->setStatus(absFile, FileStatus::CheckedOut, true);
|
||||
// don't care about checked-in files not listed in project
|
||||
else if (m_statusMap->contains(relFile))
|
||||
m_plugin->setStatus(relFile, FileStatus::CheckedIn, true);
|
||||
else if (m_statusMap->contains(absFile))
|
||||
m_plugin->setStatus(absFile, FileStatus::CheckedIn, true);
|
||||
}
|
||||
buffer.clear();
|
||||
future.setProgressValue(qMin(total, ++processed));
|
||||
@@ -154,9 +158,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
|
||||
|
||||
if (!future.isCanceled()) {
|
||||
foreach (const QString &file, files) {
|
||||
const QString relFile = topLevelDir.relativeFilePath(file);
|
||||
if (m_statusMap->value(relFile).status == FileStatus::Unknown)
|
||||
m_plugin->setStatus(relFile, FileStatus::NotManaged, false);
|
||||
QString absFile = QFileInfo(file).absoluteFilePath();
|
||||
if (!m_statusMap->contains(absFile))
|
||||
m_plugin->setStatus(absFile, FileStatus::NotManaged, false);
|
||||
}
|
||||
future.setProgressValue(total + 1);
|
||||
if (!hot) {
|
||||
|
||||
Reference in New Issue
Block a user