forked from qt-creator/qt-creator
Merge remote branch 'origin/2.1'
Conflicts: share/qtcreator/templates/mobileapp/app.pro share/qtcreator/templates/qmlapp/app.pro src/plugins/cpptools/cpptools.pro
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <utils/environment.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
@@ -1922,6 +1923,67 @@ QString GitClient::readConfigValue(const QString &workingDirectory, const QStrin
|
||||
return readConfig(workingDirectory, QStringList(configVar)).remove(QLatin1Char('\n'));
|
||||
}
|
||||
|
||||
bool GitClient::cloneRepository(const QString &directory,const QByteArray &url)
|
||||
{
|
||||
QDir workingDirectory(directory);
|
||||
const unsigned flags = VCSBase::VCSBasePlugin::SshPasswordPrompt |
|
||||
VCSBase::VCSBasePlugin::ShowStdOutInLogWindow|
|
||||
VCSBase::VCSBasePlugin::ShowSuccessMessage;
|
||||
|
||||
if (workingDirectory.exists()) {
|
||||
if (!synchronousInit(workingDirectory.path()))
|
||||
return false;
|
||||
|
||||
QStringList arguments(QLatin1String("remote"));
|
||||
arguments << QLatin1String("add") << QLatin1String("origin") << url;
|
||||
if (!fullySynchronousGit(workingDirectory.path(), arguments, 0, 0, true))
|
||||
return false;
|
||||
|
||||
arguments.clear();
|
||||
arguments << QLatin1String("fetch");
|
||||
const Utils::SynchronousProcessResponse resp =
|
||||
synchronousGit(workingDirectory.path(), arguments, flags);
|
||||
if (resp.result != Utils::SynchronousProcessResponse::Finished)
|
||||
return false;
|
||||
|
||||
arguments.clear();
|
||||
arguments << QLatin1String("config")
|
||||
<< QLatin1String("branch.master.remote")
|
||||
<< QLatin1String("origin");
|
||||
if (!fullySynchronousGit(workingDirectory.path(), arguments, 0, 0, true))
|
||||
return false;
|
||||
|
||||
arguments.clear();
|
||||
arguments << QLatin1String("config")
|
||||
<< QLatin1String("branch.master.merge")
|
||||
<< QLatin1String("refs/heads/master");
|
||||
if (!fullySynchronousGit(workingDirectory.path(), arguments, 0, 0, true))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
} else {
|
||||
QStringList arguments(QLatin1String("clone"));
|
||||
arguments << url << workingDirectory.dirName();
|
||||
workingDirectory.cdUp();
|
||||
const Utils::SynchronousProcessResponse resp =
|
||||
synchronousGit(workingDirectory.path(), arguments, flags);
|
||||
return resp.result == Utils::SynchronousProcessResponse::Finished;
|
||||
}
|
||||
}
|
||||
|
||||
QString GitClient::vcsGetRepositoryURL(const QString &directory)
|
||||
{
|
||||
QStringList arguments(QLatin1String("config"));
|
||||
QByteArray outputText;
|
||||
|
||||
arguments << QLatin1String("remote.origin.url");
|
||||
|
||||
if (fullySynchronousGit(directory, arguments, &outputText, 0, false)) {
|
||||
return commandOutputFromLocal8Bit(outputText);
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
GitSettings GitClient::settings() const
|
||||
{
|
||||
return m_settings;
|
||||
|
||||
@@ -158,6 +158,8 @@ public:
|
||||
unsigned gitVersion(bool silent, QString *errorMessage = 0);
|
||||
QString gitVersionString(bool silent, QString *errorMessage = 0);
|
||||
|
||||
bool cloneRepository(const QString &directory, const QByteArray &url);
|
||||
QString vcsGetRepositoryURL(const QString &directory);
|
||||
bool synchronousFetch(const QString &workingDirectory);
|
||||
bool synchronousPull(const QString &workingDirectory);
|
||||
bool synchronousPush(const QString &workingDirectory);
|
||||
|
||||
@@ -34,10 +34,13 @@
|
||||
#include <texteditor/fontsettings.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QRegExpValidator>
|
||||
#include <QtGui/QSyntaxHighlighter>
|
||||
#include <QtGui/QTextEdit>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QRegExp>
|
||||
|
||||
namespace Git {
|
||||
@@ -116,11 +119,19 @@ GitSubmitEditorWidget::GitSubmitEditorWidget(QWidget *parent) :
|
||||
m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel);
|
||||
insertTopWidget(m_gitSubmitPanel);
|
||||
new GitSubmitHighlighter(descriptionEdit());
|
||||
|
||||
m_emailValidator = new QRegExpValidator(QRegExp(QLatin1String("[^@ ]+@[^@ ]+\\.[a-zA-Z]+")), this);
|
||||
|
||||
m_gitSubmitPanelUi.emailLineEdit->setValidator(m_emailValidator);
|
||||
connect(m_gitSubmitPanelUi.authorLineEdit, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(authorInformationChanged()));
|
||||
connect(m_gitSubmitPanelUi.emailLineEdit, SIGNAL(textChanged(QString)),
|
||||
this, SLOT(authorInformationChanged()));
|
||||
}
|
||||
|
||||
void GitSubmitEditorWidget::setPanelInfo(const GitSubmitEditorPanelInfo &info)
|
||||
{
|
||||
m_gitSubmitPanelUi.repositoryLabel->setText(info.repository);
|
||||
m_gitSubmitPanelUi.repositoryLabel->setText(QDir::toNativeSeparators(info.repository));
|
||||
m_gitSubmitPanelUi.branchLabel->setText(info.branch);
|
||||
}
|
||||
|
||||
@@ -136,6 +147,32 @@ void GitSubmitEditorWidget::setPanelData(const GitSubmitEditorPanelData &data)
|
||||
{
|
||||
m_gitSubmitPanelUi.authorLineEdit->setText(data.author);
|
||||
m_gitSubmitPanelUi.emailLineEdit->setText(data.email);
|
||||
authorInformationChanged();
|
||||
}
|
||||
|
||||
bool GitSubmitEditorWidget::canSubmit() const
|
||||
{
|
||||
if (m_gitSubmitPanelUi.authorLineEdit->text().isEmpty()
|
||||
|| !emailIsValid())
|
||||
return false;
|
||||
return SubmitEditorWidget::canSubmit();
|
||||
}
|
||||
|
||||
void GitSubmitEditorWidget::authorInformationChanged()
|
||||
{
|
||||
m_gitSubmitPanelUi.invalidAuthorLabel->
|
||||
setVisible(m_gitSubmitPanelUi.authorLineEdit->text().isEmpty());
|
||||
m_gitSubmitPanelUi.invalidEmailLabel->
|
||||
setVisible(!emailIsValid());
|
||||
|
||||
updateSubmitAction();
|
||||
}
|
||||
|
||||
bool GitSubmitEditorWidget::emailIsValid() const
|
||||
{
|
||||
int pos = m_gitSubmitPanelUi.emailLineEdit->cursorPosition();
|
||||
return m_emailValidator->validate(m_gitSubmitPanelUi.emailLineEdit->text(), pos)
|
||||
== QValidator::Acceptable;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -31,8 +31,13 @@
|
||||
#define GITSUBMITEDITORWIDGET_H
|
||||
|
||||
#include "ui_gitsubmitpanel.h"
|
||||
|
||||
#include <utils/submiteditorwidget.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QValidator;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
@@ -49,6 +54,7 @@ struct GitSubmitEditorPanelData;
|
||||
|
||||
class GitSubmitEditorWidget : public Utils::SubmitEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit GitSubmitEditorWidget(QWidget *parent = 0);
|
||||
@@ -59,9 +65,18 @@ public:
|
||||
|
||||
void setPanelInfo(const GitSubmitEditorPanelInfo &info);
|
||||
|
||||
protected:
|
||||
bool canSubmit() const;
|
||||
|
||||
private slots:
|
||||
void authorInformationChanged();
|
||||
|
||||
private:
|
||||
bool emailIsValid() const;
|
||||
|
||||
QWidget *m_gitSubmitPanel;
|
||||
Ui::GitSubmitPanel m_gitSubmitPanelUi;
|
||||
QValidator *m_emailValidator;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>374</width>
|
||||
<height>229</height>
|
||||
<width>364</width>
|
||||
<height>172</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
@@ -59,49 +59,96 @@
|
||||
<property name="title">
|
||||
<string>Commit Information</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="authorLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="authorLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="emailLabel">
|
||||
<property name="text">
|
||||
<string>Email:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="emailLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="authorLabel">
|
||||
<property name="text">
|
||||
<string>Author:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="authorLineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="invalidAuthorLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_error.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>161</width>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="emailLabel">
|
||||
<property name="text">
|
||||
<string>Email:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="emailLineEdit">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QLabel" name="invalidEmailLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../projectexplorer/projectexplorer.qrc">:/projectexplorer/images/compile_error.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="../projectexplorer/projectexplorer.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -87,6 +87,10 @@ bool GitVersionControl::supportsOperation(Operation operation) const
|
||||
case AnnotateOperation:
|
||||
rc = true;
|
||||
break;
|
||||
case CheckoutOperation:
|
||||
case GetRepositoryRootOperation:
|
||||
rc = true;
|
||||
break;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
@@ -121,6 +125,17 @@ bool GitVersionControl::vcsCreateRepository(const QString &directory)
|
||||
{
|
||||
return gitClient()->synchronousInit(directory);
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsCheckout(const QString &directory, const QByteArray &url)
|
||||
{
|
||||
return gitClient()->cloneRepository(directory,url);
|
||||
}
|
||||
|
||||
QString GitVersionControl::vcsGetRepositoryURL(const QString &directory)
|
||||
{
|
||||
return gitClient()->vcsGetRepositoryURL(directory);
|
||||
}
|
||||
|
||||
/* Snapshots are implement using stashes, relying on stash messages for
|
||||
* naming as the actual stash names (stash{n}) are rotated as one adds stashes.
|
||||
* Note that the snapshot interface does not care whether we have an unmodified
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
virtual bool vcsDelete(const QString &filename);
|
||||
virtual bool vcsMove(const QString &from, const QString &to);
|
||||
virtual bool vcsCreateRepository(const QString &directory);
|
||||
virtual bool vcsCheckout(const QString &directory, const QByteArray &url);
|
||||
virtual QString vcsGetRepositoryURL(const QString &directory);
|
||||
virtual QString vcsCreateSnapshot(const QString &topLevel);
|
||||
virtual QStringList vcsSnapshots(const QString &topLevel);
|
||||
virtual bool vcsRestoreSnapshot(const QString &topLevel, const QString &name);
|
||||
|
||||
Reference in New Issue
Block a user