comparison 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
comparison
equal deleted inserted replaced
504:d972f0cd61b3 505:1c05e7576ea5
26 26
27 #include <iostream> 27 #include <iostream>
28 28
29 HgTabWidget::HgTabWidget(QWidget *parent, 29 HgTabWidget::HgTabWidget(QWidget *parent,
30 QString workFolderPath) : 30 QString workFolderPath) :
31 QTabWidget(parent) 31 QTabWidget(parent),
32 m_haveMerge(false)
32 { 33 {
33 // Work tab 34 // Work tab
34 m_fileStatusWidget = new FileStatusWidget; 35 m_fileStatusWidget = new FileStatusWidget;
35 m_fileStatusWidget->setLocalPath(workFolderPath); 36 m_fileStatusWidget->setLocalPath(workFolderPath);
36 37
130 m_fileStatusWidget->clearSelections(); 131 m_fileStatusWidget->clearSelections();
131 } 132 }
132 133
133 void HgTabWidget::setCurrent(QStringList ids, QString branch) 134 void HgTabWidget::setCurrent(QStringList ids, QString branch)
134 { 135 {
135 bool showUncommitted = haveChangesToCommit(); 136 m_historyWidget->setCurrent(ids, branch, haveChangesToCommit());
136 m_historyWidget->setCurrent(ids, branch, showUncommitted);
137 } 137 }
138 138
139 void HgTabWidget::updateFileStates() 139 void HgTabWidget::updateFileStates()
140 { 140 {
141 m_fileStatusWidget->updateWidgets(); 141 m_fileStatusWidget->updateWidgets();
151 return canRevert(); 151 return canRevert();
152 } 152 }
153 153
154 bool HgTabWidget::canCommit() const 154 bool HgTabWidget::canCommit() const
155 { 155 {
156 if (!m_fileStatusWidget->haveChangesToCommit()) return false; 156 if (!haveChangesToCommit()) return false;
157 if (!m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false; 157 if (!getAllUnresolvedFiles().empty()) return false;
158 return true; 158 return true;
159 } 159 }
160 160
161 bool HgTabWidget::canRevert() const 161 bool HgTabWidget::canRevert() const
162 { 162 {
163 // Not the same as canCommit() -- we can revert (and diff) 163 // Not the same as canCommit() -- we can revert (and diff)
164 // unresolved files, but we can't commit them 164 // unresolved files, but we can't commit them
165 if (!m_fileStatusWidget->haveChangesToCommit() && 165 if (!haveChangesToCommit() &&
166 m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false; 166 getAllUnresolvedFiles().empty()) return false;
167 return true; 167 return true;
168 } 168 }
169 169
170 bool HgTabWidget::canAdd() const 170 bool HgTabWidget::canAdd() const
171 { 171 {
172 // Permit this only when work tab is visible 172 // Permit this only when work tab is visible
173 if (currentIndex() != 0) return false; 173 if (currentIndex() != 0) return false;
174 174
175 QStringList addable = m_fileStatusWidget->getSelectedAddableFiles(); 175 QStringList addable = getSelectedAddableFiles();
176 if (addable.empty()) return false; 176 if (addable.empty()) return false;
177 177
178 QStringList removable = m_fileStatusWidget->getSelectedRemovableFiles(); 178 QStringList removable = getSelectedRemovableFiles();
179 if (!removable.empty()) return false; 179 if (!removable.empty()) return false;
180 180
181 return true; 181 return true;
182 } 182 }
183 183
184 bool HgTabWidget::canRemove() const 184 bool HgTabWidget::canRemove() const
185 { 185 {
186 // Permit this only when work tab is visible 186 // Permit this only when work tab is visible
187 if (currentIndex() != 0) return false; 187 if (currentIndex() != 0) return false;
188 188
189 if (m_fileStatusWidget->getSelectedRemovableFiles().empty()) return false; 189 if (getSelectedRemovableFiles().empty()) return false;
190 if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; 190 if (!getSelectedAddableFiles().empty()) return false;
191 return true; 191 return true;
192 } 192 }
193 193
194 bool HgTabWidget::canResolve() const 194 bool HgTabWidget::canResolve() const
195 { 195 {
196 return !m_fileStatusWidget->getAllUnresolvedFiles().empty(); 196 return !getAllUnresolvedFiles().empty();
197 } 197 }
198 198
199 bool HgTabWidget::canIgnore() const 199 bool HgTabWidget::canIgnore() const
200 { 200 {
201 return canAdd(); 201 return canAdd();
202 } 202 }
203 203
204 bool HgTabWidget::haveChangesToCommit() const 204 bool HgTabWidget::haveChangesToCommit() const
205 { 205 {
206 return m_fileStatusWidget->haveChangesToCommit(); 206 return m_haveMerge || m_fileStatusWidget->haveChangesToCommit();
207 } 207 }
208 208
209 QStringList HgTabWidget::getAllCommittableFiles() const 209 QStringList HgTabWidget::getAllCommittableFiles() const
210 { 210 {
211 return m_fileStatusWidget->getAllCommittableFiles(); 211 return m_fileStatusWidget->getAllCommittableFiles();
233 233
234 void HgTabWidget::updateWorkFolderFileList(QString fileList) 234 void HgTabWidget::updateWorkFolderFileList(QString fileList)
235 { 235 {
236 m_fileStates.parseStates(fileList); 236 m_fileStates.parseStates(fileList);
237 m_fileStatusWidget->setFileStates(m_fileStates); 237 m_fileStatusWidget->setFileStates(m_fileStates);
238 }
239
240 void HgTabWidget::setHaveMerge(bool haveMerge)
241 {
242 if (m_haveMerge != haveMerge) {
243 m_haveMerge = haveMerge;
244 m_historyWidget->setShowUncommitted(haveChangesToCommit());
245 updateHistory();
246 }
238 } 247 }
239 248
240 void HgTabWidget::setNewLog(QString hgLogList) 249 void HgTabWidget::setNewLog(QString hgLogList)
241 { 250 {
242 m_historyWidget->parseNewLog(hgLogList); 251 m_historyWidget->parseNewLog(hgLogList);