changeset 154:6bcb4a4d6521

* Try to reduce unnecessary history updates; add --new-branch option on push
author Chris Cannam
date Thu, 02 Dec 2010 18:04:21 +0000
parents 70fe12873106
children edab92f3ea0b
files hgtabwidget.cpp hgtabwidget.h historywidget.cpp historywidget.h mainwindow.cpp
diffstat 5 files changed, 28 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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;
--- 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 <QGridLayout>
 
-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();
--- 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<QString> m_newIds;
     bool m_showUncommitted;
+    bool m_refreshNeeded;
 
     Panned *m_panned;
     Panner *m_panner;
--- 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()