ClearCase: Handle read-only view private files

View private files have state NotManaged. In the corner case
where a NotManaged file is read-only they should be made
writeable by the ReadOnlyFilesDialog, and not vcsOpen()-ed.

Change-Id: Icfeab6bebb76cc01da693b3bfff7b46c45b106b4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Knut Petter Svendsen
2013-11-07 12:31:22 +01:00
parent 4c0d07a9aa
commit 16b4c2e032
8 changed files with 29 additions and 14 deletions

View File

@@ -83,13 +83,24 @@ bool ClearCaseControl::supportsOperation(Operation operation) const
return rc; return rc;
} }
Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode() const Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode(const QString &fileName) const
{ {
if (m_plugin->isDynamic()) if (m_plugin->isDynamic()) {
return IVersionControl::OpenMandatory; // Checkout is the only option for dynamic views // NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed
else // to be up to date if the file has been explicitly opened, which is not the case when
// doing a search and replace as a part of a refactoring.
if (m_plugin->managesFile(QFileInfo(fileName).absolutePath(), fileName)) {
// Checkout is the only option for managed files in dynamic views
return IVersionControl::OpenMandatory;
} else {
// Not managed files can be edited without noticing the VCS
return IVersionControl::NoOpen;
}
} else {
return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out
} }
}
bool ClearCaseControl::vcsOpen(const QString &fileName) bool ClearCaseControl::vcsOpen(const QString &fileName)
{ {
@@ -153,6 +164,8 @@ QString ClearCaseControl::vcsOpenText() const
QString ClearCaseControl::vcsMakeWritableText() const QString ClearCaseControl::vcsMakeWritableText() const
{ {
if (m_plugin->isDynamic())
return QString();
return tr("&Hijack"); return tr("&Hijack");
} }

View File

@@ -53,7 +53,7 @@ public:
bool isConfigured() const; bool isConfigured() const;
bool supportsOperation(Operation operation) const; bool supportsOperation(Operation operation) const;
OpenSupportMode openSupportMode() const; OpenSupportMode openSupportMode(const QString &fileName) const;
bool vcsOpen(const QString &fileName); bool vcsOpen(const QString &fileName);
SettingsFlags settingsFlags() const; SettingsFlags settingsFlags() const;
bool vcsAdd(const QString &fileName); bool vcsAdd(const QString &fileName);

View File

@@ -389,7 +389,7 @@ void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
IVersionControl *versionControlForFile = IVersionControl *versionControlForFile =
VcsManager::findVersionControlForDirectory(directory); VcsManager::findVersionControlForDirectory(directory);
const bool fileManagedByVCS = versionControlForFile const bool fileManagedByVCS = versionControlForFile
&& versionControlForFile->openSupportMode() != IVersionControl::NoOpen; && versionControlForFile->openSupportMode(fileName) != IVersionControl::NoOpen;
if (fileManagedByVCS) { if (fileManagedByVCS) {
const QString vcsOpenTextForFile = const QString vcsOpenTextForFile =
versionControlForFile->vcsOpenText().remove(QLatin1Char('&')); versionControlForFile->vcsOpenText().remove(QLatin1Char('&'));
@@ -407,7 +407,7 @@ void ReadOnlyFilesDialog::initDialog(const QStringList &fileNames)
vcsMakeWritableTextForAll.clear(); vcsMakeWritableTextForAll.clear();
} }
// Add make writable if it is supported by the reposetory. // Add make writable if it is supported by the reposetory.
if (versionControlForFile->openSupportMode() == IVersionControl::OpenOptional) { if (versionControlForFile->openSupportMode(fileName) == IVersionControl::OpenOptional) {
useMakeWritable = true; useMakeWritable = true;
createRadioButtonForItem(item, radioButtonGroup, MakeWritable); createRadioButtonForItem(item, radioButtonGroup, MakeWritable);
} }

View File

@@ -1896,7 +1896,7 @@ void EditorManager::vcsOpenCurrentEditor()
const QString directory = QFileInfo(document->filePath()).absolutePath(); const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory); IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
if (!versionControl || versionControl->openSupportMode() == IVersionControl::NoOpen) if (!versionControl || versionControl->openSupportMode(document->filePath()) == IVersionControl::NoOpen)
return; return;
if (!versionControl->vcsOpen(document->filePath())) { if (!versionControl->vcsOpen(document->filePath())) {
@@ -1958,7 +1958,7 @@ void EditorManager::updateMakeWritableWarning()
bool promptVCS = false; bool promptVCS = false;
const QString directory = QFileInfo(document->filePath()).absolutePath(); const QString directory = QFileInfo(document->filePath()).absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory); IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
if (versionControl && versionControl->openSupportMode() != IVersionControl::NoOpen) { if (versionControl && versionControl->openSupportMode(document->filePath()) != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) { if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
vcsOpenCurrentEditor(); vcsOpenCurrentEditor();
ww = false; ww = false;

View File

@@ -46,8 +46,9 @@ QString IVersionControl::vcsTopic(const QString &)
return QString(); return QString();
} }
IVersionControl::OpenSupportMode IVersionControl::openSupportMode() const IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString &fileName) const
{ {
Q_UNUSED(fileName);
return NoOpen; return NoOpen;
} }

View File

@@ -100,9 +100,9 @@ public:
virtual bool supportsOperation(Operation operation) const = 0; virtual bool supportsOperation(Operation operation) const = 0;
/*! /*!
* Returns the open support mode. * Returns the open support mode for \a fileName.
*/ */
virtual OpenSupportMode openSupportMode() const; virtual OpenSupportMode openSupportMode(const QString &fileName) const;
/*! /*!
* Called prior to save, if the file is read only. Should be implemented if * Called prior to save, if the file is read only. Should be implemented if

View File

@@ -81,8 +81,9 @@ bool CvsControl::supportsOperation(Operation operation) const
return rc; return rc;
} }
Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode() const Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode(const QString &fileName) const
{ {
Q_UNUSED(fileName);
return OpenOptional; return OpenOptional;
} }

View File

@@ -52,7 +52,7 @@ public:
bool isConfigured() const; bool isConfigured() const;
bool supportsOperation(Operation operation) const; bool supportsOperation(Operation operation) const;
OpenSupportMode openSupportMode() const; OpenSupportMode openSupportMode(const QString &fileName) const;
bool vcsOpen(const QString &fileName); bool vcsOpen(const QString &fileName);
bool vcsAdd(const QString &fileName); bool vcsAdd(const QString &fileName);
bool vcsDelete(const QString &filename); bool vcsDelete(const QString &filename);