forked from qt-creator/qt-creator
Gerrit - Removed all patch set stuff
Change-Id: I013c116fc7e0ac1571513005b8ea49992e0771a3 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
This commit is contained in:
committed by
Jarek Kobus
parent
f2631ad031
commit
77c136646b
@@ -106,28 +106,23 @@ private slots:
|
|||||||
void processReadyReadStandardOutput();
|
void processReadyReadStandardOutput();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// State enumeration. It starts in 'FetchState' and then
|
|
||||||
// branches to 'WritePatchFileState', 'CherryPickState'
|
|
||||||
// or 'CheckoutState' depending on FetchMode.
|
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
FetchState, // Fetch patch
|
FetchState,
|
||||||
WritePatchFileState, // Write patch to a file
|
|
||||||
DoneState,
|
DoneState,
|
||||||
ErrorState
|
ErrorState
|
||||||
};
|
};
|
||||||
|
|
||||||
void handleError(const QString &message);
|
void handleError(const QString &message);
|
||||||
void startWritePatchFile();
|
void show();
|
||||||
void cherryPick();
|
void cherryPick();
|
||||||
|
void checkout();
|
||||||
|
|
||||||
const QSharedPointer<GerritChange> m_change;
|
const QSharedPointer<GerritChange> m_change;
|
||||||
const QString m_repository;
|
const QString m_repository;
|
||||||
const FetchMode m_fetchMode;
|
const FetchMode m_fetchMode;
|
||||||
const QString m_git;
|
const QString m_git;
|
||||||
const QSharedPointer<GerritParameters> m_parameters;
|
const QSharedPointer<GerritParameters> m_parameters;
|
||||||
QScopedPointer<QTemporaryFile> m_patchFile;
|
|
||||||
QString m_patchFileName;
|
|
||||||
State m_state;
|
State m_state;
|
||||||
QProcess m_process;
|
QProcess m_process;
|
||||||
QFutureInterface<void> m_progress;
|
QFutureInterface<void> m_progress;
|
||||||
@@ -183,7 +178,6 @@ void FetchContext::start()
|
|||||||
|
|
||||||
void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
||||||
{
|
{
|
||||||
Git::Internal::GitClient *client = Git::Internal::GitPlugin::instance()->gitClient();
|
|
||||||
if (es != QProcess::NormalExit) {
|
if (es != QProcess::NormalExit) {
|
||||||
handleError(tr("%1 crashed.").arg(m_git));
|
handleError(tr("%1 crashed.").arg(m_git));
|
||||||
return;
|
return;
|
||||||
@@ -192,60 +186,18 @@ void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
|||||||
handleError(tr("%1 returned %2.").arg(m_git).arg(exitCode));
|
handleError(tr("%1 returned %2.").arg(m_git).arg(exitCode));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (m_state) {
|
if (m_state == FetchState) {
|
||||||
case DoneState:
|
|
||||||
case ErrorState:
|
|
||||||
break;
|
|
||||||
case FetchState:
|
|
||||||
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
m_progress.setProgressValue(m_progress.progressValue() + 1);
|
||||||
switch (m_fetchMode) {
|
if (m_fetchMode == FetchDisplay)
|
||||||
case FetchDisplay:
|
show();
|
||||||
if (client->settings()->boolValue(Git::Internal::GitSettings::useDiffEditorKey)) {
|
else if (m_fetchMode == FetchCherryPick)
|
||||||
client->show(m_repository, QLatin1String("FETCH_HEAD"));
|
cherryPick();
|
||||||
m_progress.reportFinished();
|
else if (m_fetchMode == FetchCheckout)
|
||||||
m_state = DoneState;
|
checkout();
|
||||||
deleteLater();
|
|
||||||
} else {
|
m_progress.reportFinished();
|
||||||
m_state = WritePatchFileState;
|
m_state = DoneState;
|
||||||
startWritePatchFile();
|
deleteLater();
|
||||||
}
|
|
||||||
break;
|
|
||||||
case FetchCherryPick:
|
|
||||||
case FetchCheckout:
|
|
||||||
if (m_fetchMode == FetchCherryPick) {
|
|
||||||
cherryPick();
|
|
||||||
} else {
|
|
||||||
client->synchronousCheckout(m_repository, QLatin1String("FETCH_HEAD"));
|
|
||||||
}
|
|
||||||
m_progress.reportFinished();
|
|
||||||
m_state = DoneState;
|
|
||||||
deleteLater();
|
|
||||||
break;
|
|
||||||
} // switch (m_fetchMode)
|
|
||||||
break;
|
|
||||||
case WritePatchFileState:
|
|
||||||
switch (m_fetchMode) {
|
|
||||||
case FetchDisplay: {
|
|
||||||
m_patchFileName = m_patchFile->fileName();
|
|
||||||
m_patchFile->close();
|
|
||||||
m_patchFile.reset();
|
|
||||||
m_state = DoneState;
|
|
||||||
m_progress.reportFinished();
|
|
||||||
QString title = QString(QLatin1String("Gerrit patch %1/%2"))
|
|
||||||
.arg(m_change->number).arg(m_change->currentPatchSet.patchSetNumber);
|
|
||||||
Core::IEditor *editor = Core::EditorManager::openEditor(
|
|
||||||
m_patchFileName, Git::Constants::GIT_DIFF_EDITOR_ID);
|
|
||||||
VcsBase::VcsBaseEditorWidget *vcsEditor = VcsBase::VcsBaseEditorWidget::getVcsBaseEditor(editor);
|
|
||||||
vcsEditor->setDiffBaseDirectory(m_repository);
|
|
||||||
vcsEditor->setForceReadOnly(true);
|
|
||||||
vcsEditor->setDisplayName(title);
|
|
||||||
deleteLater();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,10 +214,7 @@ void FetchContext::processReadyReadStandardError()
|
|||||||
void FetchContext::processReadyReadStandardOutput()
|
void FetchContext::processReadyReadStandardOutput()
|
||||||
{
|
{
|
||||||
const QByteArray output = m_process.readAllStandardOutput();
|
const QByteArray output = m_process.readAllStandardOutput();
|
||||||
if (m_state == WritePatchFileState)
|
VcsBase::VcsBaseOutputWindow::instance()->append(QString::fromLocal8Bit(output));
|
||||||
m_patchFile->write(output);
|
|
||||||
else
|
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->append(QString::fromLocal8Bit(output));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::handleError(const QString &e)
|
void FetchContext::handleError(const QString &e)
|
||||||
@@ -286,42 +235,30 @@ void FetchContext::processError(QProcess::ProcessError e)
|
|||||||
VcsBase::VcsBaseOutputWindow::instance()->appendError(msg);
|
VcsBase::VcsBaseOutputWindow::instance()->appendError(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::startWritePatchFile()
|
void FetchContext::show()
|
||||||
{
|
{
|
||||||
// Fetch to file in temporary folder.
|
const QString title = QString::number(m_change->number) + QLatin1Char('/')
|
||||||
QString tempPattern = QDir::tempPath();
|
+ QString::number(m_change->currentPatchSet.patchSetNumber);
|
||||||
if (!tempPattern.endsWith(QLatin1Char('/')))
|
Git::Internal::GitPlugin::instance()->gitClient()->show(
|
||||||
tempPattern += QLatin1Char('/');
|
m_repository, QLatin1String("FETCH_HEAD"), QStringList(), title);
|
||||||
tempPattern += QLatin1String("gerrit_") + QString::number(m_change->number)
|
|
||||||
+ QLatin1Char('_')
|
|
||||||
+ QString::number(m_change->currentPatchSet.patchSetNumber)
|
|
||||||
+ QLatin1String("XXXXXX.patch");
|
|
||||||
m_patchFile.reset(new QTemporaryFile(tempPattern));
|
|
||||||
m_patchFile->setAutoRemove(false);
|
|
||||||
if (!m_patchFile->open()) {
|
|
||||||
handleError(tr("Error writing to temporary file."));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->append(tr("Writing %1...").arg(m_patchFile->fileName()));
|
|
||||||
QStringList args;
|
|
||||||
args << QLatin1String("format-patch") << QLatin1String("-1")
|
|
||||||
<< QLatin1String("--stdout") << QLatin1String("FETCH_HEAD");
|
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->appendCommand(m_repository, m_git, args);
|
|
||||||
if (debug)
|
|
||||||
qDebug() << m_git << args;
|
|
||||||
m_process.start(m_git, args);
|
|
||||||
m_process.closeWriteChannel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::cherryPick()
|
void FetchContext::cherryPick()
|
||||||
{
|
{
|
||||||
// Point user to errors.
|
// Point user to errors.
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->popup(Core::IOutputPane::ModeSwitch | Core::IOutputPane::WithFocus);
|
VcsBase::VcsBaseOutputWindow::instance()->popup(Core::IOutputPane::ModeSwitch
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->append(tr("Cherry-picking %1...").arg(m_patchFileName));
|
| Core::IOutputPane::WithFocus);
|
||||||
Git::Internal::GitPlugin::instance()->gitClient()->synchronousCherryPick(
|
Git::Internal::GitPlugin::instance()->gitClient()->synchronousCherryPick(
|
||||||
m_repository, QLatin1String("FETCH_HEAD"));
|
m_repository, QLatin1String("FETCH_HEAD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FetchContext::checkout()
|
||||||
|
{
|
||||||
|
Git::Internal::GitPlugin::instance()->gitClient()->synchronousCheckout(
|
||||||
|
m_repository, QLatin1String("FETCH_HEAD"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GerritPlugin::GerritPlugin(QObject *parent)
|
GerritPlugin::GerritPlugin(QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_parameters(new GerritParameters)
|
, m_parameters(new GerritParameters)
|
||||||
|
@@ -1116,15 +1116,16 @@ static inline QString msgCannotShow(const QString &sha)
|
|||||||
return GitClient::tr("Cannot describe \"%1\".").arg(sha);
|
return GitClient::tr("Cannot describe \"%1\".").arg(sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitClient::show(const QString &source, const QString &id, const QStringList &args)
|
void GitClient::show(const QString &source, const QString &id,
|
||||||
|
const QStringList &args, const QString &name)
|
||||||
{
|
{
|
||||||
if (!canShow(id)) {
|
if (!canShow(id)) {
|
||||||
outputWindow()->append(msgCannotShow(id));
|
outputWindow()->append(msgCannotShow(id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString title = tr("Git Show \"%1\"").arg(name.isEmpty() ? id : name);
|
||||||
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
if (settings()->boolValue(GitSettings::useDiffEditorKey)) {
|
||||||
QString title = tr("Git Show \"%1\"").arg(id);
|
|
||||||
const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID;
|
const Core::Id editorId = DiffEditor::Constants::DIFF_EDITOR_ID;
|
||||||
|
|
||||||
DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("show", id);
|
DiffEditor::DiffEditorEditable *editorEditable = findExistingDiffEditor("show", id);
|
||||||
@@ -1140,7 +1141,6 @@ void GitClient::show(const QString &source, const QString &id, const QStringList
|
|||||||
GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), source, processEnvironment(), timeout);
|
GitDiffHandler *handler = new GitDiffHandler(editorEditable, gitBinaryPath(), source, processEnvironment(), timeout);
|
||||||
handler->show(id);
|
handler->show(id);
|
||||||
} else {
|
} else {
|
||||||
const QString title = tr("Git Show \"%1\"").arg(id);
|
|
||||||
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID;
|
const Core::Id editorId = Git::Constants::GIT_DIFF_EDITOR_ID;
|
||||||
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("show", id);
|
VcsBase::VcsBaseEditorWidget *editor = findExistingVCSEditor("show", id);
|
||||||
if (!editor)
|
if (!editor)
|
||||||
|
@@ -320,7 +320,8 @@ public:
|
|||||||
static const char *decorateOption;
|
static const char *decorateOption;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void show(const QString &source, const QString &id, const QStringList &args = QStringList());
|
void show(const QString &source, const QString &id,
|
||||||
|
const QStringList &args = QStringList(), const QString &name = QString());
|
||||||
void saveSettings();
|
void saveSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
Reference in New Issue
Block a user