Git: Introduce StashGuard

Offers the user to stash changes (if relevant), stores
the results and pops the stash when it goes out of scope
(unless disabled)

Change-Id: Ibc0d2a5d3e3c953062fb17ecba903ca814524837
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-01-24 12:11:01 +02:00
parent c670a66fe1
commit 5551c1e906
8 changed files with 102 additions and 86 deletions

View File

@@ -443,18 +443,11 @@ void BranchModel::checkoutBranch(const QModelIndex &idx)
if (branch.isEmpty())
return;
GitClient::StashGuard stashGuard(m_workingDirectory, QLatin1String("Branch-Checkout"));
if (stashGuard.stashingFailed(false))
return;
stashGuard.preventPop();
QString errorMessage;
switch (m_client->ensureStash(m_workingDirectory, QLatin1String("Branch-Checkout"), true, 0, &errorMessage)) {
case GitClient::StashUnchanged:
case GitClient::Stashed:
case GitClient::NotStashed:
break;
case GitClient::StashCanceled:
return;
case GitClient::StashFailed:
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
return;
}
if (m_client->synchronousCheckoutBranch(m_workingDirectory, branch, &errorMessage)) {
if (errorMessage.isEmpty()) {
QModelIndex currentIdx = currentBranch();