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()
|
||||
{
|
||||
QString trackedBranch = m_model->branchName(selectedIndex());
|
||||
bool isLocal = m_model->isLocal(selectedIndex());
|
||||
QModelIndex trackedIndex = selectedIndex();
|
||||
QString trackedBranch = m_model->branchName(trackedIndex);
|
||||
if (trackedBranch.isEmpty()) {
|
||||
trackedBranch = m_model->branchName(m_model->currentBranch());
|
||||
isLocal = true;
|
||||
trackedIndex = m_model->currentBranch();
|
||||
trackedBranch = m_model->branchName(trackedIndex);
|
||||
}
|
||||
const bool isLocal = m_model->isLocal(trackedIndex);
|
||||
|
||||
QStringList localNames = m_model->localBranchNames();
|
||||
|
||||
@@ -143,7 +144,7 @@ void BranchDialog::add()
|
||||
branchAddDialog.setTrackedBranchName(trackedBranch, !isLocal);
|
||||
|
||||
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
|
||||
| QItemSelectionModel::Select
|
||||
| QItemSelectionModel::Current);
|
||||
|
||||
@@ -513,19 +513,20 @@ bool BranchModel::branchIsMerged(const QModelIndex &idx)
|
||||
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())
|
||||
return QModelIndex();
|
||||
|
||||
const QString trackedBranch = branchName(startPoint);
|
||||
QString output;
|
||||
QString errorMessage;
|
||||
|
||||
QStringList args;
|
||||
args << (track ? QLatin1String("--track") : QLatin1String("--no-track"));
|
||||
args << branchName;
|
||||
if (!startPoint.isEmpty())
|
||||
args << startPoint;
|
||||
args << name;
|
||||
if (!trackedBranch.isEmpty())
|
||||
args << trackedBranch;
|
||||
|
||||
if (!m_client->synchronousBranchCmd(m_workingDirectory, args, &output, &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);
|
||||
int pos = 0;
|
||||
for (pos = 0; pos < local->count(); ++pos) {
|
||||
if (local->children.at(pos)->name > branchName)
|
||||
if (local->children.at(pos)->name > name)
|
||||
break;
|
||||
}
|
||||
BranchNode *newNode = new BranchNode(branchName);
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
BranchNode *newNode = new BranchNode(name, sha(startPoint), trackedBranch);
|
||||
beginInsertRows(index(0, 0), pos, pos);
|
||||
newNode->parent = local;
|
||||
local->children.insert(pos, newNode);
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
void removeBranch(const QModelIndex &idx);
|
||||
void checkoutBranch(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:
|
||||
void parseOutputLine(const QString &line);
|
||||
|
||||
Reference in New Issue
Block a user