Mercurial > hg > easyhg
diff 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 |
line wrap: on
line diff
--- a/hgtabwidget.cpp Sun Jan 09 10:08:42 2011 +0000 +++ b/hgtabwidget.cpp Mon Jan 10 12:44:03 2011 +0000 @@ -99,23 +99,40 @@ bool HgTabWidget::canDiff() const { - if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; - return m_fileStatusWidget->haveChangesToCommit() || - !m_fileStatusWidget->getAllUnresolvedFiles().empty(); + return canRevert(); } bool HgTabWidget::canCommit() const { - if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; - return m_fileStatusWidget->haveChangesToCommit() && - m_fileStatusWidget->getAllUnresolvedFiles().empty(); + if (!m_fileStatusWidget->haveChangesToCommit()) return false; + if (!m_fileStatusWidget->getAllUnresolvedFiles().empty()) return false; + + QStringList addable = m_fileStatusWidget->getSelectedAddableFiles(); + if (addable.empty()) return true; + + QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles(); + + // "Removed" files are both committable and addable; don't return + // a false negative if the selection only contains these + if (committable == addable) return true; + return false; } bool HgTabWidget::canRevert() const { - if (!m_fileStatusWidget->getSelectedAddableFiles().empty()) return false; - return m_fileStatusWidget->haveChangesToCommit() || - !m_fileStatusWidget->getAllUnresolvedFiles().empty(); + // 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; + + // The rest of this logic is as in canCommit though + + QStringList addable = m_fileStatusWidget->getSelectedAddableFiles(); + if (addable.empty()) return true; + + QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles(); + if (committable == addable) return true; + return false; } bool HgTabWidget::canAdd() const @@ -127,8 +144,9 @@ if (!removable.empty()) return false; QStringList committable = m_fileStatusWidget->getSelectedCommittableFiles(); + // "Removed" files are both committable and addable; don't return - // a false positive if the selection only contains these + // a false negative if the selection only contains these if (committable == addable || committable.empty()) return true; return false; }