forked from qt-creator/qt-creator
Git: Display tracking branch for newly created branches
+ Get rid of a workaround done for retrieving sha Change-Id: I4b7a6c6d9e9be5766f4fc540dc8b15037eb7948c Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
40f3efbc21
commit
744d5d51ab
@@ -121,12 +121,13 @@ void BranchDialog::refresh()
|
|||||||
|
|
||||||
void BranchDialog::add()
|
void BranchDialog::add()
|
||||||
{
|
{
|
||||||
QString trackedBranch = m_model->branchName(selectedIndex());
|
QModelIndex trackedIndex = selectedIndex();
|
||||||
bool isLocal = m_model->isLocal(selectedIndex());
|
QString trackedBranch = m_model->branchName(trackedIndex);
|
||||||
if (trackedBranch.isEmpty()) {
|
if (trackedBranch.isEmpty()) {
|
||||||
trackedBranch = m_model->branchName(m_model->currentBranch());
|
trackedIndex = m_model->currentBranch();
|
||||||
isLocal = true;
|
trackedBranch = m_model->branchName(trackedIndex);
|
||||||
}
|
}
|
||||||
|
const bool isLocal = m_model->isLocal(trackedIndex);
|
||||||
|
|
||||||
QStringList localNames = m_model->localBranchNames();
|
QStringList localNames = m_model->localBranchNames();
|
||||||
|
|
||||||
@@ -143,7 +144,7 @@ void BranchDialog::add()
|
|||||||
branchAddDialog.setTrackedBranchName(trackedBranch, !isLocal);
|
branchAddDialog.setTrackedBranchName(trackedBranch, !isLocal);
|
||||||
|
|
||||||
if (branchAddDialog.exec() == QDialog::Accepted && m_model) {
|
if (branchAddDialog.exec() == QDialog::Accepted && m_model) {
|
||||||
QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedBranch);
|
QModelIndex idx = m_model->addBranch(branchAddDialog.branchName(), branchAddDialog.track(), trackedIndex);
|
||||||
m_ui->branchView->selectionModel()->select(idx, QItemSelectionModel::Clear
|
m_ui->branchView->selectionModel()->select(idx, QItemSelectionModel::Clear
|
||||||
| QItemSelectionModel::Select
|
| QItemSelectionModel::Select
|
||||||
| QItemSelectionModel::Current);
|
| QItemSelectionModel::Current);
|
||||||
|
|||||||
@@ -513,19 +513,20 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex BranchModel::addBranch(const QString &branchName, bool track, const QString &startPoint)
|
QModelIndex BranchModel::addBranch(const QString &name, bool track, const QModelIndex &startPoint)
|
||||||
{
|
{
|
||||||
if (!m_rootNode || !m_rootNode->count())
|
if (!m_rootNode || !m_rootNode->count())
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
|
||||||
|
const QString trackedBranch = branchName(startPoint);
|
||||||
QString output;
|
QString output;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
|
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
|
||||||
args << branchName;
|
args << name;
|
||||||
if (!startPoint.isEmpty())
|
if (!trackedBranch.isEmpty())
|
||||||
args << startPoint;
|
args << trackedBranch;
|
||||||
|
|
||||||
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
|
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &errorMessage)) {
|
||||||
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
|
VcsBase::VcsBaseOutputWindow::instance()->appendError(errorMessage);
|
||||||
@@ -535,21 +536,10 @@ QModelIndex BranchModel::addBranch(const QString &branchName, bool track, const
|
|||||||
BranchNode *local = m_rootNode->children.at(0);
|
BranchNode *local = m_rootNode->children.at(0);
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
for (pos = 0; pos < local->count(); ++pos) {
|
for (pos = 0; pos < local->count(); ++pos) {
|
||||||
if (local->children.at(pos)->name > branchName)
|
if (local->children.at(pos)->name > name)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BranchNode *newNode = new BranchNode(branchName);
|
BranchNode *newNode = new BranchNode(name, sha(startPoint), trackedBranch);
|
||||||
|
|
||||||
// find the sha of the new branch:
|
|
||||||
output = toolTip(branchName); // abuse toolTip to get the data;-)
|
|
||||||
QStringList lines = output.split(QLatin1Char('\n'));
|
|
||||||
foreach (const QString &l, lines) {
|
|
||||||
if (l.startsWith(QLatin1String("commit "))) {
|
|
||||||
newNode->sha = l.mid(7, 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
beginInsertRows(index(0, 0), pos, pos);
|
beginInsertRows(index(0, 0), pos, pos);
|
||||||
newNode->parent = local;
|
newNode->parent = local;
|
||||||
local->children.insert(pos, newNode);
|
local->children.insert(pos, newNode);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
void removeBranch(const QModelIndex &idx);
|
void removeBranch(const QModelIndex &idx);
|
||||||
void checkoutBranch(const QModelIndex &idx);
|
void checkoutBranch(const QModelIndex &idx);
|
||||||
bool branchIsMerged(const QModelIndex &idx);
|
bool branchIsMerged(const QModelIndex &idx);
|
||||||
QModelIndex addBranch(const QString &branchName, bool track, const QString &trackedBranch);
|
QModelIndex addBranch(const QString &name, bool track, const QModelIndex &trackedBranch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void parseOutputLine(const QString &line);
|
void parseOutputLine(const QString &line);
|
||||||
|
|||||||
Reference in New Issue
Block a user