comparison hgtabwidget.cpp @ 237:c9a7e4ec2f78

* Try to do the right thing when completely reverting a merge (forget that the merge took place) * When trying to clone from remote repo to existing local dir, offer to create a subdir instead * Tidy up clone-successful notification * Add a note to commit and revert confirmation dialogs to tell user if they are committing/reverting only a subset of available files
author Chris Cannam
date Mon, 10 Jan 2011 12:44:03 +0000
parents e67bd8abc3e3
children 8fd71f570884
comparison
equal deleted inserted replaced
236:960b782f0a64 237:c9a7e4ec2f78
97 m_historyWidget->update(); 97 m_historyWidget->update();
98 } 98 }
99 99
100 bool HgTabWidget::canDiff() const 100 bool HgTabWidget::canDiff() const
101 { 101 {
102 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; 102 return canRevert();
103 return m_fileStatusWidget->haveChangesToCommit() ||
104 !m_fileStatusWidget->getAllUnresolvedFiles().empty();
105 } 103 }
106 104
107 bool HgTabWidget::canCommit() const 105 bool HgTabWidget::canCommit() const
108 { 106 {
109 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; 107 if (!m_fileStatusWidget->haveChangesToCommit()) return false;
110 return m_fileStatusWidget->haveChangesToCommit() && 108 if (!m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
111 m_fileStatusWidget->getAllUnresolvedFiles().empty(); 109
110 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
111 if (addable.empty()) return true;
112
113 QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles();
114
115 // "Removed" files are both committable and addable; don't return
116 // a false negative if the selection only contains these
117 if (committable == addable) return true;
118 return false;
112 } 119 }
113 120
114 bool HgTabWidget::canRevert() const 121 bool HgTabWidget::canRevert() const
115 { 122 {
116 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; 123 // Not the same as canCommit() -- we can revert (and diff)
117 return m_fileStatusWidget->haveChangesToCommit() || 124 // unresolved files, but we can't commit them
118 !m_fileStatusWidget->getAllUnresolvedFiles().empty(); 125 if (!m_fileStatusWidget->haveChangesToCommit() &&
126 m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false;
127
128 // The rest of this logic is as in canCommit though
129
130 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
131 if (addable.empty()) return true;
132
133 QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles();
134 if (committable == addable) return true;
135 return false;
119 } 136 }
120 137
121 bool HgTabWidget::canAdd() const 138 bool HgTabWidget::canAdd() const
122 { 139 {
123 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles(); 140 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles();
125 142
126 QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles(); 143 QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles();
127 if (!removable.empty()) return false; 144 if (!removable.empty()) return false;
128 145
129 QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles(); 146 QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles();
147
130 // "Removed" files are both committable and addable; don't return 148 // "Removed" files are both committable and addable; don't return
131 // a false positive if the selection only contains these 149 // a false negative if the selection only contains these
132 if (committable == addable || committable.empty()) return true; 150 if (committable == addable || committable.empty()) return true;
133 return false; 151 return false;
134 } 152 }
135 153
136 bool HgTabWidget::canRemove() const 154 bool HgTabWidget::canRemove() const