# HG changeset patch # User Chris Cannam # Date 1291313061 0 # Node ID 6bcb4a4d6521651fce1c943842cebf40f1d133ca # Parent 70fe1287310618c49120d4f0af4940f57a7c33bd * Try to reduce unnecessary history updates; add --new-branch option on push diff -r 70fe12873106 -r 6bcb4a4d6521 hgtabwidget.cpp --- a/hgtabwidget.cpp Thu Dec 02 17:55:21 2010 +0000 +++ b/hgtabwidget.cpp Thu Dec 02 18:04:21 2010 +0000 @@ -81,6 +81,11 @@ m_historyWidget->setCurrent(ids, branch, canCommit()); } +void HgTabWidget::updateHistory() +{ + m_historyWidget->update(); +} + bool HgTabWidget::canCommit() const { if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; diff -r 70fe12873106 -r 6bcb4a4d6521 hgtabwidget.h --- a/hgtabwidget.h Thu Dec 02 17:55:21 2010 +0000 +++ b/hgtabwidget.h Thu Dec 02 18:04:21 2010 +0000 @@ -50,6 +50,8 @@ void setCurrent(QStringList ids, QString branch); + void updateHistory(); + FileStates getFileStates() { return m_fileStates; } bool canCommit() const; diff -r 70fe12873106 -r 6bcb4a4d6521 historywidget.cpp --- a/historywidget.cpp Thu Dec 02 17:55:21 2010 +0000 +++ b/historywidget.cpp Thu Dec 02 18:04:21 2010 +0000 @@ -28,7 +28,9 @@ #include -HistoryWidget::HistoryWidget() +HistoryWidget::HistoryWidget() : + m_showUncommitted(false), + m_refreshNeeded(false) { m_panned = new Panned; m_panner = new Panner; @@ -78,7 +80,7 @@ m_currentIds.push_back(id); } - layoutAll(); + m_refreshNeeded = true; } void HistoryWidget::parseNewLog(QString log) @@ -87,7 +89,7 @@ Changesets csets = Changeset::parseChangesets(log); DEBUG << "HistoryWidget::parseNewLog: log has " << csets.size() << " changesets" << endl; replaceChangesets(csets); - layoutAll(); + m_refreshNeeded = true; } void HistoryWidget::parseIncrementalLog(QString log) @@ -97,8 +99,8 @@ DEBUG << "HistoryWidget::parseIncrementalLog: log has " << csets.size() << " changesets" << endl; if (!csets.empty()) { addChangesets(csets); - layoutAll(); } + m_refreshNeeded = true; } void HistoryWidget::replaceChangesets(Changesets csets) @@ -142,8 +144,17 @@ m_changesets = csets; } +void HistoryWidget::update() +{ + if (m_refreshNeeded) { + layoutAll(); + } +} + void HistoryWidget::layoutAll() { + m_refreshNeeded = false; + setChangesetParents(); ChangesetScene *scene = new ChangesetScene(); diff -r 70fe12873106 -r 6bcb4a4d6521 historywidget.h --- a/historywidget.h Thu Dec 02 17:55:21 2010 +0000 +++ b/historywidget.h Thu Dec 02 18:04:21 2010 +0000 @@ -43,6 +43,8 @@ bool haveNewItems() const { return !m_newIds.empty(); } + void update(); + signals: void commit(); void revert(); @@ -61,6 +63,7 @@ QString m_currentBranch; QSet m_newIds; bool m_showUncommitted; + bool m_refreshNeeded; Panned *m_panned; Panner *m_panner; diff -r 70fe12873106 -r 6bcb4a4d6521 mainwindow.cpp --- a/mainwindow.cpp Thu Dec 02 17:55:21 2010 +0000 +++ b/mainwindow.cpp Thu Dec 02 18:04:21 2010 +0000 @@ -632,7 +632,7 @@ QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { QStringList params; - params << "push" << remoteRepoPath; + params << "push" << "--new-branch" << remoteRepoPath; runner->requestAction(HgAction(ACT_PUSH, workFolderPath, params)); } } @@ -1625,6 +1625,8 @@ } else { hgTabs->setState(tr("At the head of %1").arg(branchText)); } + + hgTabs->updateHistory(); } void MainWindow::createActions()