ClearCase: Support systems without external diff

CC's internal diff is worthless, just disable multiple files actions

Change-Id: Ia8541e6edc6582777fc141da849819a5a11543b6
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@nokia.com>
This commit is contained in:
Orgad Shaneh
2012-09-02 11:26:26 +03:00
committed by Orgad Shaneh
parent b9c58161e4
commit 856b7f15ab
5 changed files with 96 additions and 13 deletions

View File

@@ -706,8 +706,13 @@ void ClearCasePlugin::undoHijackCurrent()
const QString fileName = state.relativeCurrentFile(); const QString fileName = state.relativeCurrentFile();
bool keep = false; bool keep = false;
QString diffres = diffExternal(ccGetFileVersion(state.topLevel(), fileName), fileName); bool askKeep = true;
if (diffres.at(0) != QLatin1Char('F')) { // Files are identical if (m_settings.extDiffAvailable) {
QString diffres = diffExternal(ccGetFileVersion(state.topLevel(), fileName), fileName);
if (diffres.at(0) == QLatin1Char('F')) // Files are identical
askKeep = false;
}
if (askKeep) {
Ui::UndoCheckOut unhijackUi; Ui::UndoCheckOut unhijackUi;
QDialog unhijackDlg; QDialog unhijackDlg;
unhijackUi.setupUi(&unhijackDlg); unhijackUi.setupUi(&unhijackDlg);
@@ -749,6 +754,11 @@ void ClearCasePlugin::ccDiffWithPred(const QStringList &files)
diffGraphical(file); diffGraphical(file);
return; // done here, diff is opened in a new window return; // done here, diff is opened in a new window
} }
if (!m_settings.extDiffAvailable) {
VcsBase::VcsBaseOutputWindow::instance()->appendError(
tr("External diff is required to compare multiple files."));
return;
}
QString result; QString result;
foreach (const QString &file, files) { foreach (const QString &file, files) {
if (m_statusMap->value(QDir::fromNativeSeparators(file)).status == FileStatus::Hijacked) if (m_statusMap->value(QDir::fromNativeSeparators(file)).status == FileStatus::Hijacked)
@@ -814,6 +824,11 @@ void ClearCasePlugin::diffActivity()
QTC_ASSERT(state.hasTopLevel(), return); QTC_ASSERT(state.hasTopLevel(), return);
if (ClearCase::Constants::debug) if (ClearCase::Constants::debug)
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
if (!m_settings.extDiffAvailable) {
VcsBase::VcsBaseOutputWindow::instance()->appendError(
tr("External diff is required to compare multiple files."));
return;
}
QString topLevel = state.topLevel(); QString topLevel = state.topLevel();
QString activity = QInputDialog::getText(0, tr("Enter Activity"), tr("Activity Name"), QLineEdit::Normal, m_activity); QString activity = QInputDialog::getText(0, tr("Enter Activity"), tr("Activity Name"), QLineEdit::Normal, m_activity);
if (activity.isEmpty()) if (activity.isEmpty())
@@ -1148,7 +1163,8 @@ void ClearCasePlugin::describe(const QString &source, const QString &changeNr)
const ClearCaseResponse response = const ClearCaseResponse response =
runCleartool(topLevel, args, m_settings.timeOutMS(), 0, codec); runCleartool(topLevel, args, m_settings.timeOutMS(), 0, codec);
description = response.stdOut; description = response.stdOut;
description += diffExternal(id); if (m_settings.extDiffAvailable)
description += diffExternal(id);
// Re-use an existing view if possible to support // Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file // the common usage pattern of continuously changing and diffing a file

View File

@@ -98,6 +98,7 @@ void ClearCaseSettings::fromSettings(QSettings *settings)
promptToCheckIn = settings->value(QLatin1String(promptToCheckInKeyC), false).toBool(); promptToCheckIn = settings->value(QLatin1String(promptToCheckInKeyC), false).toBool();
disableIndexer = settings->value(QLatin1String(disableIndexerKeyC), false).toBool(); disableIndexer = settings->value(QLatin1String(disableIndexerKeyC), false).toBool();
indexOnlyVOBs = settings->value(QLatin1String(indexOnlyVOBsC), QString()).toString(); indexOnlyVOBs = settings->value(QLatin1String(indexOnlyVOBsC), QString()).toString();
extDiffAvailable = !Utils::Environment::systemEnvironment().searchInPath(QLatin1String("diff")).isEmpty();
settings->beginGroup(QLatin1String(totalFilesKeyC)); settings->beginGroup(QLatin1String(totalFilesKeyC));
foreach (const QString &view, settings->childKeys()) foreach (const QString &view, settings->childKeys())
totalFiles[view] = settings->value(view).toInt(); totalFiles[view] = settings->value(view).toInt();

View File

@@ -73,6 +73,7 @@ public:
bool promptToCheckIn; bool promptToCheckIn;
bool disableIndexer; bool disableIndexer;
QString indexOnlyVOBs; QString indexOnlyVOBs;
bool extDiffAvailable;
QHash<QString, int> totalFiles; QHash<QString, int> totalFiles;
}; };

