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: ...@@ -107,6 +107,7 @@ public:
QString name; QString name;
bool isDynamic; bool isDynamic;
bool isUcm; bool isUcm;
QString root;
}; };
class ClearCasePlugin : public VcsBase::VcsBasePlugin class ClearCasePlugin : public VcsBase::VcsBasePlugin
...@@ -156,6 +157,7 @@ public: ...@@ -156,6 +157,7 @@ public:
const QString &fileName, const QString &file2 = QString()); const QString &fileName, const QString &file2 = QString());
FileStatus vcsStatus(const QString &file) const; FileStatus vcsStatus(const QString &file) const;
QString currentView() const { return m_viewData.name; } QString currentView() const { return m_viewData.name; }
QString viewRoot() const { return m_viewData.root; }
void refreshActivities(); void refreshActivities();
inline bool isUcm() const { return m_viewData.isUcm; } inline bool isUcm() const { return m_viewData.isUcm; }
void setStatus(const QString &file, FileStatus::Status status, bool update = true); void setStatus(const QString &file, FileStatus::Status status, bool update = true);
...@@ -206,6 +208,9 @@ protected: ...@@ -206,6 +208,9 @@ protected:
private: private:
inline bool isCheckInEditorOpen() const; 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; QString findTopLevel(const QString &directory) const;
Core::IEditor *showOutputInEditor(const QString& title, const QString &output, Core::IEditor *showOutputInEditor(const QString& title, const QString &output,
int editorType, const QString &source, int editorType, const QString &source,
...@@ -214,7 +219,7 @@ private: ...@@ -214,7 +219,7 @@ private:
ClearCaseResponse runCleartool(const QString &workingDir, ClearCaseResponse runCleartool(const QString &workingDir,
const QStringList &arguments, int timeOut, const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec = 0) const; 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, void history(const QString &workingDir,
const QStringList &file = QStringList(), const QStringList &file = QStringList(),
...@@ -233,6 +238,7 @@ private: ...@@ -233,6 +238,7 @@ private:
static void rmdir(const QString &path); static void rmdir(const QString &path);
QString runExtDiff(const QString &workingDir, const QStringList &arguments, QString runExtDiff(const QString &workingDir, const QStringList &arguments,
int timeOut, QTextCodec *outputCodec = 0); int timeOut, QTextCodec *outputCodec = 0);
static QString getDriveLetterOfPath(const QString &directory);
ClearCaseSettings m_settings; ClearCaseSettings m_settings;
......
...@@ -44,7 +44,7 @@ ClearCaseSync::ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> ...@@ -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(); ClearCaseSettings settings = m_plugin->settings();
QString program = settings.ccBinaryPath; QString program = settings.ccBinaryPath;
...@@ -65,19 +65,23 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, ...@@ -65,19 +65,23 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (settings.disableIndexer) if (settings.disableIndexer)
return; return;
QStringList vobs; QStringList vobs;
if (!settings.indexOnlyVOBs.isEmpty()) if (!settings.indexOnlyVOBs.isEmpty())
vobs = settings.indexOnlyVOBs.split(QLatin1Char(',')); vobs = settings.indexOnlyVOBs.split(QLatin1Char(','));
else else
vobs = m_plugin->ccGetActiveVobs(); vobs = m_plugin->ccGetActiveVobs();
QDir topLevelDir(topLevel);
const QString viewRoot = m_plugin->viewRoot();
const QDir viewRootDir(viewRoot);
QStringList args(QLatin1String("ls")); QStringList args(QLatin1String("ls"));
if (hot) { if (hot) {
// find all files whose permissions changed OR hijacked files // find all files whose permissions changed OR hijacked files
// (might have become checked out) // (might have become checked out)
foreach (const QString &file, m_statusMap->keys()) { foreach (const QString &file, m_statusMap->keys()) {
bool permChanged = 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) { if (permChanged || m_statusMap->value(file).status == FileStatus::Hijacked) {
files.append(file); files.append(file);
(*m_statusMap)[file].status = FileStatus::Unknown; (*m_statusMap)[file].status = FileStatus::Unknown;
...@@ -87,7 +91,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, ...@@ -87,7 +91,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
args << files; args << files;
} else { } else {
foreach (const QString &file, files) 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 << QLatin1String("-recurse");
args << vobs; args << vobs;
} }
...@@ -96,7 +100,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, ...@@ -96,7 +100,7 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
// (we don't want it to become green) // (we don't want it to become green)
future.setProgressRange(0, total + 1); future.setProgressRange(0, total + 1);
QProcess process; QProcess process;
process.setWorkingDirectory(topLevel); process.setWorkingDirectory(viewRoot);
process.start(program, args); process.start(program, args);
if (!process.waitForStarted()) if (!process.waitForStarted())
...@@ -114,21 +118,24 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, ...@@ -114,21 +118,24 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (atatpos != -1) { // probably managed file if (atatpos != -1) { // probably managed file
// find first whitespace. anything before that is not interesting // find first whitespace. anything before that is not interesting
int wspos = buffer.indexOf(QRegExp(QLatin1String("\\s"))); 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; QString ccState;
QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing] QRegExp reState(QLatin1String("^\\s*\\[[^\\]]*\\]")); // [hijacked]; [loaded but missing]
if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) { if (reState.indexIn(buffer, wspos + 1, QRegExp::CaretAtOffset) != -1) {
ccState = reState.cap(); ccState = reState.cap();
if (ccState.indexOf(QLatin1String("hijacked")) != -1) 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) 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) 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 // don't care about checked-in files not listed in project
else if (m_statusMap->contains(relFile)) else if (m_statusMap->contains(absFile))
m_plugin->setStatus(relFile, FileStatus::CheckedIn, true); m_plugin->setStatus(absFile, FileStatus::CheckedIn, true);
} }
buffer.clear(); buffer.clear();
future.setProgressValue(qMin(total, ++processed)); future.setProgressValue(qMin(total, ++processed));
...@@ -138,9 +145,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel, ...@@ -138,9 +145,9 @@ void ClearCaseSync::run(QFutureInterface<void> &future, const QString &topLevel,
if (!future.isCanceled()) { if (!future.isCanceled()) {
foreach (const QString &file, files) { foreach (const QString &file, files) {
QString relFile = topLevelDir.relativeFilePath(file); QString absFile = QFileInfo(file).absoluteFilePath();
if (m_statusMap->value(relFile).status == FileStatus::Unknown) if (!m_statusMap->contains(absFile))
m_plugin->setStatus(relFile, FileStatus::NotManaged, false); m_plugin->setStatus(absFile, FileStatus::NotManaged, false);
} }
future.setProgressValue(total + 1); future.setProgressValue(total + 1);
if (!hot) { if (!hot) {
......
...@@ -40,7 +40,7 @@ class ClearCaseSync : public QObject ...@@ -40,7 +40,7 @@ class ClearCaseSync : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit ClearCaseSync(ClearCasePlugin *plugin, QSharedPointer<StatusMap> statusMap); 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: signals:
void updateStreamAndView(); 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