diff src/hgtabwidget.cpp @ 505:1c05e7576ea5

Fix bug #292: "Merge that results in no changes leaves interface in inconsistent state." Show uncommitted state whenever a merge is present, even if no file changes
author Chris Cannam
date Mon, 17 Oct 2011 16:25:02 +0100
parents 896b7903e8f2
children 470829a21f98
line wrap: on
line diff
--- a/src/hgtabwidget.cpp	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/hgtabwidget.cpp	Mon Oct 17 16:25:02 2011 +0100
@@ -28,7 +28,8 @@
 
 HgTabWidget::HgTabWidget(QWidget *parent,
                          QString workFolderPath) :
-    QTabWidget(parent)
+    QTabWidget(parent),
+    m_haveMerge(false)
 {
     // Work tab
     m_fileStatusWidget = new FileStatusWidget;
@@ -132,8 +133,7 @@
 
 void HgTabWidget::setCurrent(QStringList ids, QString branch)
 {
-    bool showUncommitted = haveChangesToCommit();
-    m_historyWidget->setCurrent(ids, branch, showUncommitted);
+    m_historyWidget->setCurrent(ids, branch, haveChangesToCommit());
 }
 
 void HgTabWidget::updateFileStates()
@@ -153,8 +153,8 @@
 
 bool HgTabWidget::canCommit() const
 {
-    if (!m_fileStatusWidget->haveChangesToCommit()) return false;
-    if (!m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
+    if (!haveChangesToCommit()) return false;
+    if (!getAllUnresolvedFiles().empty()) return false;
     return true;
 }
 
@@ -162,8 +162,8 @@
 {
     // Not the same as canCommit() -- we can revert (and diff)
     // unresolved files, but we can't commit them
-    if (!m_fileStatusWidget->haveChangesToCommit() &&
-        m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
+    if (!haveChangesToCommit() &&
+        getAllUnresolvedFiles().empty()) return false;
     return true;
 }
 
@@ -172,10 +172,10 @@
     // Permit this only when work tab is visible
     if (currentIndex() != 0) return false;
 
-    QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
+    QStringList addable = getSelectedAddableFiles();
     if (addable.empty()) return false;
 
-    QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles();
+    QStringList removable = getSelectedRemovableFiles();
     if (!removable.empty()) return false;
 
     return true;
@@ -186,14 +186,14 @@
     // Permit this only when work tab is visible
     if (currentIndex() != 0) return false;
 
-    if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false;
-    if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false;
+    if (getSelectedRemovableFiles().empty()) return false;
+    if (!getSelectedAddableFiles().empty()) return false;
     return true;
 }
 
 bool HgTabWidget::canResolve() const
 {
-    return !m_fileStatusWidget->getAllUnresolvedFiles().empty();
+    return !getAllUnresolvedFiles().empty();
 }
 
 bool HgTabWidget::canIgnore() const
@@ -203,7 +203,7 @@
 
 bool HgTabWidget::haveChangesToCommit() const
 {
-    return m_fileStatusWidget->haveChangesToCommit();
+    return m_haveMerge || m_fileStatusWidget->haveChangesToCommit();
 }
 
 QStringList HgTabWidget::getAllCommittableFiles() const
@@ -237,6 +237,15 @@
     m_fileStatusWidget->setFileStates(m_fileStates);
 }
 
+void HgTabWidget::setHaveMerge(bool haveMerge)
+{
+    if (m_haveMerge != haveMerge) {
+        m_haveMerge = haveMerge;
+        m_historyWidget->setShowUncommitted(haveChangesToCommit());
+        updateHistory();
+    }
+}
+
 void HgTabWidget::setNewLog(QString hgLogList)
 {
     m_historyWidget->parseNewLog(hgLogList);