View File

@@ -37,6 +37,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/environment.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -71,6 +72,7 @@ ClearCaseSettings SettingsPageWidget::settings() const
rc.disableIndexer = m_ui.disableIndexerCheckBox->isChecked(); rc.disableIndexer = m_ui.disableIndexerCheckBox->isChecked();
rc.diffArgs = m_ui.diffArgsEdit->text(); rc.diffArgs = m_ui.diffArgsEdit->text();
rc.indexOnlyVOBs = m_ui.indexOnlyVOBsEdit->text(); rc.indexOnlyVOBs = m_ui.indexOnlyVOBsEdit->text();
rc.extDiffAvailable = m_ui.externalDiffRadioButton->isEnabled();
return rc; return rc;
} }
@@ -79,16 +81,23 @@ void SettingsPageWidget::setSettings(const ClearCaseSettings &s)
m_ui.commandPathChooser->setPath(s.ccCommand); m_ui.commandPathChooser->setPath(s.ccCommand);
m_ui.timeOutSpinBox->setValue(s.timeOutS); m_ui.timeOutSpinBox->setValue(s.timeOutS);
m_ui.autoCheckOutCheckBox->setChecked(s.autoCheckOut); m_ui.autoCheckOutCheckBox->setChecked(s.autoCheckOut);
switch (s.diffType) { bool extDiffAvailable = !Utils::Environment::systemEnvironment().searchInPath(QLatin1String("diff")).isEmpty();
case GraphicalDiff: if (extDiffAvailable) {
m_ui.graphicalDiffRadioButton->setChecked(true); m_ui.diffWarningLabel->setVisible(false);
m_ui.diffWidget->setEnabled(false); } else {
break; QString diffWarning = tr("In order to use External diff, 'diff' command needs to be accessible.");
case ExternalDiff: #ifdef Q_OS_WIN
m_ui.externalDiffRadioButton->setChecked(true); diffWarning.append(tr(" DiffUtils is available for free download "
m_ui.diffWidget->setEnabled(true); "<a href=\"http://gnuwin32.sourceforge.net/packages/diffutils.htm\">here</a>. "
break; "Please extract it to a directory in your PATH."));
#endif
m_ui.diffWarningLabel->setText(diffWarning);
m_ui.externalDiffRadioButton->setEnabled(false);
} }
if (extDiffAvailable && s.diffType == ExternalDiff)
m_ui.externalDiffRadioButton->setChecked(true);
else
m_ui.graphicalDiffRadioButton->setChecked(true);
m_ui.autoAssignActivityCheckBox->setChecked(s.autoAssignActivityName); m_ui.autoAssignActivityCheckBox->setChecked(s.autoAssignActivityName);
m_ui.historyCountSpinBox->setValue(s.historyCount); m_ui.historyCountSpinBox->setValue(s.historyCount);
m_ui.promptCheckBox->setChecked(s.promptToCheckIn); m_ui.promptCheckBox->setChecked(s.promptToCheckIn);

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>363</width> <width>363</width>
<height>384</height> <height>403</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@@ -39,11 +39,17 @@
<string>Diff</string> <string>Diff</string>
</property> </property>
<layout class="QFormLayout" name="formLayout"> <layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QRadioButton" name="graphicalDiffRadioButton"> <widget class="QRadioButton" name="graphicalDiffRadioButton">
<property name="text"> <property name="text">
<string>&amp;Graphical (Single file only)</string> <string>&amp;Graphical (Single file only)</string>
</property> </property>
<property name="checked">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
@@ -55,6 +61,9 @@
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QWidget" name="diffWidget" native="true"> <widget class="QWidget" name="diffWidget" native="true">
<property name="enabled">
<bool>false</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin"> <property name="margin">
<number>0</number> <number>0</number>
@@ -75,6 +84,53 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="diffWarningLabel">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>68</red>
<green>96</green>
<blue>92</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string/>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>