forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.7'
Conflicts: src/plugins/qnx/blackberrydeployconfiguration.cpp Change-Id: I16d1c7717f4bc25ba7e8dbdd5be6580fafe3f33d
This commit is contained in:
@@ -1,22 +1,13 @@
|
||||
- Make texts translatable
|
||||
- Do not use QErrorMessage, Creator standard error instead?
|
||||
Commands:
|
||||
- P2:
|
||||
- branch [list, create, delete]
|
||||
- checkout [with/without creation]
|
||||
- combine both above to a single dialog?
|
||||
- P3:
|
||||
- stash [creating, listing, applying]
|
||||
- allow to use external viewer instead of greenhouse one
|
||||
as these have more functionality usually
|
||||
|
||||
GUI:
|
||||
- Better diff view
|
||||
- Commit view View (reuse diff view?)
|
||||
- Commit action View
|
||||
- Able to add further files to commit (list of modified/untracked files)
|
||||
- use List for Log (and allow 10+ entries)
|
||||
- Have commits clickable for 'git show'
|
||||
Backend:
|
||||
- Don't use forked processes, instead find a library connection like libgit-thin
|
||||
- http://repo.or.cz/w/git/libgit-gsoc.git
|
||||
|
||||
@@ -46,15 +46,12 @@ struct CloneWizardPagePrivate {
|
||||
const QString mainLinePostfix;
|
||||
const QString gitPostFix;
|
||||
const QString protocolDelimiter;
|
||||
QCheckBox *deleteMasterCheckBox;
|
||||
QString headBranch;
|
||||
};
|
||||
|
||||
CloneWizardPagePrivate::CloneWizardPagePrivate() :
|
||||
mainLinePostfix(QLatin1String("/mainline.git")),
|
||||
gitPostFix(QLatin1String(".git")),
|
||||
protocolDelimiter(QLatin1String("://")),
|
||||
deleteMasterCheckBox(0)
|
||||
protocolDelimiter(QLatin1String("://"))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -74,10 +71,6 @@ CloneWizardPage::CloneWizardPage(QWidget *parent) :
|
||||
setTitle(tr("Location"));
|
||||
setSubTitle(tr("Specify repository URL, checkout directory and path."));
|
||||
setRepositoryLabel(tr("Clone URL:"));
|
||||
d->deleteMasterCheckBox = new QCheckBox(tr("Delete master branch"));
|
||||
d->deleteMasterCheckBox->setToolTip(tr("Delete the master branch after checking out the repository."));
|
||||
addLocalControl(d->deleteMasterCheckBox);
|
||||
setDeleteMasterBranch(true);
|
||||
}
|
||||
|
||||
CloneWizardPage::~CloneWizardPage()
|
||||
@@ -85,16 +78,6 @@ CloneWizardPage::~CloneWizardPage()
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool CloneWizardPage::deleteMasterBranch() const
|
||||
{
|
||||
return d->deleteMasterCheckBox->isChecked();
|
||||
}
|
||||
|
||||
void CloneWizardPage::setDeleteMasterBranch(bool v)
|
||||
{
|
||||
d->deleteMasterCheckBox->setChecked(v);
|
||||
}
|
||||
|
||||
QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const
|
||||
{
|
||||
/* Try to figure out a good directory name from something like:
|
||||
@@ -143,34 +126,13 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizardPage::createCheckoutJob(
|
||||
|
||||
VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob;
|
||||
const QProcessEnvironment env = client->processEnvironment();
|
||||
|
||||
// 1) Basic checkout step
|
||||
QStringList args;
|
||||
args << QLatin1String("clone") << repository() << checkoutDir;
|
||||
job->addStep(binary, args, workingDirectory, env);
|
||||
const QString checkoutBranch = branch();
|
||||
|
||||
// 2) Checkout branch, change to checkoutDir
|
||||
if (!checkoutBranch.isEmpty() && checkoutBranch != d->headBranch) {
|
||||
// Create branch
|
||||
if (!d->urlIsLocal(repository())) {
|
||||
args.clear();
|
||||
args << QLatin1String("branch") << QLatin1String("--track")
|
||||
<< checkoutBranch << (QLatin1String("origin/") + checkoutBranch);
|
||||
job->addStep(binary, args, *checkoutPath, env);
|
||||
}
|
||||
// Checkout branch
|
||||
args.clear();
|
||||
args << QLatin1String("checkout") << checkoutBranch;
|
||||
job->addStep(binary, args, *checkoutPath, env);
|
||||
if (deleteMasterBranch() && d->headBranch != QLatin1String("<detached HEAD>")) {
|
||||
// Make sure we only have the requested branch:
|
||||
args.clear();
|
||||
args << QLatin1String("branch") << QLatin1String("-D") << d->headBranch;
|
||||
}
|
||||
job->addStep(binary, args, *checkoutPath, env);
|
||||
}
|
||||
|
||||
QStringList args(QLatin1String("clone"));
|
||||
if (!checkoutBranch.isEmpty())
|
||||
args << QLatin1String("--branch") << checkoutBranch;
|
||||
args << repository() << checkoutDir;
|
||||
job->addStep(binary, args, workingDirectory, env);
|
||||
return QSharedPointer<VcsBase::AbstractCheckoutJob>(job);
|
||||
}
|
||||
|
||||
@@ -178,15 +140,12 @@ QStringList CloneWizardPage::branches(const QString &repository, int *current)
|
||||
{
|
||||
// Run git on remote repository if an URL was specified.
|
||||
*current = -1;
|
||||
d->headBranch.clear();
|
||||
|
||||
if (repository.isEmpty())
|
||||
return QStringList();
|
||||
const QStringList branches = Internal::GitPlugin::instance()->gitClient()->synchronousRepositoryBranches(repository);
|
||||
if (!branches.isEmpty()) {
|
||||
if (!branches.isEmpty())
|
||||
*current = 0; // default branch is always returned first!
|
||||
d->headBranch = branches.at(0);
|
||||
}
|
||||
return branches;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ struct CloneWizardPagePrivate;
|
||||
class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool deleteMasterBranch READ deleteMasterBranch WRITE setDeleteMasterBranch)
|
||||
public:
|
||||
explicit CloneWizardPage(QWidget *parent = 0);
|
||||
~CloneWizardPage();
|
||||
@@ -57,9 +56,6 @@ protected:
|
||||
QString directoryFromRepository(const QString &r) const;
|
||||
QStringList branches(const QString &repository, int *current);
|
||||
|
||||
bool deleteMasterBranch() const;
|
||||
void setDeleteMasterBranch(bool v);
|
||||
|
||||
private:
|
||||
CloneWizardPagePrivate *d;
|
||||
};
|
||||
|
||||
@@ -365,31 +365,25 @@ const char *GitClient::decorateOption = "--decorate";
|
||||
|
||||
QString GitClient::findRepositoryForDirectory(const QString &dir)
|
||||
{
|
||||
if (gitVersion() >= 0x010700) {
|
||||
// Find a directory to run git in:
|
||||
const QString root = QDir::rootPath();
|
||||
const QString home = QDir::homePath();
|
||||
// Find a directory to run git in:
|
||||
const QString root = QDir::rootPath();
|
||||
const QString home = QDir::homePath();
|
||||
|
||||
QDir directory(dir);
|
||||
do {
|
||||
const QString absDirPath = directory.absolutePath();
|
||||
if (absDirPath == root || absDirPath == home)
|
||||
break;
|
||||
QDir directory(dir);
|
||||
do {
|
||||
const QString absDirPath = directory.absolutePath();
|
||||
if (absDirPath == root || absDirPath == home)
|
||||
break;
|
||||
|
||||
if (directory.exists())
|
||||
break;
|
||||
} while (directory.cdUp());
|
||||
if (directory.exists())
|
||||
break;
|
||||
} while (directory.cdUp());
|
||||
|
||||
QByteArray outputText;
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("rev-parse") << QLatin1String("--show-toplevel");
|
||||
fullySynchronousGit(directory.absolutePath(), arguments, &outputText, 0, false);
|
||||
return QString::fromLocal8Bit(outputText.trimmed());
|
||||
} else {
|
||||
// Check for ".git/config"
|
||||
const QString checkFile = QLatin1String(GIT_DIRECTORY) + QLatin1String("/config");
|
||||
return VcsBase::VcsBasePlugin::findRepositoryForDirectory(dir, checkFile);
|
||||
}
|
||||
QByteArray outputText;
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("rev-parse") << QLatin1String("--show-toplevel");
|
||||
fullySynchronousGit(directory.absolutePath(), arguments, &outputText, 0, false);
|
||||
return QString::fromLocal8Bit(outputText.trimmed());
|
||||
}
|
||||
|
||||
QString GitClient::findGitDirForRepository(const QString &repositoryDir)
|
||||
@@ -1841,9 +1835,7 @@ bool GitClient::getCommitData(const QString &workingDirectory,
|
||||
if (amend) {
|
||||
// Amend: get last commit data as "SHA1<tab>author<tab>email<tab>message".
|
||||
QStringList args(QLatin1String("log"));
|
||||
const QString msgFormat = QLatin1String((gitVersion() > 0x010701) ? "%B" : "%s%n%n%b");
|
||||
const QString format = QLatin1String("%h\t%an\t%ae\t") + msgFormat;
|
||||
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:") + format;
|
||||
args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:%h\t%an\t%ae\t%B");
|
||||
QTextCodec *codec = QTextCodec::codecForName(commitData->commitEncoding.toLocal8Bit());
|
||||
const Utils::SynchronousProcessResponse sp = synchronousGit(repoDirectory, args, 0, codec);
|
||||
if (sp.result != Utils::SynchronousProcessResponse::Finished) {
|
||||
@@ -1914,7 +1906,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
|
||||
filesToAdd.append(file);
|
||||
|
||||
if ((state & StagedFile) && !checked) {
|
||||
if (state & (AddedFile | DeletedFile)) {
|
||||
if (state & (ModifiedFile | AddedFile | DeletedFile)) {
|
||||
filesToReset.append(file);
|
||||
} else if (state & (RenamedFile | CopiedFile)) {
|
||||
const QString newFile = file.mid(file.indexOf(renameSeparator) + renameSeparator.count());
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QErrorMessage;
|
||||
class QSignalMapper;
|
||||
class QDebug;
|
||||
class QProcessEnvironment;
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "settingspage.h"
|
||||
#include "resetdialog.h"
|
||||
#include "mergetool.h"
|
||||
#include "gitutils.h"
|
||||
|
||||
#include "gerrit/gerritplugin.h"
|
||||
|
||||
@@ -55,6 +56,7 @@
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
#include <coreplugin/documentmanager.h>
|
||||
@@ -81,6 +83,8 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
static const unsigned minimumRequiredVersion = 0x010702;
|
||||
|
||||
static const VcsBase::VcsBaseEditorParameters editorParameters[] = {
|
||||
{
|
||||
VcsBase::RegularCommandOutput,
|
||||
@@ -848,6 +852,26 @@ void GitPlugin::startCommit(bool amend)
|
||||
openSubmitEditor(m_commitMessageFileName, data, amend);
|
||||
}
|
||||
|
||||
void GitPlugin::updateVersionWarning()
|
||||
{
|
||||
if (m_gitClient->gitVersion() >= minimumRequiredVersion)
|
||||
return;
|
||||
Core::IEditor *curEditor = Core::EditorManager::currentEditor();
|
||||
if (!curEditor)
|
||||
return;
|
||||
Core::IDocument *curDocument = curEditor->document();
|
||||
if (!curDocument)
|
||||
return;
|
||||
Core::InfoBar *infoBar = curDocument->infoBar();
|
||||
Core::Id gitVersionWarning("GitVersionWarning");
|
||||
if (!infoBar->canInfoBeAdded(gitVersionWarning))
|
||||
return;
|
||||
infoBar->addInfo(Core::InfoBarEntry(gitVersionWarning,
|
||||
tr("Unsupported version of Git found. Git %1 or later required.")
|
||||
.arg(versionString(minimumRequiredVersion)),
|
||||
Core::InfoBarEntry::GlobalSuppressionEnabled));
|
||||
}
|
||||
|
||||
Core::IEditor *GitPlugin::openSubmitEditor(const QString &fileName, const CommitData &cd, bool amend)
|
||||
{
|
||||
Core::IEditor *editor = Core::EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID,
|
||||
@@ -934,22 +958,25 @@ void GitPlugin::pull()
|
||||
{
|
||||
const VcsBase::VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
QString topLevel = state.topLevel();
|
||||
bool rebase = m_gitClient->settings()->boolValue(GitSettings::pullRebaseKey);
|
||||
|
||||
if (!rebase) {
|
||||
bool isDetached;
|
||||
QString branchRebaseConfig = m_gitClient->synchronousRepositoryBranches(state.topLevel(), &isDetached).at(0);
|
||||
QString branchRebaseConfig = m_gitClient->synchronousRepositoryBranches(topLevel, &isDetached).at(0);
|
||||
if (!isDetached) {
|
||||
branchRebaseConfig.prepend(QLatin1String("branch."));
|
||||
branchRebaseConfig.append(QLatin1String(".rebase"));
|
||||
rebase = (m_gitClient->readConfigValue(state.topLevel(), branchRebaseConfig) == QLatin1String("true"));
|
||||
rebase = (m_gitClient->readConfigValue(topLevel, branchRebaseConfig) == QLatin1String("true"));
|
||||
}
|
||||
}
|
||||
|
||||
GitClient::StashGuard stashGuard(state.topLevel(), QLatin1String("Pull"));
|
||||
if (stashGuard.stashingFailed(false) || (rebase && (stashGuard.result() == GitClient::NotStashed)))
|
||||
GitClient::StashGuard stashGuard(topLevel, QLatin1String("Pull"));
|
||||
if (stashGuard.stashingFailed(false))
|
||||
return;
|
||||
if (!m_gitClient->synchronousPull(state.topLevel(), rebase))
|
||||
if (rebase && (stashGuard.result() == GitClient::NotStashed))
|
||||
m_gitClient->synchronousCheckoutFiles(topLevel);
|
||||
if (!m_gitClient->synchronousPull(topLevel, rebase))
|
||||
stashGuard.preventPop();
|
||||
}
|
||||
|
||||
@@ -1157,6 +1184,8 @@ void GitPlugin::updateActions(VcsBase::VcsBasePlugin::ActionState as)
|
||||
m_commandLocator->setEnabled(repositoryEnabled);
|
||||
if (!enableMenuAction(as, m_menuAction))
|
||||
return;
|
||||
if (repositoryEnabled)
|
||||
updateVersionWarning();
|
||||
// Note: This menu is visible if there is no repository. Only
|
||||
// 'Create Repository'/'Show' actions should be available.
|
||||
const QString fileName = currentState().currentFileName();
|
||||
|
||||
@@ -194,6 +194,7 @@ private:
|
||||
void cleanRepository(const QString &directory);
|
||||
void applyPatch(const QString &workingDirectory, QString file = QString());
|
||||
void startCommit(bool amend);
|
||||
void updateVersionWarning();
|
||||
|
||||
static GitPlugin *m_instance;
|
||||
Locator::CommandLocator *m_commandLocator;
|
||||
|
||||
@@ -94,5 +94,19 @@ bool inputText(QWidget *parent, const QString &title, const QString &prompt, QSt
|
||||
*s = dialog.textValue();
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline QString versionPart(unsigned part)
|
||||
{
|
||||
return QString::number(part & 0xff, 16);
|
||||
}
|
||||
|
||||
QString versionString(unsigned ver)
|
||||
{
|
||||
return QString::fromLatin1("%1.%2.%3")
|
||||
.arg(versionPart(ver >> 16))
|
||||
.arg(versionPart(ver >> 8))
|
||||
.arg(versionPart(ver));
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Git
|
||||
|
||||
@@ -61,6 +61,8 @@ inline unsigned version(unsigned major, unsigned minor, unsigned patch)
|
||||
return (major << 16) + (minor << 8) + patch;
|
||||
}
|
||||
|
||||
QString versionString(unsigned ver);
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Git
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <utils/qtcassert.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QFileInfo>
|
||||
|
||||
static const char stashMessageKeywordC[] = "IVersionControl@";
|
||||
@@ -71,32 +70,20 @@ bool GitVersionControl::supportsOperation(Operation operation) const
|
||||
if (!isConfigured())
|
||||
return false;
|
||||
|
||||
bool rc = false;
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
rc = m_client->gitVersion() >= version(1, 6, 1);;
|
||||
break;
|
||||
case DeleteOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case MoveOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case OpenOperation:
|
||||
break;
|
||||
case CreateRepositoryOperation:
|
||||
case SnapshotOperations:
|
||||
rc = true;
|
||||
break;
|
||||
case AnnotateOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case CheckoutOperation:
|
||||
case GetRepositoryRootOperation:
|
||||
rc = true;
|
||||
return true;
|
||||
case OpenOperation:
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
|
||||
@@ -107,7 +94,6 @@ bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
|
||||
bool GitVersionControl::vcsAdd(const QString & fileName)
|
||||
{
|
||||
// Implement in terms of using "--intent-to-add"
|
||||
QTC_ASSERT(m_client->gitVersion() >= version(1, 6, 1), return false);
|
||||
const QFileInfo fi(fileName);
|
||||
return m_client->synchronousAdd(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
}
|
||||
|
||||
@@ -122,10 +122,10 @@ bool ResetDialog::populateLog(const QString &repository)
|
||||
if (const int rowCount = m_model->rowCount())
|
||||
m_model->removeRows(0, rowCount);
|
||||
|
||||
// Retrieve log using a custom format "Sha1:Subject"
|
||||
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
|
||||
GitClient *client = GitPlugin::instance()->gitClient();
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("--max-count=30") << QLatin1String("--format=%h:%s");
|
||||
arguments << QLatin1String("--max-count=30") << QLatin1String("--format=%h:%s %d");
|
||||
QString output;
|
||||
if (!client->synchronousLog(repository, arguments, &output))
|
||||
return false;
|
||||
@@ -136,6 +136,11 @@ bool ResetDialog::populateLog(const QString &repository)
|
||||
for (int c = 0; c < ColumnCount; ++c) {
|
||||
QStandardItem *item = new QStandardItem;
|
||||
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
|
||||
if (line.endsWith(QLatin1Char(')'))) {
|
||||
QFont font = item->font();
|
||||
font.setItalic(true);
|
||||
item->setFont(font);
|
||||
}
|
||||
row.push_back(item);
|
||||
}
|
||||
row[Sha1Column]->setText(line.left(colonPos));
|
||||
|
||||
Reference in New Issue
Block a user