Gerrit: Use GitClient functions for checkout and cherry-pick

This is cleaner, and for cherry-pick also handles conflicts

Change-Id: I50a7035c532a2cfa07fdd960e70ffb4af666a80e
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
Orgad Shaneh
2013-01-24 11:45:59 +02:00
committed by Orgad Shaneh
parent cf5f109b68
commit c57e6029c6

View File

@@ -108,16 +108,13 @@ private:
{ {
FetchState, // Fetch patch FetchState, // Fetch patch
WritePatchFileState, // Write patch to a file WritePatchFileState, // Write patch to a file
CherryPickState, // Cherry-pick (apply) fetch-head
CheckoutState, // Check out fetch-head
DoneState, DoneState,
ErrorState ErrorState
}; };
void handleError(const QString &message); void handleError(const QString &message);
void startWritePatchFile(); void startWritePatchFile();
void startCherryPick(); void cherryPick();
void startCheckout();
const QSharedPointer<GerritChange> m_change; const QSharedPointer<GerritChange> m_change;
const QString m_repository; const QString m_repository;
@@ -199,12 +196,16 @@ void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
startWritePatchFile(); startWritePatchFile();
break; break;
case FetchApply: case FetchApply:
m_state = CherryPickState;
startCherryPick();
break;
case FetchCheckout: case FetchCheckout:
m_state = CheckoutState; if (m_fetchMode == FetchApply) {
startCheckout(); cherryPick();
} else {
Git::Internal::GitPlugin::instance()->gitClient()->synchronousCheckout(
m_repository, QLatin1String("FETCH_HEAD"));
}
m_progress.reportFinished();
m_state = DoneState;
deleteLater();
break; break;
} // switch (m_fetchMode) } // switch (m_fetchMode)
break; break;
@@ -231,11 +232,6 @@ void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
break; break;
} }
break; break;
case CherryPickState:
case CheckoutState:
m_progress.reportFinished();
m_state = DoneState;
deleteLater();
} }
} }
@@ -243,7 +239,7 @@ void FetchContext::processReadyReadStandardError()
{ {
// Note: fetch displays progress on stderr. // Note: fetch displays progress on stderr.
const QString errorOutput = QString::fromLocal8Bit(m_process.readAllStandardError()); const QString errorOutput = QString::fromLocal8Bit(m_process.readAllStandardError());
if (m_state == FetchState || m_state == CheckoutState) if (m_state == FetchState)
VcsBase::VcsBaseOutputWindow::instance()->append(errorOutput); VcsBase::VcsBaseOutputWindow::instance()->append(errorOutput);
else else
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorOutput); VcsBase::VcsBaseOutputWindow::instance()->appendError(errorOutput);
@@ -303,27 +299,13 @@ void FetchContext::startWritePatchFile()
m_process.closeWriteChannel(); m_process.closeWriteChannel();
} }
void FetchContext::startCherryPick() 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 | Core::IOutputPane::WithFocus);
VcsBase::VcsBaseOutputWindow::instance()->append(tr("Cherry-picking %1...").arg(m_patchFileName)); VcsBase::VcsBaseOutputWindow::instance()->append(tr("Cherry-picking %1...").arg(m_patchFileName));
QStringList args; Git::Internal::GitPlugin::instance()->gitClient()->cherryPickCommit(
args << QLatin1String("cherry-pick") << QLatin1String("FETCH_HEAD"); m_repository, 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::startCheckout()
{
QStringList args;
args << QLatin1String("checkout") << QLatin1String("FETCH_HEAD");
VcsBase::VcsBaseOutputWindow::instance()->appendCommand(m_repository, m_git, args);
m_process.start(m_git, args);
m_process.closeWriteChannel();
} }
GerritPlugin::GerritPlugin(QObject *parent) GerritPlugin::GerritPlugin(QObject *parent)