forked from qt-creator/qt-creator
Git: Refactor reset
Remove enum, provide the associated flag in the combobox. Change-Id: I1c4751c75f59312904fe7c175678f965ac16741d Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
cbfeb36ce7
commit
e6da908321
@@ -869,10 +869,10 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::hardReset(const QString &workingDirectory, const QString &commit)
|
void GitClient::reset(const QString &workingDirectory, const QString &argument, const QString &commit)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << QLatin1String("reset") << QLatin1String("--hard");
|
arguments << QLatin1String("reset") << argument;
|
||||||
if (!commit.isEmpty())
|
if (!commit.isEmpty())
|
||||||
arguments << commit;
|
arguments << commit;
|
||||||
|
|
||||||
@@ -880,18 +880,6 @@ void GitClient::hardReset(const QString &workingDirectory, const QString &commit
|
|||||||
connectRepositoryChanged(workingDirectory, cmd);
|
connectRepositoryChanged(workingDirectory, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::softReset(const QString &workingDirectory, const QString &commit)
|
|
||||||
{
|
|
||||||
if (commit.isEmpty())
|
|
||||||
return;
|
|
||||||
|
|
||||||
QStringList arguments;
|
|
||||||
arguments << QLatin1String("reset") << QLatin1String("--soft") << commit;
|
|
||||||
|
|
||||||
VcsBase::Command *cmd = executeGit(workingDirectory, arguments, 0, true);
|
|
||||||
connectRepositoryChanged(workingDirectory, cmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
|
void GitClient::addFile(const QString &workingDirectory, const QString &fileName)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
|
@@ -137,8 +137,7 @@ public:
|
|||||||
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
|
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
|
||||||
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
|
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
|
||||||
const QString &revision = QString(), int lineNumber = -1);
|
const QString &revision = QString(), int lineNumber = -1);
|
||||||
void hardReset(const QString &workingDirectory, const QString &commit = QString());
|
void reset(const QString &workingDirectory, const QString &argument, const QString &commit = QString());
|
||||||
void softReset(const QString &workingDirectory, const QString &commit);
|
|
||||||
void addFile(const QString &workingDirectory, const QString &fileName);
|
void addFile(const QString &workingDirectory, const QString &fileName);
|
||||||
bool synchronousLog(const QString &workingDirectory,
|
bool synchronousLog(const QString &workingDirectory,
|
||||||
const QStringList &arguments,
|
const QStringList &arguments,
|
||||||
|
@@ -708,14 +708,7 @@ void GitPlugin::resetRepository()
|
|||||||
LogChangeDialog dialog(true);
|
LogChangeDialog dialog(true);
|
||||||
dialog.setWindowTitle(tr("Undo Changes to %1").arg(QDir::toNativeSeparators(topLevel)));
|
dialog.setWindowTitle(tr("Undo Changes to %1").arg(QDir::toNativeSeparators(topLevel)));
|
||||||
if (dialog.runDialog(topLevel))
|
if (dialog.runDialog(topLevel))
|
||||||
switch (dialog.resetType()) {
|
m_gitClient->reset(topLevel, dialog.resetFlag(), dialog.commit());
|
||||||
case HardReset:
|
|
||||||
m_gitClient->hardReset(topLevel, dialog.commit());
|
|
||||||
break;
|
|
||||||
case SoftReset:
|
|
||||||
m_gitClient->softReset(topLevel, dialog.commit());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitPlugin::startRebase()
|
void GitPlugin::startRebase()
|
||||||
|
@@ -72,8 +72,8 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent)
|
|||||||
if (isReset) {
|
if (isReset) {
|
||||||
popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
|
popUpLayout->addWidget(new QLabel(tr("Reset type:"), this));
|
||||||
m_resetTypeComboBox = new QComboBox(this);
|
m_resetTypeComboBox = new QComboBox(this);
|
||||||
m_resetTypeComboBox->addItem(tr("Hard Reset"), HardReset);
|
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
|
||||||
m_resetTypeComboBox->addItem(tr("Soft Reset"), SoftReset);
|
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
|
||||||
popUpLayout->addWidget(m_resetTypeComboBox);
|
popUpLayout->addWidget(m_resetTypeComboBox);
|
||||||
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
||||||
}
|
}
|
||||||
@@ -112,11 +112,11 @@ QString LogChangeDialog::commit() const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetType LogChangeDialog::resetType() const
|
QString LogChangeDialog::resetFlag() const
|
||||||
{
|
{
|
||||||
if (!m_resetTypeComboBox)
|
if (!m_resetTypeComboBox)
|
||||||
return HardReset;
|
return QString();
|
||||||
return static_cast<ResetType>(m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toInt());
|
return m_resetTypeComboBox->itemData(m_resetTypeComboBox->currentIndex()).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LogChangeDialog::populateLog(const QString &repository)
|
bool LogChangeDialog::populateLog(const QString &repository)
|
||||||
|
@@ -44,13 +44,7 @@ namespace Git {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// A dialog that lists SHA1 and subject of the changes
|
// A dialog that lists SHA1 and subject of the changes
|
||||||
// for reset --hard and --soft.
|
// Used for reset and interactive rebased
|
||||||
|
|
||||||
enum ResetType {
|
|
||||||
HardReset,
|
|
||||||
SoftReset
|
|
||||||
};
|
|
||||||
|
|
||||||
class LogChangeDialog : public QDialog
|
class LogChangeDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -60,7 +54,7 @@ public:
|
|||||||
bool runDialog(const QString &repository);
|
bool runDialog(const QString &repository);
|
||||||
|
|
||||||
QString commit() const;
|
QString commit() const;
|
||||||
ResetType resetType() const;
|
QString resetFlag() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool populateLog(const QString &repository);
|
bool populateLog(const QString &repository);
|
||||||
|
Reference in New Issue
Block a user