grandmas-svn-commit Mailing List for Grandma's SVN (Page 2)
Brought to you by:
matthiasmiller
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(7) |
Jun
|
Jul
(3) |
Aug
(15) |
Sep
(8) |
Oct
(36) |
Nov
(26) |
Dec
(51) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(18) |
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mat...@us...> - 2006-12-22 20:01:27
|
Revision: 142 http://svn.sourceforge.net/grandmas-svn/?rev=142&view=rev Author: matthiasmiller Date: 2006-12-22 12:01:27 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Error conditions were not correctly being displayed. Allow the Revision object to be sent via the signal/slot mechanism (for real this time) and refresh the modifications model when a fetch fails. Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/include/svn/revision.h trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/commit_summary_thread.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-12-22 19:54:52 UTC (rev 141) +++ trunk/include/dialogs/modificationsmodel.h 2006-12-22 20:01:27 UTC (rev 142) @@ -61,6 +61,7 @@ private slots: void afterCommitSummaryChanged(Revision rev); + void fetchFailed(Revision startRevision, Revision endRevision, QString error); private: void refresh(); Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-12-22 19:54:52 UTC (rev 141) +++ trunk/include/svn/revision.h 2006-12-22 20:01:27 UTC (rev 142) @@ -22,7 +22,6 @@ #define _REVISION_H_ #include <Qt> -#include <QMetaType> #include <svn_wc.h> @@ -71,6 +70,5 @@ Type mType; int mCommittedRevision; }; -Q_DECLARE_METATYPE(Revision); #endif Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 19:54:52 UTC (rev 141) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 20:01:27 UTC (rev 142) @@ -43,6 +43,8 @@ mpCommitSummaryCache = pCommitSummaryCache; connect(mpCommitSummaryCache, SIGNAL(afterCommitSummaryChanged(Revision)), this, SLOT(afterCommitSummaryChanged(Revision))); + connect(mpCommitSummaryCache, SIGNAL(fetchFailed(Revision,Revision,QString)), + this, SLOT(fetchFailed(Revision,Revision,QString))); mShowUnversionedMods = true; refresh(); @@ -58,6 +60,11 @@ refresh(); } +void ModificationsModel::fetchFailed(Revision startRevision, Revision endRevision, QString error) +{ + refresh(); +} + void ModificationsModel::refresh() { if (mRevision.hasValue()) @@ -79,7 +86,7 @@ } else { - mError = QString(); + mError = QString(); mAllModifications.clear(); reset(); } Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2006-12-22 19:54:52 UTC (rev 141) +++ trunk/src/svn/commit_summary_thread.cpp 2006-12-22 20:01:27 UTC (rev 142) @@ -61,6 +61,7 @@ } else { + qRegisterMetaType<Revision>("Revision"); emit failed(fullRepoPath, startRevision, endRevision, error); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-12-22 19:54:53
|
Revision: 141 http://svn.sourceforge.net/grandmas-svn/?rev=141&view=rev Author: highjinx Date: 2006-12-22 11:54:52 -0800 (Fri, 22 Dec 2006) Log Message: ----------- * Changed the commit summary fetcher to return modifications without a leading slash -- this is consistent with the official svn client * Fixed gcc compile error in commit_summary_sort.cpp * Fixed incorrect parameter name in getRepoUrlWithPath Modified Paths: -------------- trunk/include/svn/helpers.h trunk/include/svn/operation.h trunk/src/commit_summary_sort.cpp trunk/src/svn/commit_summary.cpp trunk/src/svn/helpers.cpp Modified: trunk/include/svn/helpers.h =================================================================== --- trunk/include/svn/helpers.h 2006-12-22 19:34:43 UTC (rev 140) +++ trunk/include/svn/helpers.h 2006-12-22 19:54:52 UTC (rev 141) @@ -32,4 +32,5 @@ QString formatSvnErrorMessage(svn_error_t* pError); bool removePrefixNoCase(QString& rString, QString prefix); + bool addSuffixUnlessExists(QString& rString, QString suffix); }; Modified: trunk/include/svn/operation.h =================================================================== --- trunk/include/svn/operation.h 2006-12-22 19:34:43 UTC (rev 140) +++ trunk/include/svn/operation.h 2006-12-22 19:54:52 UTC (rev 141) @@ -31,5 +31,5 @@ bool initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& rError); bool getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); - bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); + bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rFullPath, QString fullRepoPath, QString& rError); }; Modified: trunk/src/commit_summary_sort.cpp =================================================================== --- trunk/src/commit_summary_sort.cpp 2006-12-22 19:34:43 UTC (rev 140) +++ trunk/src/commit_summary_sort.cpp 2006-12-22 19:54:52 UTC (rev 141) @@ -68,12 +68,12 @@ class CommitSummaryRevisionLessThan { public: - inline bool CommitSummaryRevisionLessThan::operator()(const Svn::CommitSummary& rLeft, const Svn::CommitSummary& rRight) const + inline bool operator()(const Svn::CommitSummary& rLeft, const Svn::CommitSummary& rRight) const { return isRevisionLessThan(rRight.getRevision(), rLeft.getRevision()); } - inline bool CommitSummaryRevisionLessThan::operator()(const Svn::CommitSummary& rLeft, const Revision& rRight) const + inline bool operator()(const Svn::CommitSummary& rLeft, const Revision& rRight) const { return isRevisionLessThan(rRight, rLeft.getRevision()); } Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-12-22 19:34:43 UTC (rev 140) +++ trunk/src/svn/commit_summary.cpp 2006-12-22 19:54:52 UTC (rev 141) @@ -47,7 +47,8 @@ { if (!Operation::getRepoCheckoutUrl(rContext, ctx, mRepoUrl, fullCanonPath, rError)) return false; - + addSuffixUnlessExists(mRepoUrl, "/"); + svn_opt_revision_t startRev = startRevision.getSvnRevision(); svn_opt_revision_t endRev = endRevision.getSvnRevision(); apr_array_header_t *array = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); @@ -66,8 +67,10 @@ else { mWcPath = fullCanonPath; + addSuffixUnlessExists(mWcPath, "/"); if (!Operation::getRepoUrlWithPath(rContext, ctx, mRepoUrl, fullCanonPath, rError)) return false; + addSuffixUnlessExists(mRepoUrl, "/"); if (mSummaries.size() == 0) { Modified: trunk/src/svn/helpers.cpp =================================================================== --- trunk/src/svn/helpers.cpp 2006-12-22 19:34:43 UTC (rev 140) +++ trunk/src/svn/helpers.cpp 2006-12-22 19:54:52 UTC (rev 141) @@ -67,3 +67,13 @@ return false; } +bool Svn::addSuffixUnlessExists(QString& rString, QString suffix) +{ + if (!rString.endsWith(suffix)) + { + rString += suffix; + return true; + } + return false; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 19:34:43
|
Revision: 140 http://svn.sourceforge.net/grandmas-svn/?rev=140&view=rev Author: matthiasmiller Date: 2006-12-22 11:34:43 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Allow revisions to be sent via the signal/slot mechanism. (This prevented error messages from being displayed when items could not be loaded.) Modified Paths: -------------- trunk/include/svn/revision.h Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-12-22 19:23:50 UTC (rev 139) +++ trunk/include/svn/revision.h 2006-12-22 19:34:43 UTC (rev 140) @@ -22,6 +22,7 @@ #define _REVISION_H_ #include <Qt> +#include <QMetaType> #include <svn_wc.h> @@ -70,5 +71,6 @@ Type mType; int mCommittedRevision; }; +Q_DECLARE_METATYPE(Revision); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 19:23:50
|
Revision: 139 http://svn.sourceforge.net/grandmas-svn/?rev=139&view=rev Author: matthiasmiller Date: 2006-12-22 11:23:50 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Start using the CommitSummaryCache in the modifications and revisions models. This prevents a lot of duplication of information between the main window, the modifications model, and the revisions model. This change also allows the correct revision to remain selected when new commit summaries are downloaded after an update or commit. Modified Paths: -------------- trunk/include/dialogs/commit.h trunk/include/dialogs/mainwindow.h trunk/include/dialogs/modificationsmodel.h trunk/include/dialogs/revisionsmodel.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/dialogs/revisionsmodel.cpp Modified: trunk/include/dialogs/commit.h =================================================================== --- trunk/include/dialogs/commit.h 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/include/dialogs/commit.h 2006-12-22 19:23:50 UTC (rev 139) @@ -25,6 +25,7 @@ #include <Qt> #include <QDialog> +class CommitSummaryCache; class ModificationsModel; class SvnOperationContext; class Ui_CommitDialog; @@ -49,6 +50,8 @@ Ui_CommitDialog* mpUi; + CommitSummaryCache* mpCommitSummaryCache; + SvnOperationContext* mpContext; QString mCommitMessage; QString mPath; Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/include/dialogs/mainwindow.h 2006-12-22 19:23:50 UTC (rev 139) @@ -25,7 +25,7 @@ #include "svn/commit_summary.h" #include "svn/revision.h" -class CommitSummaryFetcherThread; +class CommitSummaryCache; class ModificationsModel; class RevisionsModel; class SvnOperationContext; @@ -56,25 +56,21 @@ void add(); void move(); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); - void fetchedCommittedRevisions(QString fullRepoPath, QList<Svn::CommitSummary> summaries); - void fetchCommittedRevisionsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); - void fetchedModifications(QString fullRepoPath, QList<Svn::CommitSummary> summaries); - void fetchModificationsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); + void afterCommitSummaryAdded(Revision rev); private: - void reloadCommitSummaries(); - void reloadModifications(); + void reloadCommittedSummaries(); + void reloadUncommittedSummary(); + bool getSelectedCommitSummary(Svn::CommitSummary& rSummary); QList<int> getSelectedRows(QAbstractItemView* pView); QList<Modification> getSelectedModifications(); Ui_MainWindow* mpUi; SvnOperationContext* mpContext; QString mPath; + CommitSummaryCache* mpCommitSummaryCache; ModificationsModel* mpModificationsModel; - Svn::CommitSummary mDisplayedCommitSummary; RevisionsModel* mpRevisionsModel; - CommitSummaryFetcherThread* mpCommitSummaryThread; - CommitSummaryFetcherThread* mpModificationsThread; }; #endif Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/include/dialogs/modificationsmodel.h 2006-12-22 19:23:50 UTC (rev 139) @@ -17,23 +17,27 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + #include <QAbstractListModel> +#include "nullable.h" +#include "svn/revision.h" +class CommitSummaryCache; class Modification; -class Revision; class SvnOperationContext; class ModificationsModel : public QAbstractListModel { + Q_OBJECT public: - ModificationsModel(); + ModificationsModel(CommitSummaryCache* pCommitSummaryCache); virtual ~ModificationsModel(); - void showError(QString error); - void showModifications(QList<Modification> modifications); + void setRevision(Revision revision); + void clearRevision(); bool getModificationForRow(int row, Modification& rModification) const; - + virtual int columnCount(const QModelIndex &rcParent = QModelIndex()) const; virtual int rowCount(const QModelIndex& rcParent = QModelIndex()) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; @@ -41,21 +45,34 @@ virtual bool setData(const QModelIndex& rcIndex, const QVariant& rcValue, int role); virtual Qt::ItemFlags flags(const QModelIndex& rcIndex) const; - + + void setShowUnversionedMods(bool showUnversionedMods); void setAllowSelections(bool allowSelections); QList<Modification> getSelectedModifications() const; bool hasCheckboxColumn() const; int getCheckboxColumn() const; - + private: bool isErrorColumn(int col) const; bool isCheckboxColumn(int col) const; bool isTypeColumn(int col) const; bool isPathColumn(int col) const; +private slots: + void afterCommitSummaryChanged(Revision rev); + +private: + void refresh(); + void setModifications(QList<Modification> modifications); + + CommitSummaryCache* mpCommitSummaryCache; + + Nullable<Revision> mRevision; + QString mError; QList<Modification> mAllModifications; QList<QString> mDeclinedPaths; + bool mShowUnversionedMods; bool mAllowSelections; }; Modified: trunk/include/dialogs/revisionsmodel.h =================================================================== --- trunk/include/dialogs/revisionsmodel.h 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/include/dialogs/revisionsmodel.h 2006-12-22 19:23:50 UTC (rev 139) @@ -17,24 +17,23 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ + +#include "svn/revision.h" #include <QAbstractListModel> +class CommitSummaryCache; namespace Svn { class CommitSummary; }; -class Revision; class RevisionsModel : public QAbstractListModel { + Q_OBJECT public: - RevisionsModel(); + RevisionsModel(CommitSummaryCache* pCommitSummaryCache); virtual ~RevisionsModel(); - void showError(QString error); - void showUncommittedRevision(Svn::CommitSummary uncommittedRevision); - void showCommittedRevisions(QList<Svn::CommitSummary> committedRevisions); - bool getCommitSummaryForRow(int row, Svn::CommitSummary& rSummary) const; QModelIndex getUncommittedRevision() const; @@ -43,11 +42,17 @@ virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex& rcIndex, int role = Qt::DisplayRole) const; +private slots: + void beforeCommitSummaryAdded(Revision rev); + void afterCommitSummaryAdded(Revision rev); + void afterCommitSummaryChanged(Revision rev); + void fetchFailed(Revision startRevision, Revision endRevision, QString error); + private: static QString getRevisionAsString(Revision rev); static QString getDateTimeAsString(QDateTime dateTime); + CommitSummaryCache* mpCommitSummaryCache; QString mError; - QList<Svn::CommitSummary> mUncommittedSummaries, mCommittedSummaries; }; Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/src/dialogs/commit.cpp 2006-12-22 19:23:50 UTC (rev 139) @@ -19,6 +19,8 @@ ***************************************************************************/ #include "dialogs/commit.h" + +#include "commit_summary_cache.h" #include "dialogs/modificationsmodel.h" #include "dialogs/progress.h" #include "dialogs/util.h" @@ -38,13 +40,16 @@ mCommitMessage = commitMessage; mPath = path; + mpCommitSummaryCache = new CommitSummaryCache(mPath); + mpUi = new Ui_CommitDialog(); mpUi->setupUi(this); #if QT_VERSION >= 0x040200 mpUi->changesTreeView->setAllColumnsShowFocus(true); #endif - mpModificationsModel = new ModificationsModel(); + mpModificationsModel = new ModificationsModel(mpCommitSummaryCache); + mpModificationsModel->setShowUnversionedMods(false); mpModificationsModel->setAllowSelections(true); mpUi->changesTreeView->setModel(mpModificationsModel); mpUi->changesTreeView->header()->setMovable(false); @@ -53,6 +58,7 @@ connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); reload(); + mpModificationsModel->setRevision(Revision::uncommitted()); #ifdef Q_WS_MAC exchangeWidgets(mpUi->hboxLayout, mpUi->commitButton, mpUi->cancelButton); @@ -67,6 +73,9 @@ delete mpUi; mpUi = NULL; + + delete mpCommitSummaryCache; + mpCommitSummaryCache = NULL; } void CommitDialog::changeEvent(QEvent* pEvent) @@ -75,7 +84,7 @@ if (pEvent->type() == QEvent::ActivationChange && isActiveWindow()) { - if (mpModificationsModel) + if (mpCommitSummaryCache) reload(); } } @@ -121,25 +130,8 @@ void CommitDialog::reload() { - Svn::CommitSummary summary; - Svn::CommitSummaryFetcher fetcher; - QString error; - if (fetcher.fetchSummary(*mpContext, mPath, Revision::uncommitted(), true, summary, error)) - { - // remove unversioned mods - QList<Modification> unversionedMods = summary.modifications(); - QMutableListIterator<Modification> i(unversionedMods); - while (i.hasNext()) - { - if (!Modification::isVersionedType(i.next().getType())) - i.remove(); - } + mpCommitSummaryCache->fetchSummariesSync(Revision::uncommitted(), Revision::uncommitted()); - mpModificationsModel->showModifications(summary.modifications()); - } - else - mpModificationsModel->showError(error); - if (mpModificationsModel->hasCheckboxColumn()) mpUi->changesTreeView->resizeColumnToContents(mpModificationsModel->getCheckboxColumn()); } Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-22 19:23:50 UTC (rev 139) @@ -20,6 +20,8 @@ #include "dialogs/mainwindow.h" + +#include "commit_summary_cache.h" #include "dialogs/authentication.h" #include "dialogs/commit.h" #include "dialogs/modificationsmodel.h" @@ -29,7 +31,6 @@ #include "diff.h" #include "svn/add.h" #include "svn/commit_summary.h" -#include "svn/commit_summary_thread.h" #include "svn/file_access.h" #include "svn/revert.h" #include "svn/revision.h" @@ -46,18 +47,10 @@ mpContext = pContext; mPath = path; - mpCommitSummaryThread = new CommitSummaryFetcherThread; - connect(mpCommitSummaryThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), - this, SLOT(fetchedCommittedRevisions(QString,QList<Svn::CommitSummary>))); - connect(mpCommitSummaryThread, SIGNAL(failed(QString,Revision,Revision,QString)), - this, SLOT(fetchCommittedRevisionsFailed(QString,Revision,Revision,QString))); + mpCommitSummaryCache = new CommitSummaryCache(mPath); + connect(mpCommitSummaryCache, SIGNAL(afterCommitSummaryAdded(Revision)), + this, SLOT(afterCommitSummaryAdded(Revision))); - mpModificationsThread = new CommitSummaryFetcherThread; - connect(mpModificationsThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), this, - SLOT(fetchedModifications(QString,QList<Svn::CommitSummary>))); - connect(mpModificationsThread, SIGNAL(failed(QString,Revision,Revision,QString)), - this, SLOT(fetchModificationsFailed(QString,Revision,Revision,QString))); - mpUi = new Ui_MainWindow(); mpUi->setupUi(this); #if QT_VERSION >= 0x040200 @@ -79,11 +72,11 @@ connect(mpUi->addButton, SIGNAL(clicked()), this, SLOT(add())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); - mpModificationsModel = new ModificationsModel(); + mpModificationsModel = new ModificationsModel(mpCommitSummaryCache); mpUi->changesTreeView->setModel(mpModificationsModel); mpUi->changesTreeView->header()->setMovable(false); - mpRevisionsModel = new RevisionsModel(); + mpRevisionsModel = new RevisionsModel(mpCommitSummaryCache); mpUi->revisionsTreeView->setModel(mpRevisionsModel); mpUi->revisionsTreeView->header()->setMovable(false); @@ -93,7 +86,9 @@ setWindowTitle(tr("%1 - %2").arg(QDir::convertSeparators(path)).arg(windowTitle())); - reloadCommitSummaries(); + // wait to load until the models have been instantiated + reloadUncommittedSummary(); + reloadCommittedSummaries(); } MainWindow::~MainWindow() @@ -111,14 +106,9 @@ delete mpUi; mpUi = NULL; - mpModificationsThread->stop(); - delete mpModificationsThread; - mpModificationsThread = NULL; + delete mpCommitSummaryCache; + mpCommitSummaryCache = NULL; - mpCommitSummaryThread->stop(); - delete mpCommitSummaryThread; - mpCommitSummaryThread = NULL; - mpContext = NULL; } @@ -129,8 +119,9 @@ if (pEvent->type() == QEvent::ActivationChange && isActiveWindow()) { // Refresh the modifications if it doesn't require server access. - if (mpModificationsModel && mDisplayedCommitSummary.getRevision().getType() == Revision::Uncommitted) - reloadModifications(); + Svn::CommitSummary summary; + if (getSelectedCommitSummary(summary) && summary.getRevision().getType() == Revision::Uncommitted) + reloadUncommittedSummary(); } } @@ -148,18 +139,22 @@ if (!Svn::update(*mpContext, mPath, Revision::head(), error)) QMessageBox::critical(this, "", error); mpContext->setStatus(NULL); - - reloadCommitSummaries(); + + reloadUncommittedSummary(); + reloadCommittedSummaries(); } void MainWindow::commit() { CommitDialog dlg(mpContext, mpUi->logEdit->toPlainText(), mPath, this); dlg.exec(); - reloadModifications(); + + // the commit dialog may have updated but not committed + reloadUncommittedSummary(); + reloadCommittedSummaries(); + if (dlg.result() == QDialog::Accepted) { - reloadCommitSummaries(); mpUi->logEdit->setReadOnly(false); mpUi->logEdit->document()->setPlainText(""); } @@ -213,7 +208,7 @@ return; } } - reloadModifications(); + reloadUncommittedSummary(); } void MainWindow::add() @@ -229,7 +224,7 @@ return; } } - reloadModifications(); + reloadUncommittedSummary(); } void MainWindow::move() @@ -238,41 +233,14 @@ dlg.exec(); } -void MainWindow::reloadCommitSummaries() +void MainWindow::reloadCommittedSummaries() { - // load uncommitted revisions - Svn::CommitSummaryFetcher fetcher; - Svn::CommitSummary uncommittedSummary; - QString error; - if (fetcher.fetchSummary(*mpContext, mPath, Revision::uncommitted(), false, uncommittedSummary, error)) - { - mpRevisionsModel->showUncommittedRevision(uncommittedSummary); - - // select the uncommitted revision if nothing is selected yet - QItemSelectionModel* pSelection = mpUi->revisionsTreeView->selectionModel(); - if (pSelection->selectedIndexes().count() == 0) - { - QModelIndex index = mpRevisionsModel->getUncommittedRevision(); - pSelection->select(index, QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Current | QItemSelectionModel::Rows); - } - } - else - { - mpRevisionsModel->showError(error); - } - - // load committed revisions - mpCommitSummaryThread->fetchSummariesAsync(mPath, Revision::base(), Revision::committed(0)); + mpCommitSummaryCache->fetchSummariesAsync(Revision::base(), Revision::committed(0)); } -void MainWindow::reloadModifications() +void MainWindow::reloadUncommittedSummary() { - // Update immediately for all revisions, then post a background request to refresh uncommitted modifications. - mpModificationsModel->showModifications(mDisplayedCommitSummary.modifications()); - - Revision rev = mDisplayedCommitSummary.getRevision(); - if (rev.getType() == Revision::Uncommitted) - mpModificationsThread->fetchSummariesAsync(mPath, rev, rev); + mpCommitSummaryCache->fetchSummariesAsync(Revision::uncommitted(), Revision::uncommitted()); } void MainWindow::revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected) @@ -280,62 +248,50 @@ Q_UNUSED(rcSelected); Q_UNUSED(rcDeselected); - QList<int> rows = getSelectedRows(mpUi->revisionsTreeView); - if (rows.count() == 0) - return; - GSVN_ASSERT(rows.count() == 1); - Svn::CommitSummary commitSummary; - if (mpRevisionsModel->getCommitSummaryForRow(rows.at(0), commitSummary)) + if (getSelectedCommitSummary(commitSummary)) { - mDisplayedCommitSummary = commitSummary; + mpUi->logEdit->setReadOnly(commitSummary.getRevision().getType() != Revision::Uncommitted); + mpUi->logEdit->document()->setPlainText(commitSummary.getCommitLogMessage()); - mpUi->logEdit->setReadOnly(mDisplayedCommitSummary.getRevision().getType() != Revision::Uncommitted); - mpUi->logEdit->document()->setPlainText(mDisplayedCommitSummary.getCommitLogMessage()); + mpModificationsModel->setRevision(commitSummary.getRevision()); - reloadModifications(); + if (commitSummary.getRevision().getType() == Revision::Uncommitted) + reloadUncommittedSummary(); } + else + mpModificationsModel->clearRevision(); } -void MainWindow::fetchedCommittedRevisions(QString fullRepoPath, QList<Svn::CommitSummary> summaries) +void MainWindow::afterCommitSummaryAdded(Revision rev) { - Q_UNUSED(fullRepoPath); - mpRevisionsModel->showCommittedRevisions(summaries); + // select the uncommitted revision if nothing is selected yet + QItemSelectionModel* pSelection = mpUi->revisionsTreeView->selectionModel(); + if (pSelection->selectedIndexes().count() == 0) + { + QModelIndex index = mpRevisionsModel->getUncommittedRevision(); + if (index.isValid()) + pSelection->select(index, QItemSelectionModel::Clear | QItemSelectionModel::Select | QItemSelectionModel::Current | QItemSelectionModel::Rows); + } } -void MainWindow::fetchCommittedRevisionsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) +bool MainWindow::getSelectedCommitSummary(Svn::CommitSummary& rSummary) { - Q_UNUSED(fullRepoPath); - Q_UNUSED(startRevision); - Q_UNUSED(endRevision); - qDebug(tr("Unable to fetch commit summaries: %1").arg(error).toAscii()); -} + rSummary = Svn::CommitSummary(); -void MainWindow::fetchedModifications(QString fullRepoPath, QList<Svn::CommitSummary> summaries) -{ - Q_UNUSED(fullRepoPath); + QList<int> rows = getSelectedRows(mpUi->revisionsTreeView); + if (rows.count() == 0) + return false; + GSVN_ASSERT(rows.count() == 1); - GSVN_ASSERT(summaries.count() == 1); + Svn::CommitSummary commitSummary; + if (!mpRevisionsModel->getCommitSummaryForRow(rows.at(0), commitSummary)) + return false; - // Save the new modifications if showing an uncommitted revision to prevent - // a refresh of stale data when the window receives focus. - if (mDisplayedCommitSummary.getRevision().getType() == Revision::Uncommitted && - summaries.at(0).getRevision().getType() == Revision::Uncommitted) - { - mDisplayedCommitSummary = summaries.at(0); - } - - mpModificationsModel->showModifications(summaries.at(0).modifications()); + rSummary = commitSummary; + return true; } -void MainWindow::fetchModificationsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) -{ - Q_UNUSED(fullRepoPath); - Q_UNUSED(startRevision); - Q_UNUSED(endRevision); - mpModificationsModel->showError(error); -} - QList<int> MainWindow::getSelectedRows(QAbstractItemView* pView) { // determine which rows are selected (remove duplicate rows, since an index is returned for each column) Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 19:23:50 UTC (rev 139) @@ -18,6 +18,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "dialogs/modificationsmodel.h" +#include "commit_summary_cache.h" #include "debug.h" #include "svn/modification.h" #include "svn/revision.h" @@ -37,24 +38,66 @@ } -ModificationsModel::ModificationsModel() : mAllowSelections(false) +ModificationsModel::ModificationsModel(CommitSummaryCache* pCommitSummaryCache) : mAllowSelections(false) { + mpCommitSummaryCache = pCommitSummaryCache; + connect(mpCommitSummaryCache, SIGNAL(afterCommitSummaryChanged(Revision)), + this, SLOT(afterCommitSummaryChanged(Revision))); + mShowUnversionedMods = true; + + refresh(); } ModificationsModel::~ModificationsModel() { } -void ModificationsModel::showError(QString error) +void ModificationsModel::afterCommitSummaryChanged(Revision rev) { - GSVN_ASSERT(!error.isNull()); - mError = error; - mAllModifications.clear(); - reset(); + if (mRevision.hasValue() && mRevision.getValue() == rev) + refresh(); } -void ModificationsModel::showModifications(QList<Modification> modifications) +void ModificationsModel::refresh() { + if (mRevision.hasValue()) + { + QString error; + if (mRevision.getValue().getType() == Revision::Uncommitted && + !mpCommitSummaryCache->didLastFetchSucceed(mRevision.getValue(), error)) + { + GSVN_ASSERT(!error.isNull()); + mError = error; + mAllModifications.clear(); + reset(); + } + else + { + Svn::CommitSummary summary = mpCommitSummaryCache->getCommitSummary(mRevision.getValue()); + setModifications(summary.modifications()); + } + } + else + { + mError = QString(); + mAllModifications.clear(); + reset(); + } +} + +void ModificationsModel::setModifications(QList<Modification> modifications) +{ + if (!mShowUnversionedMods) + { + // remove unversioned mods + QMutableListIterator<Modification> i(modifications); + while (i.hasNext()) + { + if (!Modification::isVersionedType(i.next().getType())) + i.remove(); + } + } + // Sort by file path to provide more consistent display and to better maintain selection. qSort(modifications.begin(), modifications.end(), ModificationPathLessThan()); @@ -131,6 +174,18 @@ GSVN_ASSERT(mAllModifications.size() == modifications.size()); } +void ModificationsModel::setRevision(Revision revision) +{ + mRevision = revision; + refresh(); +} + +void ModificationsModel::clearRevision() +{ + mRevision = Nullable<Revision>(); + refresh(); +} + bool ModificationsModel::getModificationForRow(int row, Modification& rModification) const { if (!mError.isEmpty()) @@ -280,9 +335,16 @@ return flags; } +void ModificationsModel::setShowUnversionedMods(bool showUnversionedMods) +{ + mShowUnversionedMods = showUnversionedMods; + refresh(); +} + void ModificationsModel::setAllowSelections(bool allowSelections) { mAllowSelections = allowSelections; + emit layoutChanged(); } QList<Modification> ModificationsModel::getSelectedModifications() const Modified: trunk/src/dialogs/revisionsmodel.cpp =================================================================== --- trunk/src/dialogs/revisionsmodel.cpp 2006-12-22 19:04:57 UTC (rev 138) +++ trunk/src/dialogs/revisionsmodel.cpp 2006-12-22 19:23:50 UTC (rev 139) @@ -19,41 +19,28 @@ ***************************************************************************/ #include "dialogs/revisionsmodel.h" +#include "commit_summary_cache.h" +#include "commit_summary_sort.h" #include "debug.h" #include "svn/commit_summary.h" -RevisionsModel::RevisionsModel() +RevisionsModel::RevisionsModel(CommitSummaryCache* pCommitSummaryCache) { + mpCommitSummaryCache = pCommitSummaryCache; + connect(mpCommitSummaryCache, SIGNAL(beforeCommitSummaryAdded(Revision)), + this, SLOT(beforeCommitSummaryAdded(Revision))); + connect(mpCommitSummaryCache, SIGNAL(afterCommitSummaryAdded(Revision)), + this, SLOT(afterCommitSummaryAdded(Revision))); + connect(mpCommitSummaryCache, SIGNAL(afterCommitSummaryChanged(Revision)), + this, SLOT(afterCommitSummaryChanged(Revision))); + connect(mpCommitSummaryCache, SIGNAL(fetchFailed(Revision,Revision,QString)), + this, SLOT(fetchFailed(Revision,Revision,QString))); } RevisionsModel::~RevisionsModel() { } -void RevisionsModel::showError(QString error) -{ - GSVN_ASSERT(!error.isNull()); - mError = error; - mUncommittedSummaries.clear(); - mCommittedSummaries.clear(); - emit layoutChanged(); -} - -void RevisionsModel::showUncommittedRevision(Svn::CommitSummary uncommittedRevision) -{ - mError = QString(); - mUncommittedSummaries.clear(); - mUncommittedSummaries.push_back(uncommittedRevision); - emit layoutChanged(); -} - -void RevisionsModel::showCommittedRevisions(QList<Svn::CommitSummary> committedRevisions) -{ - mError = QString(); - mCommittedSummaries = committedRevisions; - emit layoutChanged(); -} - QModelIndex RevisionsModel::getUncommittedRevision() const { Svn::CommitSummary summary; @@ -68,7 +55,7 @@ switch (rev.getType()) { case Revision::Uncommitted: return tr("(uncommitted)"); - case Revision::Committed: return tr("r%1").arg(QString::number(rev.getCommittedRevision())) ; + case Revision::Committed: return tr("r%1").arg(rev.getCommittedRevision()); case Revision::Base: return tr("(base)"); case Revision::Head: return tr("(head)"); default: @@ -108,7 +95,7 @@ if (!mError.isNull()) return 1; - return mUncommittedSummaries.count() + mCommittedSummaries.count(); + return mpCommitSummaryCache->getCommitSummaries().count(); } QVariant RevisionsModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -170,24 +157,53 @@ if (!mError.isNull()) return false; - if (row < 0) - return false; - - // uncommitted revision? - if (row < mUncommittedSummaries.count()) + if (row >= 0 && row < mpCommitSummaryCache->getCommitSummaries().count()) { - rSummary = mUncommittedSummaries.at(row); + rSummary = mpCommitSummaryCache->getCommitSummaries().at(row); return true; } - // committed revision? - row -= mUncommittedSummaries.count(); - GSVN_ASSERT(row >= 0); - if (row < mCommittedSummaries.count()) + return false; +} + +void RevisionsModel::beforeCommitSummaryAdded(Revision rev) +{ + if (!mError.isNull()) { - rSummary = mCommittedSummaries.at(row); - return true; + mError = QString(); + reset(); } - return false; + int index = -1; + if (CommitSummaryFinder::findByRevision(mpCommitSummaryCache->getCommitSummaries(), rev, index)) + GSVN_ASSERT(false); + else + beginInsertRows(QModelIndex(), index, index); } + +void RevisionsModel::afterCommitSummaryAdded(Revision rev) +{ + endInsertRows(); +} + +void RevisionsModel::afterCommitSummaryChanged(Revision rev) +{ + GSVN_ASSERT(mError.isNull()); + + int row = -1; + if (CommitSummaryFinder::findByRevision(mpCommitSummaryCache->getCommitSummaries(), rev, row)) + emit dataChanged(index(row,0), index(row,columnCount())); + else + GSVN_ASSERT(false); +} + +void RevisionsModel::fetchFailed(Revision startRevision, Revision endRevision, QString error) +{ + Q_UNUSED(startRevision); + Q_UNUSED(endRevision); + if (mpCommitSummaryCache->getCommitSummaries().size() == 0) + { + mError = error; + reset(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 19:04:57
|
Revision: 138 http://svn.sourceforge.net/grandmas-svn/?rev=138&view=rev Author: matthiasmiller Date: 2006-12-22 11:04:57 -0800 (Fri, 22 Dec 2006) Log Message: ----------- fetch uncommitted revisions with a separate thread so that modifications can be refreshed even if the request for committed revisions takes a long time Modified Paths: -------------- trunk/include/commit_summary_cache.h trunk/src/commit_summary_cache.cpp Modified: trunk/include/commit_summary_cache.h =================================================================== --- trunk/include/commit_summary_cache.h 2006-12-22 19:02:54 UTC (rev 137) +++ trunk/include/commit_summary_cache.h 2006-12-22 19:04:57 UTC (rev 138) @@ -51,8 +51,13 @@ void fetchCommitSummariesFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); private: + CommitSummaryFetcherThread* createThread(); + void deleteThread(CommitSummaryFetcherThread*& rpThread); + CommitSummaryFetcherThread* chooseThread(Revision startRevision, Revision endRevision); + QString mFullRepoPath; - CommitSummaryFetcherThread* mpThread; + CommitSummaryFetcherThread* mpCommittedThread; + CommitSummaryFetcherThread* mpUncommittedThread; QList<Svn::CommitSummary> mCommitSummaries; struct FetchResult; QList<FetchResult> mFetchResults; Modified: trunk/src/commit_summary_cache.cpp =================================================================== --- trunk/src/commit_summary_cache.cpp 2006-12-22 19:02:54 UTC (rev 137) +++ trunk/src/commit_summary_cache.cpp 2006-12-22 19:04:57 UTC (rev 138) @@ -35,28 +35,26 @@ { mFullRepoPath = fullRepoPath; - mpThread = new CommitSummaryFetcherThread; - connect(mpThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), - this, SLOT(fetchedCommitSummaries(QString,QList<Svn::CommitSummary>))); - connect(mpThread, SIGNAL(failed(QString,Revision,Revision,QString)), - this, SLOT(fetchCommitSummariesFailed(QString,Revision,Revision,QString))); + mpCommittedThread = createThread(); + mpUncommittedThread = createThread(); } CommitSummaryCache::~CommitSummaryCache() { - mpThread->stop(); - delete mpThread; - mpThread = NULL; + deleteThread(mpCommittedThread); + deleteThread(mpUncommittedThread); } void CommitSummaryCache::fetchSummariesSync(Revision startRevision, Revision endRevision) { - return mpThread->fetchSummariesSync(mFullRepoPath, startRevision, endRevision); + CommitSummaryFetcherThread* pThread = chooseThread(startRevision, endRevision); + return pThread->fetchSummariesSync(mFullRepoPath, startRevision, endRevision); } void CommitSummaryCache::fetchSummariesAsync(Revision startRevision, Revision endRevision) { - mpThread->fetchSummariesAsync(mFullRepoPath, startRevision, endRevision); + CommitSummaryFetcherThread* pThread = chooseThread(startRevision, endRevision); + pThread->fetchSummariesAsync(mFullRepoPath, startRevision, endRevision); } QList<Svn::CommitSummary> CommitSummaryCache::getCommitSummaries() const @@ -139,3 +137,30 @@ emit fetchFailed(startRevision, endRevision, error); } + +CommitSummaryFetcherThread* CommitSummaryCache::createThread() +{ + CommitSummaryFetcherThread* pThread = new CommitSummaryFetcherThread; + connect(pThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), + this, SLOT(fetchedCommitSummaries(QString,QList<Svn::CommitSummary>))); + connect(pThread, SIGNAL(failed(QString,Revision,Revision,QString)), + this, SLOT(fetchCommitSummariesFailed(QString,Revision,Revision,QString))); + return pThread; +} + +void CommitSummaryCache::deleteThread(CommitSummaryFetcherThread*& rpThread) +{ + rpThread->stop(); + delete rpThread; + rpThread = NULL; +} + +CommitSummaryFetcherThread* CommitSummaryCache::chooseThread(Revision startRevision, Revision endRevision) +{ + // fetch uncommitted revisions with a separate thread so that they're + // not affected if requests for committed revisions take a long time + if (startRevision.getType() == Revision::Uncommitted && endRevision.getType() == Revision::Uncommitted) + return mpUncommittedThread; + else + return mpCommittedThread; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 19:02:55
|
Revision: 137 http://svn.sourceforge.net/grandmas-svn/?rev=137&view=rev Author: matthiasmiller Date: 2006-12-22 11:02:54 -0800 (Fri, 22 Dec 2006) Log Message: ----------- re-enable Nullable tests Modified Paths: -------------- trunk/tests/nullable_test.h Modified: trunk/tests/nullable_test.h =================================================================== --- trunk/tests/nullable_test.h 2006-12-22 19:00:29 UTC (rev 136) +++ trunk/tests/nullable_test.h 2006-12-22 19:02:54 UTC (rev 137) @@ -23,7 +23,7 @@ class NullableTester : public QObject { Q_OBJECT -private: +private slots: void init() {} void testDefaultConstructor(); void testCopyConstructorValue(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 19:00:29
|
Revision: 136 http://svn.sourceforge.net/grandmas-svn/?rev=136&view=rev Author: matthiasmiller Date: 2006-12-22 11:00:29 -0800 (Fri, 22 Dec 2006) Log Message: ----------- fix deletion of wild pointer in Nullable (unit tests were failing on unix systems) Modified Paths: -------------- trunk/include/nullable.h Modified: trunk/include/nullable.h =================================================================== --- trunk/include/nullable.h 2006-12-22 18:43:05 UTC (rev 135) +++ trunk/include/nullable.h 2006-12-22 19:00:29 UTC (rev 136) @@ -33,6 +33,7 @@ } Nullable(const T& rValue) { + mp = NULL; *this = rValue; } ~Nullable() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-12-22 18:43:06
|
Revision: 135 http://svn.sourceforge.net/grandmas-svn/?rev=135&view=rev Author: highjinx Date: 2006-12-22 10:43:05 -0800 (Fri, 22 Dec 2006) Log Message: ----------- * Refactored the Modifications class * Improved unit tests a little, including a check for no leading slash (which is currently failing) Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/svn/modification.h trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/commit_summary.cpp trunk/tests/nullable_test.h trunk/tests/svn_test.cpp trunk/tests/svn_test.h Added Paths: ----------- trunk/src/svn/modification.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/grandmas_svn.pro 2006-12-22 18:43:05 UTC (rev 135) @@ -244,6 +244,7 @@ src/svn/commit_summary_thread.cpp \ src/svn/file_access.cpp \ src/svn/helpers.cpp \ + src/svn/modification.cpp \ src/svn/operation.cpp \ src/svn/operation_internal.cpp \ src/svn/pool.cpp \ Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/include/svn/modification.h 2006-12-22 18:43:05 UTC (rev 135) @@ -36,61 +36,54 @@ public: enum Type { - Type_TextMod, - Type_Add, - Type_Delete, - Type_PropMod, + Type_FileModification, + Type_Addition, + Type_Deletion, + Type_PropertyModification, // Pseudo-types: types that are not modifications, but need to be displayed - Type_New, // exists, but has not been added + Type_Creation, // exists, but has not been added Type_Missing, - Type_Conflicting, + Type_Conflict, }; + + static Modification fileModification(QString filePath, Revision oldRevision, Revision newRevision); + static Modification addition(QString filePath, Revision revision); + static Modification additionWithHistory(QString filePath, Revision revision, QString historyFilePath, Revision historyRevision); + static Modification deletion(QString filePath, Revision revision); + static Modification propertyModification(QString filePath, Revision oldRevision, Revision newRevision); + // The revision for the following types is always uncommitted + static Modification creation(QString filePath); + static Modification missing(QString filePath); + static Modification conflict(QString filePath); - static bool isVersionedType(Type type) - { - switch (type) - { - case Type_TextMod: - case Type_Add: - case Type_Delete: - case Type_PropMod: - return true; - case Type_New: - case Type_Missing: - case Type_Conflicting: - return false; - default: - return false; - } - } + Type getType() const; + + QString getFilePath() const; - QString getFilePath() const { return mFilePath; } - Type getType() const { return mType; } + Revision getRevision() const; - // Only use for move mods - bool isAddedWithHistory() const - { - Q_ASSERT(mType == Type_Add); - return mHistoryFilePath != ""; - } - QString getHistoryFilePath() const - { - Q_ASSERT(isAddedWithHistory()); - return mHistoryFilePath; - } + // Only use for add mods + bool isAddedWithHistory() const; + QString getHistoryFilePath() const; + Revision getHistoryRevision() const; - Revision getOldRevision() const { return mOldRevision; } - Revision getNewRevision() const { return mNewRevision; } + Revision fileModification_getOldRevision() const; + Revision propertyModification_getOldRevision() const; -private: - friend class Svn::CommitSummaryFetcher; +public: // Helper functions + static bool isVersionedType(Type type); +private: + static Modification fromType(Type type, QString filePath, Revision revision); + Type mType; QString mFilePath; - QString mHistoryFilePath; + Revision mRevision; Revision mOldRevision; - Revision mNewRevision; + + QString mHistoryFilePath; + Revision mHistoryRevision; }; #endif Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-22 18:43:05 UTC (rev 135) @@ -173,14 +173,14 @@ // Generate each side of the diff QString error, leftPath, rightPath; QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); - if (!RepoFileAccess::getDiffFiles(*mpContext, fullFilePath, mod.getOldRevision(), mod.getNewRevision(), leftPath, rightPath, error)) + if (!RepoFileAccess::getDiffFiles(*mpContext, fullFilePath, mod.fileModification_getOldRevision(), mod.getRevision(), leftPath, rightPath, error)) { QMessageBox::critical(this, "", error); return; } // Launch the diff - bool allowMerge = mod.getNewRevision().getType() == Revision::Uncommitted; + bool allowMerge = mod.getRevision().getType() == Revision::Uncommitted; if (!diffFiles(leftPath, rightPath, allowMerge)) { QMessageBox::critical(this, tr("The differences could not be displayed."), tr("The comparison program could not be opened.")); Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-22 18:43:05 UTC (rev 135) @@ -204,13 +204,13 @@ { switch (mod.getType()) { - case Modification::Type_TextMod: return tr("Modified"); - case Modification::Type_Add: return tr("Added"); - case Modification::Type_Delete: return tr("Deleted"); - case Modification::Type_PropMod: return tr("Property Modified"); - case Modification::Type_New: return tr("?"); + case Modification::Type_FileModification: return tr("Modified"); + case Modification::Type_Addition: return tr("Added"); + case Modification::Type_Deletion: return tr("Deleted"); + case Modification::Type_PropertyModification: return tr("Property Modified"); + case Modification::Type_Creation: return tr("?"); case Modification::Type_Missing: return tr("!"); - case Modification::Type_Conflicting: return tr("Conflicting"); + case Modification::Type_Conflict: return tr("Conflicting"); } Q_ASSERT(false); @@ -219,7 +219,7 @@ else if (isPathColumn(rcIndex.column())) { QString path = mod.getFilePath(); - if (mod.getType() == Modification::Type_Add && mod.isAddedWithHistory()) + if (mod.getType() == Modification::Type_Addition && mod.isAddedWithHistory()) path += tr(" (with history from %1)").arg(mod.getHistoryFilePath()); return path; Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/src/svn/commit_summary.cpp 2006-12-22 18:43:05 UTC (rev 135) @@ -127,34 +127,30 @@ char *path; void *val; apr_hash_this(pKey, (const void **)&path, NULL, &val); - - Modification mod; - mod.mFilePath = path; - removePrefixNoCase(mod.mFilePath, pThis->mRepoUrl); - - mod.mNewRevision = Revision::committed(revision); - mod.mOldRevision = Revision::committed(revision-1); + + QString filePath = path; + removePrefixNoCase(filePath, pThis->mRepoUrl); + svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *>(val); switch (log_item->action) { case 'A': - mod.mType = Modification::Type_Add; + summary.mModifications.append(Modification::addition(filePath, Revision::committed(revision))); break; case 'D': - mod.mType = Modification::Type_Delete; + summary.mModifications.append(Modification::deletion(filePath, Revision::committed(revision))); break; case 'R': // TODO: handle "replace" - mod.mType = Modification::Type_Add; + summary.mModifications.append(Modification::addition(filePath, Revision::committed(revision))); break; case 'M': - mod.mType = Modification::Type_TextMod; + summary.mModifications.append(Modification::fileModification(filePath, Revision::committed(revision-1), Revision::committed(revision))); break; default: // TODO: return error break; } - summary.mModifications.append(mod); } } @@ -168,36 +164,45 @@ return NULL; } -void Svn::CommitSummaryFetcher::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) +void Svn::CommitSummaryFetcher::statusCallback(void *baton, const char *fullPath, svn_wc_status2_t *status) { + CommitSummaryFetcher* pThis = (CommitSummaryFetcher*)baton; + + QString filePath = fullPath; + removePrefixNoCase(filePath, pThis->mWcPath); + Modification mod; switch (status->text_status) { // cases we care about case svn_wc_status_unversioned: - mod.mType = Modification::Type_New; + mod = Modification::creation(filePath); break; case svn_wc_status_added: if (status->copied) - mod.mHistoryFilePath = status->entry->copyfrom_url; - - mod.mType = Modification::Type_Add; + { + QString historyFilePath = status->entry->copyfrom_url; + removePrefixNoCase(historyFilePath, pThis->mRepoUrl); + mod = Modification::additionWithHistory(filePath, Revision::uncommitted(), historyFilePath, Revision::base()); + } + else + mod = Modification::addition(filePath, Revision::uncommitted()); break; case svn_wc_status_missing: - mod.mType = Modification::Type_Missing; + mod = Modification::missing(filePath); break; case svn_wc_status_deleted: - mod.mType = Modification::Type_Delete; + mod = Modification::deletion(filePath, Revision::uncommitted()); break; case svn_wc_status_modified: - mod.mType = Modification::Type_TextMod; + mod = Modification::fileModification(filePath, Revision::base(), Revision::uncommitted()); break; case svn_wc_status_conflicted: - mod.mType = Modification::Type_Conflicting; + mod = Modification::conflict(filePath); break; // cases we can ignore @@ -215,22 +220,9 @@ return; } - - CommitSummaryFetcher* pThis = (CommitSummaryFetcher*)baton; - - // Set file path (removing working copy part) - mod.mNewRevision = Revision::uncommitted(); - - mod.mFilePath = path; - removePrefixNoCase(mod.mFilePath, pThis->mWcPath); - removePrefixNoCase(mod.mHistoryFilePath, pThis->mRepoUrl); - // Set old revision to base, if the file is already under version control - if (status->entry) - mod.mOldRevision = Revision::base(); - // Assume that if we're here (i.e. checking WC status) that we're only retrieving one revision GSVN_ASSERT(pThis->mSummaries.size() == 1); - + pThis->mSummaries[0].mModifications.append(mod); } Added: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp (rev 0) +++ trunk/src/svn/modification.cpp 2006-12-22 18:43:05 UTC (rev 135) @@ -0,0 +1,134 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "svn/modification.h" + +Modification Modification::fromType(Type type, QString filePath, Revision revision) +{ + Modification mod; + mod.mType = type; + mod.mRevision = revision; + mod.mFilePath = filePath; + return mod; +} + +Modification Modification::fileModification(QString filePath, Revision oldRevision, Revision newRevision) +{ + Modification mod = fromType(Type_FileModification, filePath, newRevision); + mod.mOldRevision = oldRevision; + return mod; +} + +Modification Modification::addition(QString filePath, Revision revision) +{ + return fromType(Type_Addition, filePath, revision); +} + + +Modification Modification::additionWithHistory(QString filePath, Revision revision, QString historyFilePath, Revision historyRevision) +{ + Modification mod = fromType(Type_Addition, filePath, revision); + mod.mHistoryFilePath = historyFilePath; + mod.mHistoryRevision = historyRevision; + return mod; +} + +Modification Modification::deletion(QString filePath, Revision revision) +{ + return fromType(Type_Deletion, filePath, revision); +} + +Modification Modification::propertyModification(QString filePath, Revision oldRevision, Revision newRevision) +{ + Modification mod = fromType(Type_PropertyModification, filePath, newRevision); + mod.mOldRevision = oldRevision; + return mod; +} + +Modification Modification::creation(QString filePath) +{ + return fromType(Type_Creation, filePath, Revision::uncommitted()); +} + +Modification Modification::missing(QString filePath) +{ + return fromType(Type_Missing, filePath, Revision::uncommitted()); +} + +Modification Modification::conflict(QString filePath) +{ + return fromType(Type_Conflict, filePath, Revision::uncommitted()); +} + +bool Modification::isVersionedType(Type type) +{ + switch (type) + { + case Type_FileModification: + case Type_Addition: + case Type_Deletion: + case Type_PropertyModification: + return true; + + case Type_Creation: + case Type_Missing: + case Type_Conflict: + return false; + } + + return false; +} + +Modification::Type Modification::getType() const +{ + return mType; +} + +QString Modification::getFilePath() const +{ + return mFilePath; +} + +Revision Modification::getRevision() const +{ + return mRevision; +} + +bool Modification::isAddedWithHistory() const +{ + Q_ASSERT(mType == Type_Addition); + return mHistoryFilePath != ""; +} +QString Modification::getHistoryFilePath() const +{ + Q_ASSERT(isAddedWithHistory()); + return mHistoryFilePath; +} + +Revision Modification::fileModification_getOldRevision() const +{ + return mOldRevision; +} + +Revision Modification::propertyModification_getOldRevision() const +{ + return mOldRevision; +} + Modified: trunk/tests/nullable_test.h =================================================================== --- trunk/tests/nullable_test.h 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/tests/nullable_test.h 2006-12-22 18:43:05 UTC (rev 135) @@ -23,7 +23,7 @@ class NullableTester : public QObject { Q_OBJECT -private slots: +private: void init() {} void testDefaultConstructor(); void testCopyConstructorValue(); Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/tests/svn_test.cpp 2006-12-22 18:43:05 UTC (rev 135) @@ -20,6 +20,8 @@ #include "svn_test.h" +#include "svn/add.h" +#include "svn/svn_commit.h" #include <svn/commit_summary.h> #include <svn/file_access.h> #include <svn/modification.h> @@ -32,6 +34,29 @@ #include <iostream> +#define SVN_VERIFY(command) \ + do { \ + pError = (command); \ + if (!pError)\ + break;\ + qDebug("Condition failed: " #command "\n");\ + while (pError) {\ + qDebug(pError->message);\ + pError = pError->child;\ + }\ + QVERIFY(false); \ + } while (0) + +#define GSVN_VERIFY(command) \ + do { \ + if (!(command)) {\ + qDebug("Condition failed: " #command "\n");\ + qDebug(error.toAscii());\ + QVERIFY(false); \ + }\ + } while (0) + + namespace { bool clearReadOnlyFlag(QFileInfo file) @@ -67,11 +92,6 @@ QString rIgnoredError; Q_ASSERT(Operation::initAuthProviders(*mpContext, mpCtx, rIgnoredError)); - - mpCtx->log_msg_func = logMsgCallback; - mpCtx->log_msg_baton = this; - - mpCurrentCommitMsg = NULL; } SvnTester::~SvnTester() @@ -80,28 +100,9 @@ delete mpContext; } -svn_error_t* SvnTester::commitChanges(const char* pCommitMessage) -{ - mpCurrentCommitMsg = pCommitMessage; - - svn_client_commit_info_t* pCommitInfo; - apr_array_header_t *array = apr_array_make(mpContext->getAprPool(), 1, sizeof(const char*)); - APR_ARRAY_PUSH(array, const char*) = svn_path_canonicalize(getWcPath().toAscii(), mpContext->getAprPool()); - - svn_error_t* pError = svn_client_commit2(&pCommitInfo, array, true, false, mpCtx, mpContext->getAprPool()); - mpCurrentCommitMsg = NULL; - return pError; -} - -svn_error_t* SvnTester::addFile(QString relFilePath) -{ - QString fullPath = QDir::convertSeparators(getWcPath()+relFilePath); - return svn_client_add2(fullPath.toAscii(), true, true, mpCtx, mpContext->getAprPool()); -} - bool SvnTester::touchFile(QString relFilePath, QString fileText) { - QFile file(getWcPath()+relFilePath); + QFile file(getWcPath()+"/"+relFilePath); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return false; @@ -131,7 +132,7 @@ return false; } } - if (!dir.rmdir(filePath)) + if (dir.exists() && !dir.rmdir(filePath)) return false; return true; @@ -151,48 +152,10 @@ return fileText; } -bool SvnTester::updateWc() +void SvnTester::createRepoAndWc() { - apr_array_header_t *array = apr_array_make(mpContext->getAprPool(), 1, sizeof(const char*)); - APR_ARRAY_PUSH(array, const char*) = svn_path_canonicalize(getWcPath().toAscii(), mpContext->getAprPool()); - svn_opt_revision_t revision; - revision.kind = svn_opt_revision_head; - if (svn_client_update2(NULL, array, &revision, true, true, mpCtx, mpContext->getAprPool())) - return false; - - return true; -} + cleanup(); -#define SVN_VERIFY(command) \ - do { \ - pError = (command); \ - if (!pError)\ - break;\ - qDebug("Condition failed: " #command "\n");\ - while (pError) {\ - qDebug(pError->message);\ - pError = pError->child;\ - }\ - QVERIFY(false); \ - } while (0) - -#define GSVN_VERIFY(command) \ - do { \ - if (!(command)) {\ - qDebug("Condition failed: " #command "\n");\ - qDebug(rError.toAscii());\ - QVERIFY(false); \ - }\ - } while (0) - -void SvnTester::init() -{ -#ifdef Q_WS_WIN - // force these tests to fail early on Windows since they interfere - // with the working copy in the current directory. - QVERIFY(false); -#endif - apr_pool_t* pSubPool = svn_pool_create(mpContext->getAprPool()); svn_repos_t* pCreatedRepo; @@ -213,14 +176,17 @@ const char* repoPath = svn_path_canonicalize(url.toAscii(), mpContext->getAprPool()); const char* wcPath = svn_path_canonicalize(getWcPath().toAscii(), mpContext->getAprPool()); SVN_VERIFY(svn_client_checkout2(NULL, repoPath, wcPath, &revision, &revision, true, false, mpCtx, mpContext->getAprPool())); +} + + +void SvnTester::init() +{ +#ifdef Q_WS_WIN + // force these tests to fail early on Windows since they interfere + // with the working copy in the current directory. + QVERIFY(false); +#endif - QVERIFY(touchFile("/first.txt", "This is the first file")); - SVN_VERIFY(addFile("/first.txt")); - SVN_VERIFY(commitChanges("first commit")); - QVERIFY(touchFile("/second.txt", "This is the second file")); - SVN_VERIFY(addFile("/second.txt")); - - QVERIFY(updateWc()); } void SvnTester::cleanup() @@ -229,81 +195,96 @@ QVERIFY(removeDirectory(getWcPath())); } - -svn_error_t* SvnTester::logMsgCallback(const char **log_msg, const char **tmp_file, apr_array_header_t * /*commit_items*/, void *baton, apr_pool_t * /*pool*/) +void SvnTester::assertModsMatch(QString wcPath, Revision rev, QList<Modification> mods) { - SvnTester* pThis = (SvnTester*)baton; - Q_ASSERT(pThis->mpCurrentCommitMsg != NULL); - *log_msg = pThis->mpCurrentCommitMsg; - pThis->mpCurrentCommitMsg = NULL; - tmp_file = NULL; - return NULL; + Svn::CommitSummary summary; + Svn::CommitSummaryFetcher fetcher; + QString error; + GSVN_VERIFY(fetcher.fetchSummary(*mpContext, wcPath, rev, true, summary, error)); + + QCOMPARE(summary.modifications().size(), mods.size()); + for (int i = 0; i < mods.size(); i++) + { + QCOMPARE(summary.modifications()[i].getFilePath(), mods[i].getFilePath()); + QCOMPARE(summary.modifications()[i].getType(), mods[i].getType()); + if (Modification::isVersionedType(summary.modifications()[i].getType())) + { + QCOMPARE(summary.modifications()[i].getRevision(), rev); + } + else + { + QCOMPARE(rev, Revision::uncommitted()); + QCOMPARE(summary.modifications()[i].getRevision(), Revision::uncommitted()); + } + } } -void SvnTester::testModifications() +void SvnTester::testAdd() { - Svn::CommitSummary summary; - Svn::CommitSummaryFetcher fetcher; - QString rError; - Revision rev; - rev = Revision::committed(1); - GSVN_VERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, true, summary, rError)); + createRepoAndWc(); - QList<Modification> mods = summary.modifications(); + QString error; + QVERIFY(touchFile("first.txt", "This is the first file")); - QCOMPARE(mods.size(), 1); - QCOMPARE(mods[0].getFilePath(), QString("/first.txt")); - QCOMPARE(mods[0].getType(), Modification::Type_Add); - QCOMPARE(summary.getRevision(), Revision::committed(1)); + assertModsMatch(getWcPath(), Revision::uncommitted(), QList<Modification>() << Modification::creation("first.txt")); + + GSVN_VERIFY(Svn::add(*mpContext, getWcPath()+"/first.txt", error)); - rev = Revision::uncommitted(); - GSVN_VERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, true, summary, rError)); + assertModsMatch(getWcPath(), Revision::uncommitted(), QList<Modification>() << Modification::addition("first.txt", Revision::uncommitted())); - QCOMPARE(mods.size(), 1); - QCOMPARE(mods[0].getFilePath(), QString("/second.txt")); - QCOMPARE(mods[0].getType(), Modification::Type_Add); - QCOMPARE(summary.getRevision(), Revision::uncommitted()); + GSVN_VERIFY(Svn::commit(*mpContext, "test", QStringList() << getWcPath()+"/first.txt", error)); + + assertModsMatch(getWcPath(), Revision::committed(1), QList<Modification>() << Modification::addition("first.txt", Revision::committed(1))); } void SvnTester::testRepoFileAccess() { - QString rError; + createRepoAndWc(); + +// Test committed file + QString error; + QVERIFY(touchFile("first.txt", "This is the first file")); + GSVN_VERIFY(Svn::add(*mpContext, getWcPath()+"/first.txt", error)); + GSVN_VERIFY(Svn::commit(*mpContext, "test", QStringList() << getWcPath()+"/first.txt", error)); + QString filePath; - Revision oldRev; - oldRev = Revision::committed(1); - GSVN_VERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/first.txt"), oldRev, filePath, rError)); + GSVN_VERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/first.txt"), Revision::committed(1), filePath, error)); QCOMPARE(getFileContents(filePath), QString("This is the first file")); QVERIFY(filePath != getWcPath()+"/first.txt"); // We should not overwrite the WC copy! - Revision newRev; - newRev = Revision::uncommitted(); - GSVN_VERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/second.txt"), newRev, filePath, rError)); +// Test uncommitted file + QVERIFY(touchFile("second.txt", "This is the second file")); + GSVN_VERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/second.txt"), Revision::uncommitted(), filePath, error)); QCOMPARE(filePath, getWcPath()+"/second.txt"); // We should return the WC file path directly if working on uncommitted revisions QCOMPARE(getFileContents(filePath), QString("This is the second file")); - - - QVERIFY(touchFile("/first.txt", "This is the first file, now modified")); - + +// Test both committed and uncommitted files + QVERIFY(touchFile("first.txt", "This is the first file, now modified")); + QString oldFilePath, newFilePath; - GSVN_VERIFY(RepoFileAccess::getDiffFiles(*mpContext, getWcPath()+"/first.txt", oldRev, newRev, oldFilePath, newFilePath, rError)); + GSVN_VERIFY(RepoFileAccess::getDiffFiles(*mpContext, getWcPath()+"/first.txt", Revision::committed(1), Revision::uncommitted(), oldFilePath, newFilePath, error)); QCOMPARE(getFileContents(oldFilePath), QString("This is the first file")); QCOMPARE(getFileContents(newFilePath), QString("This is the first file, now modified")); } - - + + void SvnTester::testCommitSummary() { - QString rError; - Revision rev; - rev = Revision::committed(1); - + createRepoAndWc(); + +// Test committed file + QString error; + QVERIFY(touchFile("first.txt", "This is the first file")); + GSVN_VERIFY(Svn::add(*mpContext, getWcPath()+"/first.txt", error)); + GSVN_VERIFY(Svn::commit(*mpContext, "test message", QStringList() << getWcPath()+"/first.txt", error)); + Svn::CommitSummary summary; Svn::CommitSummaryFetcher fetcher; - GSVN_VERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, false, summary, rError)); + GSVN_VERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), Revision::committed(1), false, summary, error)); //QCOMPARE(summary.getCommitAuthor(), QString("billfrank")); //QCOMPARE(summary.getCommitDate(), bogus); - QCOMPARE(summary.getCommitLogMessage(), QString("first commit")); + QCOMPARE(summary.getCommitLogMessage(), QString("test message")); } Modified: trunk/tests/svn_test.h =================================================================== --- trunk/tests/svn_test.h 2006-12-22 18:01:02 UTC (rev 134) +++ trunk/tests/svn_test.h 2006-12-22 18:43:05 UTC (rev 135) @@ -59,32 +59,28 @@ QString getRepoPath() { return QDir::cleanPath(QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo")); } QString getWcPath() { return QDir::cleanPath(QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc")); } - svn_error_t* commitChanges(const char* pCommitMessage); - svn_error_t* addFile(QString relFilePath); bool touchFile(QString relFilePath, QString fileText); // fails if the file exists - bool updateWc(); bool removeDirectory(QString filePath); QString getFileContents(QString filePath); + void createRepoAndWc(); + + void assertModsMatch(QString wcPath, Revision rev, QList<Modification> mods); + private slots: void init(); void cleanup(); - void testModifications(); + void testAdd(); void testRepoFileAccess(); void testCommitSummary(); private: - // Callbacks - static svn_error_t* logMsgCallback(const char **log_msg, const char **tmp_file, apr_array_header_t *commit_items, void *baton, apr_pool_t *pool); -private: NoOperationStatus mStatus; NoAuthentication mAuthentication; SvnOperationContext* mpContext; svn_client_ctx_t* mpCtx; - - const char* mpCurrentCommitMsg; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 18:01:03
|
Revision: 134 http://svn.sourceforge.net/grandmas-svn/?rev=134&view=rev Author: matthiasmiller Date: 2006-12-22 10:01:02 -0800 (Fri, 22 Dec 2006) Log Message: ----------- clean up some gcc warnings Modified Paths: -------------- trunk/src/dialogs/mainwindow.cpp trunk/tests/svn_test.cpp Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-22 17:57:10 UTC (rev 133) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-22 18:01:02 UTC (rev 134) @@ -299,16 +299,22 @@ void MainWindow::fetchedCommittedRevisions(QString fullRepoPath, QList<Svn::CommitSummary> summaries) { + Q_UNUSED(fullRepoPath); mpRevisionsModel->showCommittedRevisions(summaries); } void MainWindow::fetchCommittedRevisionsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) { + Q_UNUSED(fullRepoPath); + Q_UNUSED(startRevision); + Q_UNUSED(endRevision); qDebug(tr("Unable to fetch commit summaries: %1").arg(error).toAscii()); } void MainWindow::fetchedModifications(QString fullRepoPath, QList<Svn::CommitSummary> summaries) { + Q_UNUSED(fullRepoPath); + GSVN_ASSERT(summaries.count() == 1); // Save the new modifications if showing an uncommitted revision to prevent @@ -324,6 +330,9 @@ void MainWindow::fetchModificationsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) { + Q_UNUSED(fullRepoPath); + Q_UNUSED(startRevision); + Q_UNUSED(endRevision); mpModificationsModel->showError(error); } Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-22 17:57:10 UTC (rev 133) +++ trunk/tests/svn_test.cpp 2006-12-22 18:01:02 UTC (rev 134) @@ -51,6 +51,7 @@ return true; #else + Q_UNUSED(file); return false; //unimpl #endif } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 17:57:14
|
Revision: 133 http://svn.sourceforge.net/grandmas-svn/?rev=133&view=rev Author: matthiasmiller Date: 2006-12-22 09:57:10 -0800 (Fri, 22 Dec 2006) Log Message: ----------- start compiling with MSVC's highest warning level Modified Paths: -------------- trunk/grandmas_svn.pro trunk/src/svn/revision.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-12-22 17:39:45 UTC (rev 132) +++ trunk/grandmas_svn.pro 2006-12-22 17:57:10 UTC (rev 133) @@ -150,6 +150,12 @@ # This is already defined in APR's header. DEFINES -= _CRT_SECURE_NO_DEPRECATE + + # Compile with warning level 4. Suppress the warnings that occur in Qt source code. + QMAKE_CFLAGS_WARN_ON = -W4 + QMAKE_CFLAGS_WARN_ON += -wd4127 # suppress warning: "conditional expression is constant" + QMAKE_CFLAGS_WARN_ON += -wd4512 # suppress warning: "assignment operator could not be generated" + QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON } # must set debug/release configuration immediately since it affects output directories. Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2006-12-22 17:39:45 UTC (rev 132) +++ trunk/src/svn/revision.cpp 2006-12-22 17:57:10 UTC (rev 133) @@ -58,8 +58,6 @@ default: return uncommitted(); } - GSVN_ASSERT(false); - return uncommitted(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 17:39:48
|
Revision: 132 http://svn.sourceforge.net/grandmas-svn/?rev=132&view=rev Author: matthiasmiller Date: 2006-12-22 09:39:45 -0800 (Fri, 22 Dec 2006) Log Message: ----------- include working copy path in CommitSummaryFetcherThread's signals; also include revisions in its failure signal Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/include/svn/commit_summary_thread.h trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary_thread.cpp Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-12-22 17:29:51 UTC (rev 131) +++ trunk/include/dialogs/mainwindow.h 2006-12-22 17:39:45 UTC (rev 132) @@ -56,10 +56,10 @@ void add(); void move(); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); - void fetchedCommittedRevisions(QList<Svn::CommitSummary> summaries); - void fetchCommittedRevisionsFailed(QString error); - void fetchedModifications(QList<Svn::CommitSummary> summaries); - void fetchModificationsFailed(QString error); + void fetchedCommittedRevisions(QString fullRepoPath, QList<Svn::CommitSummary> summaries); + void fetchCommittedRevisionsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); + void fetchedModifications(QString fullRepoPath, QList<Svn::CommitSummary> summaries); + void fetchModificationsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); private: void reloadCommitSummaries(); Modified: trunk/include/svn/commit_summary_thread.h =================================================================== --- trunk/include/svn/commit_summary_thread.h 2006-12-22 17:29:51 UTC (rev 131) +++ trunk/include/svn/commit_summary_thread.h 2006-12-22 17:39:45 UTC (rev 132) @@ -42,8 +42,8 @@ void stop(); signals: - void fetchedSummaries(QList<Svn::CommitSummary> summaries); - void failed(QString error); + void fetchedSummaries(QString fullRepoPath, QList<Svn::CommitSummary> summaries); + void failed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); private: virtual void run(); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-22 17:29:51 UTC (rev 131) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-22 17:39:45 UTC (rev 132) @@ -47,12 +47,16 @@ mPath = path; mpCommitSummaryThread = new CommitSummaryFetcherThread; - connect(mpCommitSummaryThread, SIGNAL(fetchedSummaries(QList<Svn::CommitSummary>)), this, SLOT(fetchedCommittedRevisions(QList<Svn::CommitSummary>))); - connect(mpCommitSummaryThread, SIGNAL(failed(QString)), this, SLOT(fetchCommittedRevisionsFailed(QString))); + connect(mpCommitSummaryThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), + this, SLOT(fetchedCommittedRevisions(QString,QList<Svn::CommitSummary>))); + connect(mpCommitSummaryThread, SIGNAL(failed(QString,Revision,Revision,QString)), + this, SLOT(fetchCommittedRevisionsFailed(QString,Revision,Revision,QString))); mpModificationsThread = new CommitSummaryFetcherThread; - connect(mpModificationsThread, SIGNAL(fetchedSummaries(QList<Svn::CommitSummary>)), this, SLOT(fetchedModifications(QList<Svn::CommitSummary>))); - connect(mpModificationsThread, SIGNAL(failed(QString)), this, SLOT(fetchModificationsFailed(QString))); + connect(mpModificationsThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), this, + SLOT(fetchedModifications(QString,QList<Svn::CommitSummary>))); + connect(mpModificationsThread, SIGNAL(failed(QString,Revision,Revision,QString)), + this, SLOT(fetchModificationsFailed(QString,Revision,Revision,QString))); mpUi = new Ui_MainWindow(); mpUi->setupUi(this); @@ -293,17 +297,17 @@ } } -void MainWindow::fetchedCommittedRevisions(QList<Svn::CommitSummary> summaries) +void MainWindow::fetchedCommittedRevisions(QString fullRepoPath, QList<Svn::CommitSummary> summaries) { mpRevisionsModel->showCommittedRevisions(summaries); } -void MainWindow::fetchCommittedRevisionsFailed(QString error) +void MainWindow::fetchCommittedRevisionsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) { qDebug(tr("Unable to fetch commit summaries: %1").arg(error).toAscii()); } -void MainWindow::fetchedModifications(QList<Svn::CommitSummary> summaries) +void MainWindow::fetchedModifications(QString fullRepoPath, QList<Svn::CommitSummary> summaries) { GSVN_ASSERT(summaries.count() == 1); @@ -318,7 +322,7 @@ mpModificationsModel->showModifications(summaries.at(0).modifications()); } -void MainWindow::fetchModificationsFailed(QString error) +void MainWindow::fetchModificationsFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error) { mpModificationsModel->showError(error); } Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2006-12-22 17:29:51 UTC (rev 131) +++ trunk/src/svn/commit_summary_thread.cpp 2006-12-22 17:39:45 UTC (rev 132) @@ -57,11 +57,11 @@ if (fetcher.fetchSummaries(context, fullRepoPath, startRevision, endRevision, true, summaries, error)) { qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); - emit fetchedSummaries(summaries); + emit fetchedSummaries(fullRepoPath, summaries); } else { - emit failed(error); + emit failed(fullRepoPath, startRevision, endRevision, error); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 17:29:51
|
Revision: 131 http://svn.sourceforge.net/grandmas-svn/?rev=131&view=rev Author: matthiasmiller Date: 2006-12-22 09:29:51 -0800 (Fri, 22 Dec 2006) Log Message: ----------- create an interface for caching commit summaries Modified Paths: -------------- trunk/grandmas_svn.pro Added Paths: ----------- trunk/include/commit_summary_cache.h trunk/src/commit_summary_cache.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-12-22 17:06:17 UTC (rev 130) +++ trunk/grandmas_svn.pro 2006-12-22 17:29:51 UTC (rev 131) @@ -187,6 +187,7 @@ RC_FILE = ui/icons/win32.rc HEADERS += include/commandline.h \ + include/commit_summary_cache.h \ include/commit_summary_sort.h \ include/debug.h \ include/dialogs/authentication.h \ @@ -218,6 +219,7 @@ src/grandmas_svn.h SOURCES += src/commandline.cpp \ + src/commit_summary_cache.cpp \ src/commit_summary_sort.cpp \ src/debug.cpp \ src/dialogs/authentication.cpp \ Added: trunk/include/commit_summary_cache.h =================================================================== --- trunk/include/commit_summary_cache.h (rev 0) +++ trunk/include/commit_summary_cache.h 2006-12-22 17:29:51 UTC (rev 131) @@ -0,0 +1,59 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <QObject> + +#include "svn/commit_summary.h" + +class CommitSummaryFetcherThread; +class Revision; + +class CommitSummaryCache : public QObject +{ + Q_OBJECT +public: + CommitSummaryCache(QString fullRepoPath); + ~CommitSummaryCache(); + + void fetchSummariesSync(Revision startRevision, Revision endRevision); + void fetchSummariesAsync(Revision startRevision, Revision endRevision); + + QList<Svn::CommitSummary> getCommitSummaries() const; + Svn::CommitSummary getCommitSummary(Revision rev) const; + bool didLastFetchSucceed(Revision rev, QString& rError) const; + +signals: + void beforeCommitSummaryAdded(Revision rev); + void afterCommitSummaryAdded(Revision rev); + void beforeCommitSummaryChanged(Revision rev); + void afterCommitSummaryChanged(Revision rev); + void fetchFailed(Revision startRevision, Revision endRevision, QString error); + +private slots: + void fetchedCommitSummaries(QString fullRepoPath, QList<Svn::CommitSummary> summaries); + void fetchCommitSummariesFailed(QString fullRepoPath, Revision startRevision, Revision endRevision, QString error); + +private: + QString mFullRepoPath; + CommitSummaryFetcherThread* mpThread; + QList<Svn::CommitSummary> mCommitSummaries; + struct FetchResult; + QList<FetchResult> mFetchResults; +}; Added: trunk/src/commit_summary_cache.cpp =================================================================== --- trunk/src/commit_summary_cache.cpp (rev 0) +++ trunk/src/commit_summary_cache.cpp 2006-12-22 17:29:51 UTC (rev 131) @@ -0,0 +1,141 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "commit_summary_cache.h" + +#include "commit_summary_sort.h" +#include "svn/commit_summary_thread.h" +#include "svn/revision.h" + +struct CommitSummaryCache::FetchResult +{ + Revision mStartRevision, mEndRevision; + bool mSuccess; + QString mError; +}; + + +CommitSummaryCache::CommitSummaryCache(QString fullRepoPath) +{ + mFullRepoPath = fullRepoPath; + + mpThread = new CommitSummaryFetcherThread; + connect(mpThread, SIGNAL(fetchedSummaries(QString,QList<Svn::CommitSummary>)), + this, SLOT(fetchedCommitSummaries(QString,QList<Svn::CommitSummary>))); + connect(mpThread, SIGNAL(failed(QString,Revision,Revision,QString)), + this, SLOT(fetchCommitSummariesFailed(QString,Revision,Revision,QString))); +} + +CommitSummaryCache::~CommitSummaryCache() +{ + mpThread->stop(); + delete mpThread; + mpThread = NULL; +} + +void CommitSummaryCache::fetchSummariesSync(Revision startRevision, Revision endRevision) +{ + return mpThread->fetchSummariesSync(mFullRepoPath, startRevision, endRevision); +} + +void CommitSummaryCache::fetchSummariesAsync(Revision startRevision, Revision endRevision) +{ + mpThread->fetchSummariesAsync(mFullRepoPath, startRevision, endRevision); +} + +QList<Svn::CommitSummary> CommitSummaryCache::getCommitSummaries() const +{ + return mCommitSummaries; +} + +Svn::CommitSummary CommitSummaryCache::getCommitSummary(Revision rev) const +{ + int index = -1; + if (!CommitSummaryFinder::findByRevision(mCommitSummaries, rev, index)) + { + GSVN_ASSERT(false); + return Svn::CommitSummary(); + } + + return mCommitSummaries.at(index); +} + +bool CommitSummaryCache::didLastFetchSucceed(Revision rev, QString& rError) const +{ + rError = QString(); + + Q_FOREACH(FetchResult result, mFetchResults) + { + if (isRevisionInRange(rev, result.mStartRevision, result.mEndRevision)) + { + rError = result.mError; + return result.mSuccess; + } + } + + GSVN_ASSERT(false); + return false; +} + +void CommitSummaryCache::fetchedCommitSummaries(QString fullRepoPath, QList<Svn::CommitSummary> summaries) +{ + Q_UNUSED(fullRepoPath); + + if (summaries.size() > 0) + { + FetchResult result; + result.mStartRevision = summaries.first().getRevision(); + result.mEndRevision = summaries.last().getRevision(); + result.mSuccess = true; + result.mError = QString(); + mFetchResults.push_front(result); + } + + Q_FOREACH(Svn::CommitSummary summary, summaries) + { + int index = -1; + if (CommitSummaryFinder::findByRevision(mCommitSummaries, summary.getRevision(), index)) + { + emit beforeCommitSummaryChanged(summary.getRevision()); + mCommitSummaries[index] = summary; + emit afterCommitSummaryChanged(summary.getRevision()); + } + else + { + emit beforeCommitSummaryAdded(summary.getRevision()); + mCommitSummaries.insert(index, summary); + emit afterCommitSummaryAdded(summary.getRevision()); + } + } +} + +void CommitSummaryCache::fetchCommitSummariesFailed(QString fullRepoPath, Revision startRevision, + Revision endRevision, QString error) +{ + Q_UNUSED(fullRepoPath); + + FetchResult result; + result.mStartRevision = startRevision; + result.mEndRevision = endRevision; + result.mSuccess = false; + result.mError = error; + mFetchResults.push_front(result); + + emit fetchFailed(startRevision, endRevision, error); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 17:06:18
|
Revision: 130 http://svn.sourceforge.net/grandmas-svn/?rev=130&view=rev Author: matthiasmiller Date: 2006-12-22 09:06:17 -0800 (Fri, 22 Dec 2006) Log Message: ----------- add helper functions to sort commit summaries by revision Modified Paths: -------------- trunk/grandmas_svn.pro trunk/tests/tests.cpp Added Paths: ----------- trunk/include/commit_summary_sort.h trunk/src/commit_summary_sort.cpp trunk/tests/commit_summary_sort_test.cpp trunk/tests/commit_summary_sort_test.h Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-12-22 15:15:46 UTC (rev 129) +++ trunk/grandmas_svn.pro 2006-12-22 17:06:17 UTC (rev 130) @@ -187,6 +187,7 @@ RC_FILE = ui/icons/win32.rc HEADERS += include/commandline.h \ + include/commit_summary_sort.h \ include/debug.h \ include/dialogs/authentication.h \ include/dialogs/commit.h \ @@ -217,6 +218,7 @@ src/grandmas_svn.h SOURCES += src/commandline.cpp \ + src/commit_summary_sort.cpp \ src/debug.cpp \ src/dialogs/authentication.cpp \ src/dialogs/commit.cpp \ @@ -254,10 +256,12 @@ contains(DEFINES, GSVN_TESTS) { CONFIG += qtestlib HEADERS += tests/commandlinetest.h \ + tests/commit_summary_sort_test.h \ tests/nullable_test.h \ tests/svn_test.h \ tests/tests.h SOURCES += tests/commandlinetest.cpp \ + tests/commit_summary_sort_test.cpp \ tests/nullable_test.cpp \ tests/svn_test.cpp \ tests/tests.cpp Added: trunk/include/commit_summary_sort.h =================================================================== --- trunk/include/commit_summary_sort.h (rev 0) +++ trunk/include/commit_summary_sort.h 2006-12-22 17:06:17 UTC (rev 130) @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <QList> + +class Revision; +namespace Svn +{ + class CommitSummary; +} + +// "less than" means "earlier than" +bool isRevisionLessThan(const Revision& rLeft, const Revision& rRight); + +bool isRevisionInRange(Revision rev, Revision min, Revision max); + +namespace CommitSummaryFinder +{ + // This function returns the revisions from latest-to-earliest. The list of revisions must + // have been ordered by this function. + bool findByRevision(QList<Svn::CommitSummary> summaries, const Revision& rRev, int& rIndex); +} Added: trunk/src/commit_summary_sort.cpp =================================================================== --- trunk/src/commit_summary_sort.cpp (rev 0) +++ trunk/src/commit_summary_sort.cpp 2006-12-22 17:06:17 UTC (rev 130) @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "commit_summary_sort.h" + +#include "svn/commit_summary.h" +#include "svn/revision.h" + +namespace +{ + int getRevisionTypeNumber(Revision::Type type) + { + switch (type) + { + case Revision::Uncommitted: return 2; + case Revision::Committed: return 0; + case Revision::Base: return 1; + case Revision::Head: return 3; + default: + GSVN_ASSERT(false); + return 0; + } + } +} + +bool isRevisionLessThan(const Revision& rLeft, const Revision& rRight) +{ + // Compare types first. + int leftTypeSort = getRevisionTypeNumber(rLeft.getType()); + int rightTypeSort = getRevisionTypeNumber(rRight.getType()); + if (leftTypeSort < rightTypeSort) + return true; + else if (leftTypeSort > rightTypeSort) + return false; + + // The types must match. Reverse-sort by revision number. + return (rLeft.getType() == Revision::Committed && + rLeft.getCommittedRevision() < rRight.getCommittedRevision()); +} + +bool isRevisionInRange(Revision rev, Revision min, Revision max) +{ + if (isRevisionLessThan(max, min)) + return isRevisionInRange(rev, max, min); + + return !isRevisionLessThan(rev, min) && !isRevisionLessThan(max, rev); +} + +namespace +{ + class CommitSummaryRevisionLessThan + { + public: + inline bool CommitSummaryRevisionLessThan::operator()(const Svn::CommitSummary& rLeft, const Svn::CommitSummary& rRight) const + { + return isRevisionLessThan(rRight.getRevision(), rLeft.getRevision()); + } + + inline bool CommitSummaryRevisionLessThan::operator()(const Svn::CommitSummary& rLeft, const Revision& rRight) const + { + return isRevisionLessThan(rRight, rLeft.getRevision()); + } + }; +} + +bool CommitSummaryFinder::findByRevision(QList<Svn::CommitSummary> summaries, const Revision& rRev, int& rIndex) +{ + CommitSummaryRevisionLessThan lessThan; + QList<Svn::CommitSummary>::iterator iter = qLowerBound(summaries.begin(), summaries.end(), rRev, lessThan); + rIndex = (iter - summaries.begin()); + return iter != summaries.end() && iter->getRevision() == rRev; +} Added: trunk/tests/commit_summary_sort_test.cpp =================================================================== --- trunk/tests/commit_summary_sort_test.cpp (rev 0) +++ trunk/tests/commit_summary_sort_test.cpp 2006-12-22 17:06:17 UTC (rev 130) @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "commit_summary_sort_test.h" + +#include "commit_summary_sort.h" +#include "svn/revision.h" + +#include <QtTest/QtTest> + +void CommitSummarySortTester::testRevisionCompareUncommitted() +{ + Revision rev = Revision::uncommitted(); + QVERIFY(!isRevisionLessThan(rev, Revision::uncommitted())); + QVERIFY(!isRevisionLessThan(rev, Revision::base())); + QVERIFY(isRevisionLessThan(rev, Revision::head())); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(0))); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(42))); +} + +void CommitSummarySortTester::testRevisionCompareCommitted() +{ + Revision rev = Revision::committed(7); + QVERIFY(isRevisionLessThan(rev, Revision::uncommitted())); + QVERIFY(isRevisionLessThan(rev, Revision::base())); + QVERIFY(isRevisionLessThan(rev, Revision::head())); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(0))); + QVERIFY(isRevisionLessThan(rev, Revision::committed(42))); +} + +void CommitSummarySortTester::testRevisionCompareBase() +{ + Revision rev = Revision::base(); + QVERIFY(isRevisionLessThan(rev, Revision::uncommitted())); + QVERIFY(!isRevisionLessThan(rev, Revision::base())); + QVERIFY(isRevisionLessThan(rev, Revision::head())); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(0))); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(42))); +} + +void CommitSummarySortTester::testRevisionCompareHead() +{ + Revision rev = Revision::head(); + QVERIFY(!isRevisionLessThan(rev, Revision::uncommitted())); + QVERIFY(!isRevisionLessThan(rev, Revision::base())); + QVERIFY(!isRevisionLessThan(rev, Revision::head())); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(0))); + QVERIFY(!isRevisionLessThan(rev, Revision::committed(42))); +} + +void CommitSummarySortTester::testRevisionRange() +{ + QVERIFY(isRevisionInRange(Revision::committed(0), Revision::committed(0), Revision::committed(0))); + QVERIFY(isRevisionInRange(Revision::committed(1), Revision::committed(0), Revision::committed(1))); + QVERIFY(isRevisionInRange(Revision::committed(1), Revision::committed(0), Revision::committed(2))); + QVERIFY(!isRevisionInRange(Revision::committed(0), Revision::committed(1), Revision::committed(2))); + QVERIFY(!isRevisionInRange(Revision::committed(3), Revision::committed(1), Revision::committed(2))); +} + +void CommitSummarySortTester::testRevisionRangeMaxMin() +{ + // should switch min/max appropriately + QVERIFY(isRevisionInRange(Revision::committed(7), Revision::committed(42), Revision::committed(0))); +} Added: trunk/tests/commit_summary_sort_test.h =================================================================== --- trunk/tests/commit_summary_sort_test.h (rev 0) +++ trunk/tests/commit_summary_sort_test.h 2006-12-22 17:06:17 UTC (rev 130) @@ -0,0 +1,33 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <QObject> + +class CommitSummarySortTester : public QObject +{ + Q_OBJECT +private slots: + void testRevisionCompareUncommitted(); + void testRevisionCompareCommitted(); + void testRevisionCompareBase(); + void testRevisionCompareHead(); + void testRevisionRange(); + void testRevisionRangeMaxMin(); +}; Modified: trunk/tests/tests.cpp =================================================================== --- trunk/tests/tests.cpp 2006-12-22 15:15:46 UTC (rev 129) +++ trunk/tests/tests.cpp 2006-12-22 17:06:17 UTC (rev 130) @@ -20,6 +20,7 @@ #include "tests.h" #include "commandlinetest.h" +#include "commit_summary_sort_test.h" #include "nullable_test.h" #include "svn_test.h" @@ -38,6 +39,7 @@ { int result = 0; TEST(CommandLineTest); + TEST(CommitSummarySortTester); TEST(NullableTester); TEST(SvnTester); return result; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-12-22 15:15:52
|
Revision: 129 http://svn.sourceforge.net/grandmas-svn/?rev=129&view=rev Author: highjinx Date: 2006-12-22 07:15:46 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Fix compile error under gcc Modified Paths: -------------- trunk/tests/nullable_test.h Modified: trunk/tests/nullable_test.h =================================================================== --- trunk/tests/nullable_test.h 2006-12-22 13:20:33 UTC (rev 128) +++ trunk/tests/nullable_test.h 2006-12-22 15:15:46 UTC (rev 129) @@ -22,7 +22,7 @@ class NullableTester : public QObject { - Q_OBJECT(); + Q_OBJECT private slots: void init() {} void testDefaultConstructor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 13:20:33
|
Revision: 128 http://svn.sourceforge.net/grandmas-svn/?rev=128&view=rev Author: matthiasmiller Date: 2006-12-22 05:20:33 -0800 (Fri, 22 Dec 2006) Log Message: ----------- * create a Nullable template class to save values that may be optionally set * force the Subversion tests to fail on Windows, since they interfere with the working copy in the current directory Modified Paths: -------------- trunk/grandmas_svn.pro trunk/tests/svn_test.cpp trunk/tests/tests.cpp Added Paths: ----------- trunk/include/nullable.h trunk/tests/nullable_test.cpp trunk/tests/nullable_test.h Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-12-22 05:06:57 UTC (rev 127) +++ trunk/grandmas_svn.pro 2006-12-22 13:20:33 UTC (rev 128) @@ -198,6 +198,7 @@ include/dialogs/revisionsmodel.h \ include/dialogs/util.h \ include/diff.h \ + include/nullable.h \ include/settings/userpaths.h \ include/svn/add.h \ include/svn/commit_summary.h \ @@ -253,9 +254,11 @@ contains(DEFINES, GSVN_TESTS) { CONFIG += qtestlib HEADERS += tests/commandlinetest.h \ + tests/nullable_test.h \ tests/svn_test.h \ tests/tests.h SOURCES += tests/commandlinetest.cpp \ + tests/nullable_test.cpp \ tests/svn_test.cpp \ tests/tests.cpp win32 { Added: trunk/include/nullable.h =================================================================== --- trunk/include/nullable.h (rev 0) +++ trunk/include/nullable.h 2006-12-22 13:20:33 UTC (rev 128) @@ -0,0 +1,81 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +template <class T> +class Nullable +{ +public: + Nullable() + { + mp = NULL; + } + Nullable(const Nullable& rOther) + { + mp = NULL; + *this = rOther; + } + Nullable(const T& rValue) + { + *this = rValue; + } + ~Nullable() + { + clear(); + } + + Nullable& operator=(const Nullable& rOther) + { + if (rOther.mp) + *this = *rOther.mp; + else + clear(); + return *this; + } + Nullable& operator=(const T& rValue) + { + if (mp != &rValue) + { + clear(); + mp = new T(rValue); + } + return *this; + } + + bool hasValue() const + { + return (mp != NULL); + } + const T& getValue() const + { + return *mp; + } + +private: + void clear() + { + if (mp) + { + delete mp; + mp = NULL; + } + } + + T* mp; +}; Added: trunk/tests/nullable_test.cpp =================================================================== --- trunk/tests/nullable_test.cpp (rev 0) +++ trunk/tests/nullable_test.cpp 2006-12-22 13:20:33 UTC (rev 128) @@ -0,0 +1,127 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "nullable_test.h" + +#include "nullable.h" + +#include <QtTest/QtTest> + +void NullableTester::testDefaultConstructor() +{ + Nullable<int> vNum; + QVERIFY(!vNum.hasValue()); +} + +void NullableTester::testCopyConstructorValue() +{ + Nullable<int> vNum(42); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopyConstructorNullable() +{ + Nullable<int> vNull; + QVERIFY(!vNull.hasValue()); + + Nullable<int> vNum(vNull); + QVERIFY(!vNum.hasValue()); +} + +void NullableTester::testCopyConstructorNullableValue() +{ + Nullable<int> vValue(42); + + Nullable<int> vNum(vValue); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopyValue() +{ + Nullable<int> vNum; + QVERIFY(!vNum.hasValue()); + vNum = 42; + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopyNullable() +{ + Nullable<int> vNull; + QVERIFY(!vNull.hasValue()); + + Nullable<int> vNum(42); + QVERIFY(vNum.hasValue()); + vNum = vNull; + QVERIFY(!vNum.hasValue()); +} + +void NullableTester::testCopyNullableValueToNull() +{ + Nullable<int> vValue(42); + + Nullable<int> vNum; + QVERIFY(!vNum.hasValue()); + vNum = vValue; + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopyNullableValueToValue() +{ + Nullable<int> vValue(42); + + Nullable<int> vNum(7); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 7); + vNum = vValue; + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopySelfNullableAsNull() +{ + Nullable<int> vNull; + QVERIFY(!vNull.hasValue()); + vNull = vNull; + QVERIFY(!vNull.hasValue()); +} + +void NullableTester::testCopySelfNullableAsValue() +{ + Nullable<int> vNum(42); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); + vNum = vNum; + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} + +void NullableTester::testCopySelfValue() +{ + Nullable<int> vNum(42); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); + vNum = vNum.getValue(); + QVERIFY(vNum.hasValue()); + QCOMPARE(vNum.getValue(), 42); +} Added: trunk/tests/nullable_test.h =================================================================== --- trunk/tests/nullable_test.h (rev 0) +++ trunk/tests/nullable_test.h 2006-12-22 13:20:33 UTC (rev 128) @@ -0,0 +1,40 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include <QObject> + +class NullableTester : public QObject +{ + Q_OBJECT(); +private slots: + void init() {} + void testDefaultConstructor(); + void testCopyConstructorValue(); + void testCopyConstructorNullable(); + void testCopyConstructorNullableValue(); + void testCopyValue(); + void testCopyNullable(); + void testCopyNullableValueToNull(); + void testCopyNullableValueToValue(); + void testCopySelfNullableAsNull(); + void testCopySelfNullableAsValue(); + void testCopySelfValue(); + void cleanup() {} +}; Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-22 05:06:57 UTC (rev 127) +++ trunk/tests/svn_test.cpp 2006-12-22 13:20:33 UTC (rev 128) @@ -186,6 +186,12 @@ void SvnTester::init() { +#ifdef Q_WS_WIN + // force these tests to fail early on Windows since they interfere + // with the working copy in the current directory. + QVERIFY(false); +#endif + apr_pool_t* pSubPool = svn_pool_create(mpContext->getAprPool()); svn_repos_t* pCreatedRepo; Modified: trunk/tests/tests.cpp =================================================================== --- trunk/tests/tests.cpp 2006-12-22 05:06:57 UTC (rev 127) +++ trunk/tests/tests.cpp 2006-12-22 13:20:33 UTC (rev 128) @@ -20,6 +20,7 @@ #include "tests.h" #include "commandlinetest.h" +#include "nullable_test.h" #include "svn_test.h" #include <QtTest/QtTest> @@ -37,6 +38,7 @@ { int result = 0; TEST(CommandLineTest); + TEST(NullableTester); TEST(SvnTester); return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 05:06:58
|
Revision: 127 http://svn.sourceforge.net/grandmas-svn/?rev=127&view=rev Author: matthiasmiller Date: 2006-12-21 21:06:57 -0800 (Thu, 21 Dec 2006) Log Message: ----------- add the MainWindow::getSelectedModifications() helper function Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/src/dialogs/mainwindow.cpp Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-12-22 03:25:46 UTC (rev 126) +++ trunk/include/dialogs/mainwindow.h 2006-12-22 05:06:57 UTC (rev 127) @@ -65,6 +65,7 @@ void reloadCommitSummaries(); void reloadModifications(); QList<int> getSelectedRows(QAbstractItemView* pView); + QList<Modification> getSelectedModifications(); Ui_MainWindow* mpUi; SvnOperationContext* mpContext; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-22 03:25:46 UTC (rev 126) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-22 05:06:57 UTC (rev 127) @@ -163,15 +163,11 @@ void MainWindow::diff() { - QList<int> rows = getSelectedRows(mpUi->changesTreeView); - Q_FOREACH(int row, rows) + QList<Modification> mods = getSelectedModifications(); + Q_FOREACH(Modification mod, mods) { // Generate each side of the diff QString error, leftPath, rightPath; - Modification mod; - if (!mpModificationsModel->getModificationForRow(row, mod)) - continue; - QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); if (!RepoFileAccess::getDiffFiles(*mpContext, fullFilePath, mod.getOldRevision(), mod.getNewRevision(), leftPath, rightPath, error)) { @@ -202,15 +198,10 @@ if (iResponse != QMessageBox::Yes) return; - QList<int> rows = getSelectedRows(mpUi->changesTreeView); - Q_FOREACH(int row, rows) + QList<Modification> mods = getSelectedModifications(); + Q_FOREACH(Modification mod, mods) { - // Generate each side of the diff - QString error, leftPath, rightPath; - Modification mod; - if (!mpModificationsModel->getModificationForRow(row, mod)) - continue; - + QString error; QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); if (!Svn::revert(*mpContext, fullFilePath, error)) { @@ -223,15 +214,10 @@ void MainWindow::add() { - QList<int> rows = getSelectedRows(mpUi->changesTreeView); - Q_FOREACH(int row, rows) + QList<Modification> mods = getSelectedModifications(); + Q_FOREACH(Modification mod, mods) { - // Generate each side of the diff - QString error, leftPath, rightPath; - Modification mod; - if (!mpModificationsModel->getModificationForRow(row, mod)) - continue; - + QString error; QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); if (!Svn::add(*mpContext, fullFilePath, error)) { @@ -350,3 +336,18 @@ return QList<int>::fromSet(rows); } + +QList<Modification> MainWindow::getSelectedModifications() +{ + QList<Modification> mods; + + QList<int> rows = getSelectedRows(mpUi->changesTreeView); + Q_FOREACH(int row, rows) + { + Modification mod; + if (mpModificationsModel->getModificationForRow(row, mod)) + mods.push_back(mod); + } + + return mods; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-22 03:25:45
|
Revision: 126 http://svn.sourceforge.net/grandmas-svn/?rev=126&view=rev Author: matthiasmiller Date: 2006-12-21 19:25:46 -0800 (Thu, 21 Dec 2006) Log Message: ----------- * replace File, Open with File, Exit * rename the Actions menu with Advanced and changing the mnemonic to avoid conflict * removing menu items that are already interfaced as buttons Modified Paths: -------------- trunk/ui/mainwindow.ui Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-12-21 23:49:15 UTC (rev 125) +++ trunk/ui/mainwindow.ui 2006-12-22 03:25:46 UTC (rev 126) @@ -1,7 +1,4 @@ <ui version="4.0" > - <author></author> - <comment></comment> - <exportmacro></exportmacro> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow" > <property name="geometry" > @@ -324,55 +321,35 @@ <x>0</x> <y>0</y> <width>639</width> - <height>22</height> + <height>21</height> </rect> </property> - <widget class="QMenu" name="menu_Actions" > + <widget class="QMenu" name="menuAdvanced" > <property name="title" > - <string>&Actions</string> + <string>Ad&vanced</string> </property> - <addaction name="action_Update_All" /> <addaction name="actionUpdate_Path_to_Revision" /> - <addaction name="action_Commit" /> - <addaction name="separator" /> - <addaction name="action_Diff" /> - <addaction name="action_Revert" /> - <addaction name="action_Add" /> - <addaction name="action_Delete" /> - <addaction name="action_Move_Rename" /> - <addaction name="separator" /> <addaction name="action_Annotate" /> </widget> <widget class="QMenu" name="menu_File" > <property name="title" > <string>&File</string> </property> - <addaction name="action_Open" /> + <addaction name="actionExit" /> </widget> <addaction name="menu_File" /> - <addaction name="menu_Actions" /> + <addaction name="menuAdvanced" /> </widget> <action name="action_Close" > <property name="text" > <string>&Close</string> </property> </action> - <action name="action_Open" > + <action name="actionExit" > <property name="text" > - <string>&Open...</string> + <string>E&xit</string> </property> - <property name="shortcut" > - <string>Ctrl+O</string> - </property> </action> - <action name="action_Update_All" > - <property name="text" > - <string>&Update All...</string> - </property> - <property name="shortcut" > - <string>Ctrl+U</string> - </property> - </action> <action name="actionUpdate_Path_to_Revision" > <property name="text" > <string>Update &Path to Revision...</string> @@ -381,42 +358,6 @@ <string>Ctrl+Shift+U</string> </property> </action> - <action name="action_Commit" > - <property name="text" > - <string>&Commit...</string> - </property> - <property name="shortcut" > - <string>Ctrl+I</string> - </property> - </action> - <action name="action_Diff" > - <property name="text" > - <string>&Diff</string> - </property> - <property name="shortcut" > - <string>Ctrl+D</string> - </property> - </action> - <action name="action_Revert" > - <property name="text" > - <string>&Revert</string> - </property> - </action> - <action name="action_Add" > - <property name="text" > - <string>&Add</string> - </property> - </action> - <action name="action_Delete" > - <property name="text" > - <string>&Delete</string> - </property> - </action> - <action name="action_Move_Rename" > - <property name="text" > - <string>&Move/Rename...</string> - </property> - </action> <action name="action_Annotate" > <property name="text" > <string>&Annotate</string> @@ -426,7 +367,6 @@ </property> </action> </widget> - <pixmapfunction></pixmapfunction> <tabstops> <tabstop>logEdit</tabstop> <tabstop>changesTreeView</tabstop> @@ -442,5 +382,22 @@ <resources> <include location="grandmas-svn.qrc" /> </resources> - <connections/> + <connections> + <connection> + <sender>actionExit</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>close()</slot> + <hints> + <hint type="sourcelabel" > + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel" > + <x>323</x> + <y>285</y> + </hint> + </hints> + </connection> + </connections> </ui> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 23:49:15
|
Revision: 125 http://svn.sourceforge.net/grandmas-svn/?rev=125&view=rev Author: matthiasmiller Date: 2006-12-21 15:49:15 -0800 (Thu, 21 Dec 2006) Log Message: ----------- The modifications model sometimes included too many modifications. Fix one scenario by sorting modifications by path. Also provide a fallback for the other remaining scenario, which occurs when there are modifications of different types for the same path. Modified Paths: -------------- trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 23:45:35 UTC (rev 124) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 23:49:15 UTC (rev 125) @@ -24,7 +24,19 @@ #include <QSize> +namespace +{ + class ModificationPathLessThan + { + public: + inline bool operator()(const Modification& rLeft, const Modification& rRight) const + { + return rLeft.getFilePath() < rRight.getFilePath(); + } + }; +} + ModificationsModel::ModificationsModel() : mAllowSelections(false) { } @@ -38,11 +50,14 @@ GSVN_ASSERT(!error.isNull()); mError = error; mAllModifications.clear(); - emit layoutChanged(); + reset(); } void ModificationsModel::showModifications(QList<Modification> modifications) { + // Sort by file path to provide more consistent display and to better maintain selection. + qSort(modifications.begin(), modifications.end(), ModificationPathLessThan()); + if (!mError.isEmpty()) { mError = QString(); @@ -51,6 +66,11 @@ return; } + // CAVEAT: If multiple modifications exist for the same path but with different types + // (such as a modify and property modify), the selection may switch to the wrong item. + // To solve this problem, match by type+name if the file path is listed more than once + // in either the old or the new list. + // remove all obsolete modifications for (int i = mAllModifications.size()-1; i >= 0; i--) { @@ -66,7 +86,6 @@ if (!shouldKeepMod) { - qDebug(tr("remove %1 at %2").arg(mAllModifications.at(i).getFilePath()).arg(i).toAscii()); beginRemoveRows(QModelIndex(), i, i); mAllModifications.removeAt(i); endRemoveRows(); @@ -74,25 +93,40 @@ } GSVN_ASSERT(mAllModifications.size() <= modifications.size()); - // add new modifications -- NOTE: This assumes that the caller will give modifications - // in a consistent order. Otherwise, selection may be lost. - for (int i = 0; i < modifications.size(); i++) + // add new modifications + for (int i = 0; i < qMax(mAllModifications.size(), modifications.size()); i++) { - if (i < mAllModifications.size() && mAllModifications[i].getFilePath() == modifications[i].getFilePath()) + if (i < mAllModifications.size() && i < modifications.size() && + mAllModifications[i].getFilePath() == modifications[i].getFilePath()) { // update modification if paths match mAllModifications[i] = modifications[i]; emit dataChanged(index(i,0), index(i,columnCount())); } - else + else if (i < modifications.size()) { - qDebug(tr("insert %1 at %2").arg(modifications.at(i).getFilePath()).arg(i).toAscii()); - // insert new modification beginInsertRows(QModelIndex(), i, i); mAllModifications.insert(i, modifications[i]); endInsertRows(); } + else if (i < mAllModifications.size()) + { + // NOTE: This algorithm assumes that modifications will always be processed + // in a consistent order. This condition should only occur if the the + // modifications were in an inconsistent order or if there were multiple + // modifications with the same path but different types. + qDebug("ModificationsModel: The user's selection may have been lost."); + + // remove modification if there was no match + beginRemoveRows(QModelIndex(), i, i); + mAllModifications.removeAt(i); + endRemoveRows(); + + i--; + } + else + GSVN_ASSERT(false); } GSVN_ASSERT(mAllModifications.size() == modifications.size()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 23:45:34
|
Revision: 124 http://svn.sourceforge.net/grandmas-svn/?rev=124&view=rev Author: matthiasmiller Date: 2006-12-21 15:45:35 -0800 (Thu, 21 Dec 2006) Log Message: ----------- fix annoying flash of stale data when tabbing to Grandma's SVN Modified Paths: -------------- trunk/src/dialogs/mainwindow.cpp Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-21 22:37:08 UTC (rev 123) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-21 23:45:35 UTC (rev 124) @@ -258,6 +258,7 @@ { mpRevisionsModel->showUncommittedRevision(uncommittedSummary); + // select the uncommitted revision if nothing is selected yet QItemSelectionModel* pSelection = mpUi->revisionsTreeView->selectionModel(); if (pSelection->selectedIndexes().count() == 0) { @@ -319,6 +320,15 @@ void MainWindow::fetchedModifications(QList<Svn::CommitSummary> summaries) { GSVN_ASSERT(summaries.count() == 1); + + // Save the new modifications if showing an uncommitted revision to prevent + // a refresh of stale data when the window receives focus. + if (mDisplayedCommitSummary.getRevision().getType() == Revision::Uncommitted && + summaries.at(0).getRevision().getType() == Revision::Uncommitted) + { + mDisplayedCommitSummary = summaries.at(0); + } + mpModificationsModel->showModifications(summaries.at(0).modifications()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 22:37:07
|
Revision: 123 http://svn.sourceforge.net/grandmas-svn/?rev=123&view=rev Author: matthiasmiller Date: 2006-12-21 14:37:08 -0800 (Thu, 21 Dec 2006) Log Message: ----------- * maintain correct selection when modifications are refreshed * make the commit dialog responsible for removing unversioned modifications (instead of the model) Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-12-21 20:44:17 UTC (rev 122) +++ trunk/include/dialogs/modificationsmodel.h 2006-12-21 22:37:08 UTC (rev 123) @@ -30,7 +30,7 @@ virtual ~ModificationsModel(); void showError(QString error); - void showModifications(QList<Modification> modifications, bool includeUnversionedMods); + void showModifications(QList<Modification> modifications); bool getModificationForRow(int row, Modification& rModification) const; Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-12-21 20:44:17 UTC (rev 122) +++ trunk/src/dialogs/commit.cpp 2006-12-21 22:37:08 UTC (rev 123) @@ -125,7 +125,18 @@ Svn::CommitSummaryFetcher fetcher; QString error; if (fetcher.fetchSummary(*mpContext, mPath, Revision::uncommitted(), true, summary, error)) - mpModificationsModel->showModifications(summary.modifications(), false); + { + // remove unversioned mods + QList<Modification> unversionedMods = summary.modifications(); + QMutableListIterator<Modification> i(unversionedMods); + while (i.hasNext()) + { + if (!Modification::isVersionedType(i.next().getType())) + i.remove(); + } + + mpModificationsModel->showModifications(summary.modifications()); + } else mpModificationsModel->showError(error); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-21 20:44:17 UTC (rev 122) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-21 22:37:08 UTC (rev 123) @@ -277,7 +277,7 @@ void MainWindow::reloadModifications() { // Update immediately for all revisions, then post a background request to refresh uncommitted modifications. - mpModificationsModel->showModifications(mDisplayedCommitSummary.modifications(), true); + mpModificationsModel->showModifications(mDisplayedCommitSummary.modifications()); Revision rev = mDisplayedCommitSummary.getRevision(); if (rev.getType() == Revision::Uncommitted) @@ -319,7 +319,7 @@ void MainWindow::fetchedModifications(QList<Svn::CommitSummary> summaries) { GSVN_ASSERT(summaries.count() == 1); - mpModificationsModel->showModifications(summaries.at(0).modifications(), true); + mpModificationsModel->showModifications(summaries.at(0).modifications()); } void MainWindow::fetchModificationsFailed(QString error) Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 20:44:17 UTC (rev 122) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 22:37:08 UTC (rev 123) @@ -41,23 +41,60 @@ emit layoutChanged(); } -void ModificationsModel::showModifications(QList<Modification> modifications, bool includeUnversionedMods) +void ModificationsModel::showModifications(QList<Modification> modifications) { - mError = QString(); - mAllModifications = modifications; + if (!mError.isEmpty()) + { + mError = QString(); + mAllModifications = modifications; + reset(); + return; + } - // filter unversioned modifications - if (!includeUnversionedMods) + // remove all obsolete modifications + for (int i = mAllModifications.size()-1; i >= 0; i--) { - QMutableListIterator<Modification> i(mAllModifications); - while (i.hasNext()) + bool shouldKeepMod = false; + Q_FOREACH(Modification mod, modifications) { - if (!Modification::isVersionedType(i.next().getType())) - i.remove(); + if (mod.getFilePath() == mAllModifications[i].getFilePath()) + { + shouldKeepMod = true; + break; + } } + + if (!shouldKeepMod) + { + qDebug(tr("remove %1 at %2").arg(mAllModifications.at(i).getFilePath()).arg(i).toAscii()); + beginRemoveRows(QModelIndex(), i, i); + mAllModifications.removeAt(i); + endRemoveRows(); + } } + GSVN_ASSERT(mAllModifications.size() <= modifications.size()); - emit layoutChanged(); + // add new modifications -- NOTE: This assumes that the caller will give modifications + // in a consistent order. Otherwise, selection may be lost. + for (int i = 0; i < modifications.size(); i++) + { + if (i < mAllModifications.size() && mAllModifications[i].getFilePath() == modifications[i].getFilePath()) + { + // update modification if paths match + mAllModifications[i] = modifications[i]; + emit dataChanged(index(i,0), index(i,columnCount())); + } + else + { + qDebug(tr("insert %1 at %2").arg(modifications.at(i).getFilePath()).arg(i).toAscii()); + + // insert new modification + beginInsertRows(QModelIndex(), i, i); + mAllModifications.insert(i, modifications[i]); + endInsertRows(); + } + } + GSVN_ASSERT(mAllModifications.size() == modifications.size()); } bool ModificationsModel::getModificationForRow(int row, Modification& rModification) const This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 20:44:18
|
Revision: 122 http://svn.sourceforge.net/grandmas-svn/?rev=122&view=rev Author: matthiasmiller Date: 2006-12-21 12:44:17 -0800 (Thu, 21 Dec 2006) Log Message: ----------- add an interface to CommitSummaryFetcherThread for synchronous fetches Modified Paths: -------------- trunk/include/svn/commit_summary_thread.h trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary_thread.cpp Modified: trunk/include/svn/commit_summary_thread.h =================================================================== --- trunk/include/svn/commit_summary_thread.h 2006-12-21 19:28:48 UTC (rev 121) +++ trunk/include/svn/commit_summary_thread.h 2006-12-21 20:44:17 UTC (rev 122) @@ -35,8 +35,9 @@ CommitSummaryFetcherThread(); virtual ~CommitSummaryFetcherThread(); - // The caller should connect to the fetchedSummaries signal to receive the results. Any pending requests will be cancelled. - void fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision); + // The caller should connect to the fetchedSummaries signal to receive the results. + void fetchSummariesSync(QString fullRepoPath, Revision startRevision, Revision endRevision); + void fetchSummariesAsync(QString fullRepoPath, Revision startRevision, Revision endRevision); void stop(); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-21 19:28:48 UTC (rev 121) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-21 20:44:17 UTC (rev 122) @@ -271,7 +271,7 @@ } // load committed revisions - mpCommitSummaryThread->fetchSummaries(mPath, Revision::base(), Revision::committed(0)); + mpCommitSummaryThread->fetchSummariesAsync(mPath, Revision::base(), Revision::committed(0)); } void MainWindow::reloadModifications() @@ -281,7 +281,7 @@ Revision rev = mDisplayedCommitSummary.getRevision(); if (rev.getType() == Revision::Uncommitted) - mpModificationsThread->fetchSummaries(mPath, rev, rev); + mpModificationsThread->fetchSummariesAsync(mPath, rev, rev); } void MainWindow::revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected) Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2006-12-21 19:28:48 UTC (rev 121) +++ trunk/src/svn/commit_summary_thread.cpp 2006-12-21 20:44:17 UTC (rev 122) @@ -43,8 +43,30 @@ mpStatus = NULL; } -void CommitSummaryFetcherThread::fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision) +void CommitSummaryFetcherThread::fetchSummariesSync(QString fullRepoPath, Revision startRevision, Revision endRevision) { + // set up SVN context + AprPoolWrapper pool; + SvnAuthenticationUnimpl auth; + SvnOperationContext context(pool.getPool(), *mpStatus, auth); + + // fetch revisions + Svn::CommitSummaryFetcher fetcher; + QList<Svn::CommitSummary> summaries; + QString error; + if (fetcher.fetchSummaries(context, fullRepoPath, startRevision, endRevision, true, summaries, error)) + { + qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); + emit fetchedSummaries(summaries); + } + else + { + emit failed(error); + } +} + +void CommitSummaryFetcherThread::fetchSummariesAsync(QString fullRepoPath, Revision startRevision, Revision endRevision) +{ QMutexLocker locker(&mPendingRequestsMutex); if (mShouldStopRequests) @@ -111,23 +133,6 @@ GSVN_ASSERT(mRequestSemaphore.available() == mPendingRequests.size()); } - // set up SVN context - AprPoolWrapper pool; - SvnAuthenticationUnimpl auth; - SvnOperationContext context(pool.getPool(), *mpStatus, auth); - - // fetch revisions - Svn::CommitSummaryFetcher fetcher; - QList<Svn::CommitSummary> summaries; - QString error; - if (fetcher.fetchSummaries(context, request.mFullRepoPath, request.mStartRevision, request.mEndRevision, true, summaries, error)) - { - qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); - emit fetchedSummaries(summaries); - } - else - { - emit failed(error); - } + fetchSummariesSync(request.mFullRepoPath, request.mStartRevision, request.mEndRevision); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 19:28:49
|
Revision: 121 http://svn.sourceforge.net/grandmas-svn/?rev=121&view=rev Author: matthiasmiller Date: 2006-12-21 11:28:48 -0800 (Thu, 21 Dec 2006) Log Message: ----------- allow the CommitSummaryFetcherThread to queue multiple requests Modified Paths: -------------- trunk/include/svn/commit_summary_thread.h trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary_thread.cpp Modified: trunk/include/svn/commit_summary_thread.h =================================================================== --- trunk/include/svn/commit_summary_thread.h 2006-12-21 18:32:59 UTC (rev 120) +++ trunk/include/svn/commit_summary_thread.h 2006-12-21 19:28:48 UTC (rev 121) @@ -19,6 +19,7 @@ ***************************************************************************/ #include <QMutex> +#include <QSemaphore> #include <QThread> #include "svn/commit_summary.h" @@ -35,9 +36,9 @@ virtual ~CommitSummaryFetcherThread(); // The caller should connect to the fetchedSummaries signal to receive the results. Any pending requests will be cancelled. - void fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision, bool fetchModifications); + void fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision); - void cancel(); + void stop(); signals: void fetchedSummaries(QList<Svn::CommitSummary> summaries); @@ -46,9 +47,11 @@ private: virtual void run(); - struct Parms; + SvnOperationStatusUnimpl* mpStatus; - SvnOperationStatusUnimpl* mpStatus; - QMutex mMutex; - Parms* mpParms; + struct PendingRequest; + QMutex mPendingRequestsMutex; + bool mShouldStopRequests; + QList<PendingRequest> mPendingRequests; + QSemaphore mRequestSemaphore; }; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-21 18:32:59 UTC (rev 120) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-21 19:28:48 UTC (rev 121) @@ -107,11 +107,11 @@ delete mpUi; mpUi = NULL; - mpModificationsThread->cancel(); + mpModificationsThread->stop(); delete mpModificationsThread; mpModificationsThread = NULL; - mpCommitSummaryThread->cancel(); + mpCommitSummaryThread->stop(); delete mpCommitSummaryThread; mpCommitSummaryThread = NULL; @@ -271,7 +271,7 @@ } // load committed revisions - mpCommitSummaryThread->fetchSummaries(mPath, Revision::base(), Revision::committed(0), true); + mpCommitSummaryThread->fetchSummaries(mPath, Revision::base(), Revision::committed(0)); } void MainWindow::reloadModifications() @@ -281,7 +281,7 @@ Revision rev = mDisplayedCommitSummary.getRevision(); if (rev.getType() == Revision::Uncommitted) - mpModificationsThread->fetchSummaries(mPath, rev, rev, true); + mpModificationsThread->fetchSummaries(mPath, rev, rev); } void MainWindow::revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected) Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2006-12-21 18:32:59 UTC (rev 120) +++ trunk/src/svn/commit_summary_thread.cpp 2006-12-21 19:28:48 UTC (rev 121) @@ -24,76 +24,110 @@ #include <QMetaType> -struct CommitSummaryFetcherThread::Parms +struct CommitSummaryFetcherThread::PendingRequest { QString mFullRepoPath; Revision mStartRevision, mEndRevision; - bool mFetchModifications; }; CommitSummaryFetcherThread::CommitSummaryFetcherThread() { mpStatus = new SvnOperationStatusUnimpl; - mpParms = new Parms(); + mShouldStopRequests = false; } CommitSummaryFetcherThread::~CommitSummaryFetcherThread() { - delete mpParms; - mpParms = NULL; - delete mpStatus; mpStatus = NULL; } -void CommitSummaryFetcherThread::fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision, bool fetchModifications) +void CommitSummaryFetcherThread::fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision) { - // cancel any outstanding requests - cancel(); + QMutexLocker locker(&mPendingRequestsMutex); - mMutex.lock(); - mpParms->mFullRepoPath = fullRepoPath; - mpParms->mStartRevision = startRevision; - mpParms->mEndRevision = endRevision; - mpParms->mFetchModifications = fetchModifications; - mMutex.unlock(); + if (mShouldStopRequests) + { + GSVN_ASSERT(false); + return; + } - start(); + // queue the request + PendingRequest request; + request.mFullRepoPath = fullRepoPath; + request.mStartRevision = startRevision; + request.mEndRevision = endRevision; + mPendingRequests.push_back(request); + mRequestSemaphore.release(); + + // NOTE: We cannot assert that the semaphore's resource count matches the array + // size since the worker thread's acquire() call is not guarded by a mutex. + + if (!isRunning()) + start(); } -void CommitSummaryFetcherThread::cancel() +void CommitSummaryFetcherThread::stop() { if (isRunning()) { mpStatus->cancel(); + + // release a resource to force the thread to wake up and exit + mPendingRequestsMutex.lock(); + mShouldStopRequests = true; + mRequestSemaphore.release(); + mPendingRequestsMutex.unlock(); + wait(); } - mpStatus->clear(); } void CommitSummaryFetcherThread::run() { - mMutex.lock(); - Parms parms = *mpParms; - mMutex.unlock(); + QMutex requestArrivalMutex; + for (;;) + { + // wait for a new request to arrive + mRequestSemaphore.acquire(); - // set up SVN context - AprPoolWrapper pool; - SvnAuthenticationUnimpl auth; - SvnOperationContext context(pool.getPool(), *mpStatus, auth); + PendingRequest request; - // fetch revisions - Svn::CommitSummaryFetcher fetcher; - QList<Svn::CommitSummary> summaries; - QString error; - if (fetcher.fetchSummaries(context, parms.mFullRepoPath, parms.mStartRevision, parms.mEndRevision, parms.mFetchModifications, summaries, error)) - { - qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); - emit fetchedSummaries(summaries); + // scope the mutex locker + { + QMutexLocker locker(&mPendingRequestsMutex); + + // The main thread releases a resource to force this worker thread + // to wake up. This is the single situation in which the number of + // resources does not equal the number of pending requests. + if (mShouldStopRequests) + return; + + GSVN_ASSERT(mPendingRequests.size() > 0); + request = mPendingRequests.takeFirst(); + + // This assertion is valid since the release() call is guarded by a mutex. + GSVN_ASSERT(mRequestSemaphore.available() == mPendingRequests.size()); + } + + // set up SVN context + AprPoolWrapper pool; + SvnAuthenticationUnimpl auth; + SvnOperationContext context(pool.getPool(), *mpStatus, auth); + + // fetch revisions + Svn::CommitSummaryFetcher fetcher; + QList<Svn::CommitSummary> summaries; + QString error; + if (fetcher.fetchSummaries(context, request.mFullRepoPath, request.mStartRevision, request.mEndRevision, true, summaries, error)) + { + qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); + emit fetchedSummaries(summaries); + } + else + { + emit failed(error); + } } - else - { - emit failed(error); - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 18:33:09
|
Revision: 120 http://svn.sourceforge.net/grandmas-svn/?rev=120&view=rev Author: matthiasmiller Date: 2006-12-21 10:32:59 -0800 (Thu, 21 Dec 2006) Log Message: ----------- checked/unchecked modifications can now simply be tracked with a single path Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-12-21 17:51:30 UTC (rev 119) +++ trunk/include/dialogs/modificationsmodel.h 2006-12-21 18:32:59 UTC (rev 120) @@ -54,10 +54,8 @@ bool isTypeColumn(int col) const; bool isPathColumn(int col) const; - struct DeclinedMod; - QString mError; QList<Modification> mAllModifications; - QList<DeclinedMod> mDeclinedModifications; + QList<QString> mDeclinedPaths; bool mAllowSelections; }; Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 17:51:30 UTC (rev 119) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 18:32:59 UTC (rev 120) @@ -25,27 +25,6 @@ #include <QSize> -struct ModificationsModel::DeclinedMod -{ - QString mPath; - - bool operator==(const DeclinedMod& other) const - { - return mPath == other.mPath; - } - bool operator!=(const DeclinedMod& other) const - { - return !(*this == other); - } - - static DeclinedMod fromSvnMod(const Modification& mod) - { - DeclinedMod declinedMod = { mod.getFilePath() }; - return declinedMod; - } -}; - - ModificationsModel::ModificationsModel() : mAllowSelections(false) { } @@ -181,7 +160,7 @@ { if (isCheckboxColumn(rcIndex.column())) { - if (mDeclinedModifications.contains(DeclinedMod::fromSvnMod(mod))) + if (mDeclinedPaths.contains(mod.getFilePath())) return Qt::Unchecked; else return Qt::Checked; @@ -198,17 +177,17 @@ if (isCheckboxColumn(rcIndex.column()) && rcValue.canConvert(QVariant::Bool) && rcIndex.isValid() && rcIndex.row() < mAllModifications.size()) { - DeclinedMod mod = DeclinedMod::fromSvnMod(mAllModifications.at(rcIndex.row())); + QString path = mAllModifications.at(rcIndex.row()).getFilePath(); if (rcValue.toBool()) { // remove from list of declined mods - mDeclinedModifications.removeAll(mod); + mDeclinedPaths.removeAll(path); } else { // add to the list of declined modifications - if (!mDeclinedModifications.contains(mod)) - mDeclinedModifications.push_back(mod); + if (!mDeclinedPaths.contains(path)) + mDeclinedPaths.push_back(path); } return true; @@ -242,7 +221,7 @@ QList<Modification> modifications; Q_FOREACH(Modification mod, mAllModifications) { - if (!mDeclinedModifications.contains(DeclinedMod::fromSvnMod(mod))) + if (!mDeclinedPaths.contains(mod.getFilePath())) modifications.push_back(mod); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 17:51:34
|
Revision: 119 http://svn.sourceforge.net/grandmas-svn/?rev=119&view=rev Author: matthiasmiller Date: 2006-12-21 09:51:30 -0800 (Thu, 21 Dec 2006) Log Message: ----------- Don't use constant references to QLists. (They're implicitly shared.) Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/include/settings/userpaths.h trunk/include/svn/commit_summary.h trunk/src/dialogs/modificationsmodel.cpp trunk/src/settings/userpaths.cpp trunk/tests/svn_test.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/include/dialogs/modificationsmodel.h 2006-12-21 17:51:30 UTC (rev 119) @@ -30,7 +30,7 @@ virtual ~ModificationsModel(); void showError(QString error); - void showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods); + void showModifications(QList<Modification> modifications, bool includeUnversionedMods); bool getModificationForRow(int row, Modification& rModification) const; Modified: trunk/include/settings/userpaths.h =================================================================== --- trunk/include/settings/userpaths.h 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/include/settings/userpaths.h 2006-12-21 17:51:30 UTC (rev 119) @@ -45,7 +45,7 @@ bool operator<(const WorkingCopy& rcOther) const; static void load(QSettings* pSettings, QList<WorkingCopy>& rWorkingCopies); - static void save(QSettings* pSettings, const QList<WorkingCopy>& rcWorkingCopies); + static void save(QSettings* pSettings, QList<WorkingCopy> workingCopies); static void sort(QList<WorkingCopy>& rWorkingCopies); private: Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/include/svn/commit_summary.h 2006-12-21 17:51:30 UTC (rev 119) @@ -49,7 +49,7 @@ Revision getRevision() const { return mRevision; } // This function may be called for working copy revision - const QList<Modification>& modifications() const { return mModifications; } + QList<Modification> modifications() const { return mModifications; } protected: friend class CommitSummaryFetcher; Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-12-21 17:51:30 UTC (rev 119) @@ -62,10 +62,10 @@ emit layoutChanged(); } -void ModificationsModel::showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods) +void ModificationsModel::showModifications(QList<Modification> modifications, bool includeUnversionedMods) { mError = QString(); - mAllModifications = rcModifications; + mAllModifications = modifications; // filter unversioned modifications if (!includeUnversionedMods) Modified: trunk/src/settings/userpaths.cpp =================================================================== --- trunk/src/settings/userpaths.cpp 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/src/settings/userpaths.cpp 2006-12-21 17:51:30 UTC (rev 119) @@ -66,13 +66,13 @@ sort(rWorkingCopies); } -void UserPathsModel::WorkingCopy::save(QSettings* pSettings, const QList<WorkingCopy>& rcWorkingCopies) +void UserPathsModel::WorkingCopy::save(QSettings* pSettings, QList<WorkingCopy> workingCopies) { pSettings->beginWriteArray("WorkingCopies"); - for (int wc = 0; wc < rcWorkingCopies.size(); wc++) + for (int wc = 0; wc < workingCopies.size(); wc++) { pSettings->setArrayIndex(wc); - pSettings->setValue("Path", rcWorkingCopies.at(wc).getPath()); + pSettings->setValue("Path", workingCopies.at(wc).getPath()); } pSettings->endArray(); } Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-21 17:47:20 UTC (rev 118) +++ trunk/tests/svn_test.cpp 2006-12-21 17:51:30 UTC (rev 119) @@ -242,7 +242,7 @@ rev = Revision::committed(1); GSVN_VERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, true, summary, rError)); - const QList<Modification>& mods = summary.modifications(); + QList<Modification> mods = summary.modifications(); QCOMPARE(mods.size(), 1); QCOMPARE(mods[0].getFilePath(), QString("/first.txt")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-21 17:47:25
|
Revision: 118 http://svn.sourceforge.net/grandmas-svn/?rev=118&view=rev Author: matthiasmiller Date: 2006-12-21 09:47:20 -0800 (Thu, 21 Dec 2006) Log Message: ----------- CommitSummaryThread now includes the commit summaries when it emits the fetchedSummaries signal. (This is safe because QLists use implicit sharing.) Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/include/svn/commit_summary_thread.h trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary_thread.cpp Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-12-20 23:37:12 UTC (rev 117) +++ trunk/include/dialogs/mainwindow.h 2006-12-21 17:47:20 UTC (rev 118) @@ -56,9 +56,9 @@ void add(); void move(); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); - void fetchedCommittedRevisions(); + void fetchedCommittedRevisions(QList<Svn::CommitSummary> summaries); void fetchCommittedRevisionsFailed(QString error); - void fetchedModifications(); + void fetchedModifications(QList<Svn::CommitSummary> summaries); void fetchModificationsFailed(QString error); private: Modified: trunk/include/svn/commit_summary_thread.h =================================================================== --- trunk/include/svn/commit_summary_thread.h 2006-12-20 23:37:12 UTC (rev 117) +++ trunk/include/svn/commit_summary_thread.h 2006-12-21 17:47:20 UTC (rev 118) @@ -21,10 +21,8 @@ #include <QMutex> #include <QThread> -namespace Svn -{ - class CommitSummary; -}; +#include "svn/commit_summary.h" + class Revision; class SvnOperationStatusUnimpl; @@ -38,12 +36,11 @@ // The caller should connect to the fetchedSummaries signal to receive the results. Any pending requests will be cancelled. void fetchSummaries(QString fullRepoPath, Revision startRevision, Revision endRevision, bool fetchModifications); - void getSummaries(QList<Svn::CommitSummary>& rSummaries); void cancel(); signals: - void fetchedSummaries(); + void fetchedSummaries(QList<Svn::CommitSummary> summaries); void failed(QString error); private: @@ -54,5 +51,4 @@ SvnOperationStatusUnimpl* mpStatus; QMutex mMutex; Parms* mpParms; - QList<Svn::CommitSummary> mSummaries; }; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-12-20 23:37:12 UTC (rev 117) +++ trunk/src/dialogs/mainwindow.cpp 2006-12-21 17:47:20 UTC (rev 118) @@ -47,11 +47,11 @@ mPath = path; mpCommitSummaryThread = new CommitSummaryFetcherThread; - connect(mpCommitSummaryThread, SIGNAL(fetchedSummaries()), this, SLOT(fetchedCommittedRevisions())); + connect(mpCommitSummaryThread, SIGNAL(fetchedSummaries(QList<Svn::CommitSummary>)), this, SLOT(fetchedCommittedRevisions(QList<Svn::CommitSummary>))); connect(mpCommitSummaryThread, SIGNAL(failed(QString)), this, SLOT(fetchCommittedRevisionsFailed(QString))); mpModificationsThread = new CommitSummaryFetcherThread; - connect(mpModificationsThread, SIGNAL(fetchedSummaries()), this, SLOT(fetchedModifications())); + connect(mpModificationsThread, SIGNAL(fetchedSummaries(QList<Svn::CommitSummary>)), this, SLOT(fetchedModifications(QList<Svn::CommitSummary>))); connect(mpModificationsThread, SIGNAL(failed(QString)), this, SLOT(fetchModificationsFailed(QString))); mpUi = new Ui_MainWindow(); @@ -306,10 +306,8 @@ } } -void MainWindow::fetchedCommittedRevisions() +void MainWindow::fetchedCommittedRevisions(QList<Svn::CommitSummary> summaries) { - QList<Svn::CommitSummary> summaries; - mpCommitSummaryThread->getSummaries(summaries); mpRevisionsModel->showCommittedRevisions(summaries); } @@ -318,10 +316,8 @@ qDebug(tr("Unable to fetch commit summaries: %1").arg(error).toAscii()); } -void MainWindow::fetchedModifications() +void MainWindow::fetchedModifications(QList<Svn::CommitSummary> summaries) { - QList<Svn::CommitSummary> summaries; - mpModificationsThread->getSummaries(summaries); GSVN_ASSERT(summaries.count() == 1); mpModificationsModel->showModifications(summaries.at(0).modifications(), true); } Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2006-12-20 23:37:12 UTC (rev 117) +++ trunk/src/svn/commit_summary_thread.cpp 2006-12-21 17:47:20 UTC (rev 118) @@ -22,6 +22,8 @@ #include "svn/commit_summary.h" #include "svn/revision.h" +#include <QMetaType> + struct CommitSummaryFetcherThread::Parms { QString mFullRepoPath; @@ -60,13 +62,6 @@ start(); } -void CommitSummaryFetcherThread::getSummaries(QList<Svn::CommitSummary>& rSummaries) -{ - mMutex.lock(); - rSummaries = mSummaries; - mMutex.unlock(); -} - void CommitSummaryFetcherThread::cancel() { if (isRunning()) @@ -94,11 +89,8 @@ QString error; if (fetcher.fetchSummaries(context, parms.mFullRepoPath, parms.mStartRevision, parms.mEndRevision, parms.mFetchModifications, summaries, error)) { - mMutex.lock(); - mSummaries = summaries; - mMutex.unlock(); - - emit fetchedSummaries(); + qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); + emit fetchedSummaries(summaries); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |