Commit 629c1300 authored by Knut Petter Svendsen's avatar Knut Petter Svendsen Committed by Eike Ziller

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's avatarOrgad Shaneh <orgads@gmail.com>
parent 71f1919d
This diff is collapsed.
......@@ -107,6 +107,7 @@ public:
QString name;
bool isDynamic;
bool isUcm;
QString root;
};
class ClearCasePlugin : public VcsBase::VcsBasePlugin
......@@ -156,6 +157,7 @@ public:
const QString &fileName, const QString &file2 = QString());
FileStatus vcsStatus(const QString &file) const;
QString currentView() const { return m_viewData.name; }
QString viewRoot() const { return m_viewData.root; }
void refreshActivities();
inline bool isUcm() const { return m_viewData.isUcm; }
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
......@@ -206,6 +208,9 @@ protected:
private:
inline bool isCheckInEditorOpen() const;
QStringList getVobList() const;
QString ccManagesDirectory(const QString &directory) const;
QString ccViewRoot(const QString &directory) const;
QString findTopLevel(const QString &directory) const;
Core::IEditor *showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source,
......@@ -214,7 +219,7 @@ private:
ClearCaseResponse runCleartool(const QString &workingDir,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const;
static void sync(QFutureInterface<void> &future, QString topLevel, QStringList files);
static void sync(QFutureInterface<void> &future, QStringList files);
void history(const QString &workingDir,
const QStringList &file = QStringList(),
......@@ -233,6 +238,7 @@ private:
static void rmdir(const QString &path);
QString runExtDiff(const QString &workingDir, const QStringList &arguments,
int timeOut, QTextCodec *outputCodec = 0);
static QString getDriveLetterOfPath(const QString &directory);
ClearCaseSettings m_settings;
......
......@@ -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();
QString program = settings.ccBinaryPath;
......@@ -65,19 +65,23 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (settings.disableIndexer)
return;
QStringList vobs;
if (!settings.indexOnlyVOBs.isEmpty())
vobs = settings.indexOnlyVOBs.split(QLatin1Char(','));
else
vobs = m_plugin->ccGetActiveVobs();
QDir topLevelDir(topLevel);
const QString viewRoot = m_plugin->viewRoot();
const QDir viewRootDir(viewRoot);
QStringList args(QLatin1String("ls"));
if (hot) {
// find all files whose permissions changed OR hijacked files
// (might have become checked out)
foreach (const QString &file, m_statusMap->keys()) {
bool permChanged =
m_statusMap->value(file).permissions != QFileInfo(topLevel, file).permissions();
m_statusMap->value(file).permissions != QFileInfo(viewRoot, file).permissions();
if (permChanged || m_statusMap->value(file).status == FileStatus::Hijacked) {
files.append(file);
(*m_statusMap)[file].status = FileStatus::Unknown;
......@@ -87,7 +91,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
args << files;
} else {
foreach (const QString &file, files)
m_plugin->setStatus(topLevelDir.relativeFilePath(file), FileStatus::Unknown, false);
m_plugin->setStatus(viewRootDir.absoluteFilePath(file), FileStatus::Unknown, false);
args << QLatin1String("-recurse");
args << vobs;
}
......@@ -96,7 +100,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())
......@@ -114,21 +118,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
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;
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));
......@@ -138,9 +145,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (!future.isCanceled()) {
foreach (const QString &file, files) {
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) {
......
......@@ -40,7 +40,7 @@ class ClearCaseSync : public QObject
Q_OBJECT
public:
explicit ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap);
void run(QFutureInterface<void> &future, const QString &topLevel, QStringList &files);
void run(QFutureInterface<void> &future, QStringList &files);
signals:
void updateStreamAndView();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment