forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/4.10'
Conflicts: qbs/modules/qtc/qtc.qbs qtcreator_ide_branding.pri src/libs/utils/synchronousprocess.cpp src/plugins/baremetal/iarewtoolchain.cpp src/plugins/cmakeprojectmanager/cmakeproject.cpp tests/unit/unittest/CMakeLists.txt Change-Id: I124ad492df403286751e175d27fe36487ddf6d07
This commit is contained in:
@@ -602,15 +602,15 @@ void BranchModel::removeTag(const QModelIndex &idx)
|
||||
removeNode(idx);
|
||||
}
|
||||
|
||||
void BranchModel::checkoutBranch(const QModelIndex &idx)
|
||||
VcsCommand *BranchModel::checkoutBranch(const QModelIndex &idx)
|
||||
{
|
||||
QString branch = fullName(idx, !isLocal(idx));
|
||||
if (branch.isEmpty())
|
||||
return;
|
||||
return nullptr;
|
||||
|
||||
// No StashGuard since this function for now is only used with clean working dir.
|
||||
// If it is ever used from another place, please add StashGuard here
|
||||
d->client->checkout(d->workingDirectory, branch, GitClient::StashMode::NoStash);
|
||||
return d->client->checkout(d->workingDirectory, branch, GitClient::StashMode::NoStash);
|
||||
}
|
||||
|
||||
bool BranchModel::branchIsMerged(const QModelIndex &idx)
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#include <QAbstractListModel>
|
||||
#include <QVariant>
|
||||
|
||||
namespace VcsBase { class VcsCommand; }
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
@@ -78,7 +80,7 @@ public:
|
||||
|
||||
void removeBranch(const QModelIndex &idx);
|
||||
void removeTag(const QModelIndex &idx);
|
||||
void checkoutBranch(const QModelIndex &idx);
|
||||
VcsBase::VcsCommand *checkoutBranch(const QModelIndex &idx);
|
||||
bool branchIsMerged(const QModelIndex &idx);
|
||||
QModelIndex addBranch(const QString &name, bool track, const QModelIndex &trackedBranch);
|
||||
void setRemoteTracking(const QModelIndex &trackingIndex);
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <utils/navigationtreeview.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/utilsicons.h>
|
||||
#include <vcsbase/vcscommand.h>
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
|
||||
#include <QDir>
|
||||
@@ -382,21 +383,28 @@ bool BranchView::checkout()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_model->checkoutBranch(selected);
|
||||
|
||||
QString stashName;
|
||||
client->synchronousStashList(m_repository, &stashes);
|
||||
for (const Stash &stash : qAsConst(stashes)) {
|
||||
if (stash.message.startsWith(popMessageStart)) {
|
||||
stashName = stash.name;
|
||||
break;
|
||||
}
|
||||
VcsBase::VcsCommand *command = m_model->checkoutBranch(selected);
|
||||
const bool moveChanges = branchCheckoutDialog.moveLocalChangesToNextBranch();
|
||||
const bool popStash = branchCheckoutDialog.popStashOfNextBranch();
|
||||
if (command && (moveChanges || popStash)) {
|
||||
connect(command, &VcsBase::VcsCommand::finished,
|
||||
this, [this, client, popMessageStart, moveChanges, popStash] {
|
||||
if (moveChanges) {
|
||||
client->endStashScope(m_repository);
|
||||
} else if (popStash) {
|
||||
QList<Stash> stashes;
|
||||
QString stashName;
|
||||
client->synchronousStashList(m_repository, &stashes);
|
||||
for (const Stash &stash : qAsConst(stashes)) {
|
||||
if (stash.message.startsWith(popMessageStart)) {
|
||||
stashName = stash.name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
client->synchronousStashRestore(m_repository, stashName, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (branchCheckoutDialog.moveLocalChangesToNextBranch())
|
||||
client->endStashScope(m_repository);
|
||||
else if (branchCheckoutDialog.popStashOfNextBranch())
|
||||
client->synchronousStashRestore(m_repository, stashName, true);
|
||||
}
|
||||
|
||||
if (QTC_GUARD(m_branchView))
|
||||
|
||||
@@ -1163,11 +1163,11 @@ VcsBaseEditorWidget *GitClient::annotate(
|
||||
return editor;
|
||||
}
|
||||
|
||||
void GitClient::checkout(const QString &workingDirectory, const QString &ref,
|
||||
StashMode stashMode)
|
||||
VcsCommand *GitClient::checkout(const QString &workingDirectory, const QString &ref,
|
||||
StashMode stashMode)
|
||||
{
|
||||
if (stashMode == StashMode::TryStash && !beginStashScope(workingDirectory, "Checkout"))
|
||||
return;
|
||||
return nullptr;
|
||||
QStringList arguments = setupCheckoutArguments(workingDirectory, ref);
|
||||
VcsCommand *command = vcsExec(
|
||||
workingDirectory, arguments, nullptr, true,
|
||||
@@ -1179,6 +1179,7 @@ void GitClient::checkout(const QString &workingDirectory, const QString &ref,
|
||||
if (success)
|
||||
updateSubmodulesIfNeeded(workingDirectory, true);
|
||||
});
|
||||
return command;
|
||||
}
|
||||
|
||||
/* method used to setup arguments for checkout, in case user wants to create local branch */
|
||||
@@ -2848,9 +2849,9 @@ GitClient::RevertResult GitClient::revertI(QStringList files,
|
||||
QStringList stagedFiles = allStagedFiles;
|
||||
QStringList unstagedFiles = allUnstagedFiles;
|
||||
if (!isDirectory) {
|
||||
const QSet<QString> filesSet = files.toSet();
|
||||
stagedFiles = allStagedFiles.toSet().intersect(filesSet).toList();
|
||||
unstagedFiles = allUnstagedFiles.toSet().intersect(filesSet).toList();
|
||||
const QSet<QString> filesSet = Utils::toSet(files);
|
||||
stagedFiles = Utils::toList(Utils::toSet(allStagedFiles).intersect(filesSet));
|
||||
unstagedFiles = Utils::toList(Utils::toSet(allUnstagedFiles).intersect(filesSet));
|
||||
}
|
||||
if ((!revertStaging || stagedFiles.empty()) && unstagedFiles.empty())
|
||||
return RevertUnchanged;
|
||||
@@ -2933,7 +2934,7 @@ void GitClient::pull(const QString &workingDirectory, bool rebase)
|
||||
abortCommand = "merge";
|
||||
}
|
||||
|
||||
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase);
|
||||
VcsCommand *command = vcsExecAbortable(workingDirectory, arguments, rebase, abortCommand);
|
||||
connect(command, &VcsCommand::success, this,
|
||||
[this, workingDirectory] { updateSubmodulesIfNeeded(workingDirectory, true); },
|
||||
Qt::QueuedConnection);
|
||||
@@ -3135,11 +3136,13 @@ void GitClient::revert(const QString &workingDirectory, const QString &argument)
|
||||
// Stashing is handled prior to this call.
|
||||
VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory,
|
||||
const QStringList &arguments,
|
||||
bool isRebase)
|
||||
bool isRebase,
|
||||
QString abortCommand)
|
||||
{
|
||||
QTC_ASSERT(!arguments.isEmpty(), return nullptr);
|
||||
|
||||
QString abortCommand = arguments.at(0);
|
||||
if (abortCommand.isEmpty())
|
||||
abortCommand = arguments.at(0);
|
||||
VcsCommand *command = createCommand(workingDirectory, nullptr, VcsWindowOutputBind);
|
||||
command->setCookie(workingDirectory);
|
||||
command->addFlags(VcsCommand::SshPasswordPrompt
|
||||
|
||||
@@ -126,7 +126,8 @@ public:
|
||||
|
||||
VcsBase::VcsCommand *vcsExecAbortable(const QString &workingDirectory,
|
||||
const QStringList &arguments,
|
||||
bool isRebase = false);
|
||||
bool isRebase = false,
|
||||
QString abortCommand = QString());
|
||||
|
||||
QString findRepositoryForDirectory(const QString &directory) const;
|
||||
QString findGitDirForRepository(const QString &repositoryDir) const;
|
||||
@@ -174,8 +175,8 @@ public:
|
||||
QString revision = QString(), QString *errorMessage = nullptr,
|
||||
bool revertStaging = true);
|
||||
enum class StashMode { NoStash, TryStash };
|
||||
void checkout(const QString &workingDirectory, const QString &ref,
|
||||
StashMode stashMode = StashMode::TryStash);
|
||||
VcsBase::VcsCommand *checkout(const QString &workingDirectory, const QString &ref,
|
||||
StashMode stashMode = StashMode::TryStash);
|
||||
|
||||
QStringList setupCheckoutArguments(const QString &workingDirectory, const QString &ref);
|
||||
void updateSubmodulesIfNeeded(const QString &workingDirectory, bool prompt);
|
||||
|
||||
Reference in New Issue
Block a user