changeset 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 d972f0cd61b3
children 470829a21f98
files src/confirmcommentdialog.cpp src/hgtabwidget.cpp src/hgtabwidget.h src/historywidget.cpp src/historywidget.h src/mainwindow.cpp
diffstat 6 files changed, 43 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/confirmcommentdialog.cpp	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/confirmcommentdialog.cpp	Mon Oct 17 16:25:02 2011 +0100
@@ -91,10 +91,15 @@
     else text = "<qt>" + intro + "<p>";
 
     text += "<code>";
-    foreach (QString file, files) {
-        text += "&nbsp;&nbsp;&nbsp;" + xmlEncode(file) + "<br>";
+    if (files.empty()) {
+        text += "&nbsp;&nbsp;&nbsp;</code>";
+        text += tr("(no files: metadata only)");
+    } else {
+        foreach (QString file, files) {
+            text += "&nbsp;&nbsp;&nbsp;" + xmlEncode(file) + "<br>";
+        }
+        text += "</code></qt>";
     }
-    text += "</code></qt>";
 
     return text;
 }
--- 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);
--- a/src/hgtabwidget.h	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/hgtabwidget.h	Mon Oct 17 16:25:02 2011 +0100
@@ -49,6 +49,8 @@
 
     void setCurrent(QStringList ids, QString branch);
 
+    void setHaveMerge(bool);
+
     void updateFileStates();
     void updateHistory();
 
@@ -113,6 +115,7 @@
     FileStatusWidget *m_fileStatusWidget;
     HistoryWidget *m_historyWidget;
     FileStates m_fileStates;
+    bool m_haveMerge;
 
     Changesets parseChangeSets(QString changeSetsStr);
 };
--- a/src/historywidget.cpp	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/historywidget.cpp	Mon Oct 17 16:25:02 2011 +0100
@@ -86,6 +86,11 @@
 
     m_refreshNeeded = true;
 }
+
+void HistoryWidget::setShowUncommitted(bool showUncommitted)
+{
+    setCurrent(m_currentIds, m_currentBranch, showUncommitted);
+}
     
 void HistoryWidget::parseNewLog(QString log)
 {
--- a/src/historywidget.h	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/historywidget.h	Mon Oct 17 16:25:02 2011 +0100
@@ -37,6 +37,7 @@
     virtual ~HistoryWidget();
 
     void setCurrent(QStringList ids, QString branch, bool showUncommitted);
+    void setShowUncommitted(bool showUncommitted);
 
     void parseNewLog(QString log);
     void parseIncrementalLog(QString log);
--- a/src/mainwindow.cpp	Thu Sep 15 14:51:39 2011 +0100
+++ b/src/mainwindow.cpp	Mon Oct 17 16:25:02 2011 +0100
@@ -2244,6 +2244,7 @@
         break;
 
     case ACT_RESOLVE_LIST:
+        // This happens on every update, after the stat (above)
         if (output != "") {
             // Remove lines beginning with R (they are resolved,
             // and the file stat parser treats R as removed)
@@ -2685,6 +2686,8 @@
     }
     settings.endGroup();
 
+    m_hgTabs->setHaveMerge(m_currentParents.size() == 2);
+
     m_hgRefreshAct->setEnabled(m_localRepoActionsEnabled);
     m_hgFolderDiffAct->setEnabled(m_localRepoActionsEnabled && haveDiff);
     m_hgRevertAct->setEnabled(m_localRepoActionsEnabled);
@@ -2768,7 +2771,7 @@
         haveMerge = true;
         m_justMerged = true;
     }
-        
+
     m_hgIncomingAct->setEnabled(m_remoteRepoActionsEnabled);
     m_hgPullAct->setEnabled(m_remoteRepoActionsEnabled);
     // permit push even if no remote yet; we'll ask for one