Commit c222a4f6 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 <>
Reviewed-by: default avatarKnut Petter Svendsen <>
parent bedc4779
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; }
QString viewRoot() const { return m_viewData.root; }
void refreshActivities();
inline bool isUcm() const { return m_viewData.isUcm; }
inline bool isDynamic() const { return m_viewData.isDynamic; }
......@@ -207,6 +209,9 @@ protected:
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,
......@@ -215,7 +220,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(),
......@@ -234,6 +239,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();
const QString program = settings.ccBinaryPath;
......@@ -66,8 +66,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (settings.disableIndexer)
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) {
......@@ -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.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 =
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);
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) {
......@@ -40,7 +40,7 @@ class ClearCaseSync : public QObject
explicit ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap);
void run(QFutureInterface<void> &future, const QString &topLevel, QStringList &files);
void run(QFutureInterface<void> &future, QStringList &files);
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