Thread: [Grandmas-svn-commit] SF.net SVN: grandmas-svn: [4] trunk
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2006-05-03 02:51:47
|
Revision: 4 Author: matthiasmiller Date: 2006-05-02 19:51:43 -0700 (Tue, 02 May 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=4&view=rev Log Message: ----------- create mac icons Modified Paths: -------------- trunk/grandmas_svn.pro Added Paths: ----------- trunk/ui/icons/ trunk/ui/icons/mac.icns Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-05-03 02:38:50 UTC (rev 3) +++ trunk/grandmas_svn.pro 2006-05-03 02:51:43 UTC (rev 4) @@ -128,6 +128,8 @@ ui/move.ui \ ui/open.ui +ICON = ui/icons/mac.icns + HEADERS += include/settings/userpaths.h \ include/dialogs/commit.h \ include/dialogs/move.h \ Added: trunk/ui/icons/mac.icns =================================================================== (Binary files differ) Property changes on: trunk/ui/icons/mac.icns ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-05-03 03:44:07
|
Revision: 5 Author: matthiasmiller Date: 2006-05-02 20:43:52 -0700 (Tue, 02 May 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=5&view=rev Log Message: ----------- setting window icons Modified Paths: -------------- trunk/grandmas_svn.pro trunk/ui/commit.ui trunk/ui/mainwindow.ui trunk/ui/move.ui trunk/ui/open.ui Added Paths: ----------- trunk/ui/grandmas-svn.qrc Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-05-03 02:51:43 UTC (rev 4) +++ trunk/grandmas_svn.pro 2006-05-03 03:43:52 UTC (rev 5) @@ -129,6 +129,7 @@ ui/open.ui ICON = ui/icons/mac.icns +RESOURCES = ui/grandmas-svn.qrc HEADERS += include/settings/userpaths.h \ include/dialogs/commit.h \ Modified: trunk/ui/commit.ui =================================================================== --- trunk/ui/commit.ui 2006-05-03 02:51:43 UTC (rev 4) +++ trunk/ui/commit.ui 2006-05-03 03:43:52 UTC (rev 5) @@ -15,6 +15,9 @@ <property name="windowTitle" > <string>Commit</string> </property> + <property name="windowIcon" > + <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> + </property> <layout class="QVBoxLayout" > <property name="margin" > <number>9</number> @@ -112,7 +115,9 @@ <tabstop>okButton</tabstop> <tabstop>cancelButton</tabstop> </tabstops> - <resources/> + <resources> + <include location="grandmas-svn.qrc" /> + </resources> <connections> <connection> <sender>okButton</sender> Added: trunk/ui/grandmas-svn.qrc =================================================================== --- trunk/ui/grandmas-svn.qrc (rev 0) +++ trunk/ui/grandmas-svn.qrc 2006-05-03 03:43:52 UTC (rev 5) @@ -0,0 +1,6 @@ +<RCC> + <qresource prefix="/" > + <file>logo/logo-16x16.png</file> + <file>logo/logo-32x32.png</file> + </qresource> +</RCC> Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-05-03 02:51:43 UTC (rev 4) +++ trunk/ui/mainwindow.ui 2006-05-03 03:43:52 UTC (rev 5) @@ -15,6 +15,9 @@ <property name="windowTitle" > <string>Grandma's SVN</string> </property> + <property name="windowIcon" > + <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> + </property> <widget class="QWidget" name="centralwidget" > <layout class="QVBoxLayout" > <property name="margin" > @@ -325,6 +328,8 @@ <tabstop>updateButton</tabstop> <tabstop>commitButton</tabstop> </tabstops> - <resources/> + <resources> + <include location="grandmas-svn.qrc" /> + </resources> <connections/> </ui> Modified: trunk/ui/move.ui =================================================================== --- trunk/ui/move.ui 2006-05-03 02:51:43 UTC (rev 4) +++ trunk/ui/move.ui 2006-05-03 03:43:52 UTC (rev 5) @@ -15,6 +15,9 @@ <property name="windowTitle" > <string>Move or Rename</string> </property> + <property name="windowIcon" > + <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> + </property> <layout class="QVBoxLayout" > <property name="margin" > <number>9</number> @@ -257,7 +260,9 @@ <tabstop>okButton</tabstop> <tabstop>cancelButton</tabstop> </tabstops> - <resources/> + <resources> + <include location="grandmas-svn.qrc" /> + </resources> <connections> <connection> <sender>okButton</sender> Modified: trunk/ui/open.ui =================================================================== --- trunk/ui/open.ui 2006-05-03 02:51:43 UTC (rev 4) +++ trunk/ui/open.ui 2006-05-03 03:43:52 UTC (rev 5) @@ -15,6 +15,9 @@ <property name="windowTitle" > <string>Open Working Copy</string> </property> + <property name="windowIcon" > + <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> + </property> <layout class="QVBoxLayout" > <property name="margin" > <number>9</number> @@ -92,7 +95,9 @@ <tabstop>cancelButton</tabstop> <tabstop>otherButton</tabstop> </tabstops> - <resources/> + <resources> + <include location="grandmas-svn.qrc" /> + </resources> <connections> <connection> <sender>okButton</sender> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-05-04 04:22:48
|
Revision: 6 Author: matthiasmiller Date: 2006-05-03 21:22:39 -0700 (Wed, 03 May 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=6&view=rev Log Message: ----------- creating icon file for Windows (does not include 16-bit version) Modified Paths: -------------- trunk/grandmas_svn.pro Added Paths: ----------- trunk/ui/icons/win32.ico trunk/ui/icons/win32.rc Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-05-03 03:43:52 UTC (rev 5) +++ trunk/grandmas_svn.pro 2006-05-04 04:22:39 UTC (rev 6) @@ -130,6 +130,7 @@ ICON = ui/icons/mac.icns RESOURCES = ui/grandmas-svn.qrc +RC_FILE = ui/icons/win32.rc HEADERS += include/settings/userpaths.h \ include/dialogs/commit.h \ Added: trunk/ui/icons/win32.ico =================================================================== (Binary files differ) Property changes on: trunk/ui/icons/win32.ico ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/ui/icons/win32.rc =================================================================== --- trunk/ui/icons/win32.rc (rev 0) +++ trunk/ui/icons/win32.rc 2006-05-04 04:22:39 UTC (rev 6) @@ -0,0 +1 @@ + IDI_WIN32_LOGO_ICON ICON DISCARDABLE "win32.ico" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-08-09 01:41:14
|
Revision: 12 Author: highjinx Date: 2006-08-08 18:41:08 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=12&view=rev Log Message: ----------- * Improving the Modifications class * Started adding (untested) unit test for Modifications class Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/include/svn/modification.h trunk/include/svn/server_access.h trunk/src/main.cpp trunk/src/svn/modification.cpp trunk/src/svn/revision.cpp Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/grandmas_svn.kdevelop 2006-08-09 01:41:08 UTC (rev 12) @@ -86,7 +86,7 @@ <directoryradio>executable</directoryradio> </run> <general> - <activedir>src</activedir> + <activedir></activedir> </general> </kdevtrollproject> <workspace> @@ -117,7 +117,7 @@ <LICENSEFILE>COPYING</LICENSEFILE> <VERSION>0.1</VERSION> <YEAR>2006</YEAR> - <dest></dest> + <dest/> </substmap> <kdevcppsupport> <references/> Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/include/svn/modification.h 2006-08-09 01:41:08 UTC (rev 12) @@ -26,6 +26,7 @@ class SvnOperationContext; struct svn_wc_status2_t; struct svn_client_ctx_t; +struct svn_info_t; class Modification { @@ -69,21 +70,77 @@ class Modifications : public SvnOperation { public: + // Public, interfaced functions bool init(SvnOperationContext& rContext, QString path, Revision revision, QString& rError); void getModifications(QList<Modification>& rModifications); - bool uncommittedFileIsConflicted(Modification modification); + protected: + bool getRelativeRepoUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rError); + + QString mWcPath; + Revision mRevision; SvnOperationContext* mpContext; - Revision mRevision; + QString mRelativeRepoUrl; QList<Modification> mModifications; - QList<bool> mModificationIsConflicted; +private: + // Callbacks + static void statusCallback(void *baton, const char *path, svn_wc_status2_t *status); + static svn_error_t* logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool); + static svn_error_t* infoCallback(void *baton, const char *path, const svn_info_t *info, apr_pool_t *pool); +}; + + + +#include <svn/server_access.h> + +#include <svn_repos.h> + +#include <QDir> +#include <QObject> +#include <QtTest/QtTest> + +class NoOperationStatus : public SvnOperationStatus +{ public: - void statusCallback(void *baton, const char *path, svn_wc_status2_t *status); + virtual ~NoOperationStatus() {} + virtual void update(QString textToAdd) { textToAdd=textToAdd; } - svn_error_t* logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool); + virtual bool shouldCancel() { return false; } }; +class NoAuthentication : public SvnAuthentication +{ +protected: + virtual bool getAuthentication(QString& /*rUsername*/, QString& /*rPassword*/) { return false; } +}; +class ModificationsTester : public QObject, SvnOperation +{ + Q_OBJECT + +public: + ModificationsTester(); + ~ModificationsTester(); + +private: + QString getRepoPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo"); } + QString getWcPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc"); } + + bool createRepos(); + bool commitChanges(); + bool addFile(QString relFilePath); + bool touchFile(QString relFilePath, QString fileText); // fails if the file exists + +private slots: + void initTestCase(); + void cleanupTestCase(); + +private: + NoOperationStatus mStatus; + NoAuthentication mAuthentication; + SvnOperationContext* mpContext; + svn_client_ctx_t* mpCtx; +}; Modified: trunk/include/svn/server_access.h =================================================================== --- trunk/include/svn/server_access.h 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/include/svn/server_access.h 2006-08-09 01:41:08 UTC (rev 12) @@ -18,6 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef _SERVER_ACCESS_H +#define _SERVER_ACCESS_H + #include <QString> struct apr_pool_t; @@ -70,3 +73,5 @@ SvnAuthentication* mpAuthentication; }; +#endif + Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/src/main.cpp 2006-08-09 01:41:08 UTC (rev 12) @@ -23,6 +23,7 @@ #include <svn/server_access.h> #include <apr_general.h> +#include <iostream> class QSvnOperationStatus : public SvnOperationStatus @@ -49,6 +50,7 @@ return false; } }; +using namespace std; int main(int argc, char** argv) { @@ -71,10 +73,14 @@ QString error; Revision revision; + //revision.setUncommittedRevision(); revision.setCommittedRevision(5); Modifications mods; - mods.init(context, "/home/joshn/projects/gsvn", revision, error); + if (!mods.init(context, "/home/joshn/projects/gsvn", revision, error)) + { + cout << "Error!: " << (const char*)error.toAscii() << "\n"; + } apr_pool_destroy(pool); Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/src/svn/modification.cpp 2006-08-09 01:41:08 UTC (rev 12) @@ -36,7 +36,7 @@ QString promptPassword; SvnAuthentication* pAuth = ((SvnAuthentication*)baton); if (!pAuth->getAuthentication(promptUsername)) - return svn_error_create(SVN_ERR_CANCELLED, NULL, ""); + return svn_error_create(SVN_ERR_CANCELLED, NULL, ""); svn_auth_cred_simple_t* lcred = (svn_auth_cred_simple_t*)apr_palloc(pool, sizeof (svn_auth_cred_simple_t)); lcred->username = pAuth->getUsername(); @@ -74,59 +74,25 @@ return true; } -svn_opt_revision_t svnRevisionFromRevision(Revision rev) -{ - svn_opt_revision_t svnRev; - svnRev.kind = svn_opt_revision_number; - if (!rev.isCommittedRevision()) - svnRev.value.number = 0; - else - svnRev.value.number = rev.getCommittedRevision(); - return svnRev; -} - -void statusCallback(void *baton, const char *path, svn_wc_status2_t *status) -{ - ((Modifications*)baton)->statusCallback(NULL, path, status); -} - -svn_error_t* logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool) -{ - return ((Modifications*)baton)->logCallback(NULL, changed_paths, revision, author, date, message, pool); -} - -svn_error_t* cancelFunc(void */*baton*/) -{ - cout << "cancel" << endl; - return NULL; -} - -void setUpAuthProviders() -{ -} - bool Modifications::init(SvnOperationContext& rServer, QString path, Revision revision, QString& rError) { rError = ""; mpContext = &rServer; + mWcPath = path; svn_client_ctx_t* ctx; svn_client_create_context(&ctx, rServer.getAprPool()); if (!initAuthProviders(ctx, rServer, rError)) return false; - ctx->notify_func2 = NULL; - ctx->cancel_func = ::cancelFunc; - ctx->cancel_baton = NULL; - ctx->log_msg_func2 = NULL; - ctx->log_msg_func = NULL; - ctx->progress_func = NULL; + if (!getRelativeRepoUrl(rServer, ctx, rError)) + return false; svn_error_t* pError = NULL; if (revision.isCommittedRevision()) { - svn_opt_revision_t startRev = svnRevisionFromRevision(revision); - svn_opt_revision_t endRev = svnRevisionFromRevision(revision); + svn_opt_revision_t startRev = revision.getSvnRevision(); + svn_opt_revision_t endRev = revision.getSvnRevision(); apr_array_header_t *array = apr_array_make(rServer.getAprPool(), 1, sizeof(const char*)); APR_ARRAY_PUSH(array, const char*) = svn_path_canonicalize(path.toAscii(), rServer.getAprPool()); @@ -136,16 +102,16 @@ 0/*limit*/, true/*discover_changed_paths*/, false/*strict_node_history*/, - ::logCallback, + logCallback, this, ctx, rServer.getAprPool()); } else { - svn_opt_revision_t svnRevision = svnRevisionFromRevision(revision); + svn_opt_revision_t svnRevision = revision.getSvnRevision(); pError = svn_client_status2(NULL, path.toAscii(), &svnRevision, - ::statusCallback, + statusCallback, this, true/*recurse*/, false/*get_all*/, @@ -158,7 +124,6 @@ if (pError) { rError = pError->message; - cout << (const char*)rError.toAscii() << endl; return false; } return true; @@ -169,15 +134,12 @@ rModifications = mModifications; } -bool Modifications::uncommittedFileIsConflicted(Modification /*modification*/) +void Modifications::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) { - return false; -} + Modifications* pThis = (Modifications*)baton; -void Modifications::statusCallback(void */*baton*/, const char *path, svn_wc_status2_t *status) -{ Modification mod; - mod.newRevision = mRevision; + mod.newRevision = pThis->mRevision; // Set old revision to base, if the file is already under version control if (status->entry) @@ -187,7 +149,6 @@ { // cases we care about case svn_wc_status_unversioned: - mod.mFilePath = path; mod.mType = Modification::Type_New; break; case svn_wc_status_added: @@ -196,22 +157,18 @@ break; case svn_wc_status_missing: - mod.mFilePath = path; mod.mType = Modification::Type_Missing; break; case svn_wc_status_deleted: - mod.mFilePath = path; mod.mType = Modification::Type_Delete; break; case svn_wc_status_modified: - mod.mFilePath = path; mod.mType = Modification::Type_TextMod; break; case svn_wc_status_conflicted: - mod.mFilePath = path; mod.mType = Modification::Type_Conflicting; break; @@ -231,11 +188,16 @@ break; } - mModifications.append(mod); + mod.mFilePath = path; + if (mod.mFilePath.startsWith(pThis->mWcPath)) + mod.mFilePath.remove(0, pThis->mWcPath.length()); + + pThis->mModifications.append(mod); } -svn_error_t* Modifications::logCallback(void */*baton*/, apr_hash_t *changed_paths, svn_revnum_t revision, const char */*author*/, const char */*date*/, const char */*message*/, apr_pool_t *pool) +svn_error_t* Modifications::logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char */*author*/, const char */*date*/, const char */*message*/, apr_pool_t *pool) { + Modifications* pThis = (Modifications*)baton; for (apr_hash_index_t* pKey = apr_hash_first(pool, changed_paths); pKey; pKey = apr_hash_next(pKey)) { char *path; @@ -244,6 +206,8 @@ Modification mod; mod.mFilePath = path; + + mod.newRevision.setCommittedRevision(revision); mod.oldRevision.setCommittedRevision(revision-1); svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *>(val); @@ -266,9 +230,111 @@ // TODO: return error break; } - mModifications.append(mod); + pThis->mModifications.append(mod); } return NULL; } +svn_error_t* Modifications::infoCallback(void *baton, const char */*path*/, const svn_info_t *info, apr_pool_t */*pool*/) +{ + Modifications* pThis = (Modifications*)baton; + + QString sRootUrl = info->repos_root_URL; + QString sRepoUrl = info->URL; + + if (!sRepoUrl.startsWith(sRootUrl)) + return svn_error_create(SVN_ERR_INCOMPLETE_DATA, NULL, "Invalid repository information."); + + sRepoUrl.remove(0, sRootUrl.length()); + pThis->mRelativeRepoUrl = sRepoUrl; + return NULL; +} + +bool Modifications::getRelativeRepoUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rError) +{ + svn_error_t* pError = svn_client_info(mWcPath.toAscii(), NULL, NULL, infoCallback, this, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = pError->message; + return false; + } + + return true; +} + +ModificationsTester::ModificationsTester() +{ + apr_pool_t* pool; + apr_pool_create(&pool, NULL); + mpContext = new SvnOperationContext(pool, mStatus, mAuthentication); + + svn_client_create_context(&mpCtx, mpContext->getAprPool()); + + QString rIgnoredError; + Q_ASSERT(initAuthProviders(mpCtx, *mpContext, rIgnoredError)); + +} + +ModificationsTester::~ModificationsTester() +{ + apr_pool_destroy(mpContext->getAprPool()); + delete mpContext; +} + +bool ModificationsTester::createRepos() +{ + svn_repos_t* pCreatedRepo; + if (svn_repos_create(&pCreatedRepo, getRepoPath().toAscii(), NULL, NULL, NULL, NULL, mpContext->getAprPool())) + return false; + + svn_opt_revision_t revision; + revision.kind = svn_opt_revision_head; + if (svn_client_checkout2(NULL, QString("file://"+getRepoPath()).toAscii(), getWcPath().toAscii(), &revision, &revision, true, false, mpCtx, mpContext->getAprPool())) + return false; + + return true; +} + +bool ModificationsTester::commitChanges() +{ + return false; +} + +bool ModificationsTester::addFile(QString relFilePath) +{ + relFilePath = relFilePath; + return false; +} + +bool ModificationsTester::touchFile(QString relFilePath, QString fileText) +{ + QFile file(QDir::convertSeparators(getWcPath()+relFilePath)); + if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) + return false; + + QTextStream out(&file); + out << fileText; + if (!file.flush()) + return false; + + return true; +} + +void ModificationsTester::initTestCase() +{ + qDebug("called before everything else"); +} + +void ModificationsTester::cleanupTestCase() +{ + qDebug("called after myFirstTest and mySecondTest"); +} + + + + + + + + Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2006-08-09 00:52:38 UTC (rev 11) +++ trunk/src/svn/revision.cpp 2006-08-09 01:41:08 UTC (rev 12) @@ -19,6 +19,7 @@ ***************************************************************************/ #include <svn/revision.h> +#include <QtDebug> Revision::Revision() { @@ -48,14 +49,23 @@ int Revision::getCommittedRevision() { -// assert(mIsCommitted); + Q_ASSERT(mIsCommitted); return mCommittedRevision; } svn_opt_revision_t Revision::getSvnRevision() { svn_opt_revision_t svnRev; - svnRev.value.number = mCommittedRevision; + if (!isCommittedRevision()) + { + svnRev.kind = svn_opt_revision_working; + svnRev.value.number = 0; + } + else + { + svnRev.kind = svn_opt_revision_number; + svnRev.value.number = getCommittedRevision(); + } return svnRev; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-09-28 03:34:45
|
Revision: 31 http://svn.sourceforge.net/grandmas-svn/?rev=31&view=rev Author: matthiasmiller Date: 2006-09-27 20:34:38 -0700 (Wed, 27 Sep 2006) Log Message: ----------- ModificationsModel: remove obsolete member variables Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-09-28 03:26:28 UTC (rev 30) +++ trunk/include/dialogs/modificationsmodel.h 2006-09-28 03:34:38 UTC (rev 31) @@ -42,9 +42,6 @@ void setAllowSelections(bool allowSelections); private: - SvnOperationContext* mpContext; - QString mPath; - QString mError; QList<Modification> mModifications; }; Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-09-28 03:26:28 UTC (rev 30) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-09-28 03:34:38 UTC (rev 31) @@ -34,7 +34,7 @@ { Modifications mods; QString error; - if (mods.init(*mpContext, mPath, revision, error)) + if (mods.init(*pContext, path, revision, error)) showModifications(mods.modifications()); else showError(error); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-06 18:46:33
|
Revision: 37 http://svn.sourceforge.net/grandmas-svn/?rev=37&view=rev Author: matthiasmiller Date: 2006-10-06 11:46:27 -0700 (Fri, 06 Oct 2006) Log Message: ----------- minor tweaks to svn tests Modified Paths: -------------- trunk/include/svn/commit_summary.h trunk/src/svn/commit_summary.cpp trunk/tests/svn_test.cpp trunk/tests/svn_test.h Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2006-10-06 17:50:54 UTC (rev 36) +++ trunk/include/svn/commit_summary.h 2006-10-06 18:46:27 UTC (rev 37) @@ -33,6 +33,7 @@ class CommitSummary { public: + // Must be passed a working copy path (TODO: support full repo path) bool init(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, QString& rError); // These functions should only be called for committed revisions Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-10-06 17:50:54 UTC (rev 36) +++ trunk/src/svn/commit_summary.cpp 2006-10-06 18:46:27 UTC (rev 37) @@ -37,8 +37,9 @@ if (!Operation::initAuthProviders(ctx, rContext, rError)) return false; - if (!Operation::getRelativeRepoUrl(rContext, fullRepoPath, ctx, mWcPath, rError)) - return false; + // TODO: This isn't working. Figure out why. + //if (!Operation::getRelativeRepoUrl(rContext, fullRepoPath, ctx, mWcPath, rError)) + // return false; svn_error_t* pError = NULL; if (revision.isCommittedRevision()) @@ -120,8 +121,6 @@ pThis->mModifications.append(mod); } - return NULL; - pThis->mAuthor = author; //pThis->mDate = date; pThis->mLogMessage = message; Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-10-06 17:50:54 UTC (rev 36) +++ trunk/tests/svn_test.cpp 2006-10-06 18:46:27 UTC (rev 37) @@ -247,9 +247,9 @@ rev.setCommittedRevision(1); CommitSummary summary; - QVERIFY(summary.init(*mpContext, getRepoPath(), rev, rError)); + QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); - QCOMPARE(summary.getCommitAuthor(), QString("billfrank")); + //QCOMPARE(summary.getCommitAuthor(), QString("billfrank")); // TODO: set when committing //QCOMPARE(summary.getCommitDate(), bogus); // TODO: fill in QCOMPARE(summary.getCommitLogMessage(), QString("first commit")); } Modified: trunk/tests/svn_test.h =================================================================== --- trunk/tests/svn_test.h 2006-10-06 17:50:54 UTC (rev 36) +++ trunk/tests/svn_test.h 2006-10-06 18:46:27 UTC (rev 37) @@ -56,8 +56,8 @@ ~SvnTester(); private: - QString getRepoPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo"); } - QString getWcPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc"); } + QString getRepoPath() { return QDir::cleanPath(QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo")); } + QString getWcPath() { return QDir::cleanPath(QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc")); } bool commitChanges(QString commitMessage); bool addFile(QString relFilePath); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-25 13:57:11
|
Revision: 49 http://svn.sourceforge.net/grandmas-svn/?rev=49&view=rev Author: matthiasmiller Date: 2006-10-25 06:56:57 -0700 (Wed, 25 Oct 2006) Log Message: ----------- add detection for WinMerge Modified Paths: -------------- trunk/grandmas_svn.pro trunk/src/dialogs/mainwindow.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-10-25 12:13:16 UTC (rev 48) +++ trunk/grandmas_svn.pro 2006-10-25 13:56:57 UTC (rev 49) @@ -80,6 +80,8 @@ -lssl \ -lcrypto \ -lrpcrt4 + + LIBS += -lshlwapi } TARGET = bin/grandmas-svn Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-25 12:13:16 UTC (rev 48) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-25 13:56:57 UTC (rev 49) @@ -32,7 +32,58 @@ #include <QProcess> #include <svn_client.h> +#ifdef Q_WS_WIN +#include <shlwapi.h> +namespace +{ + bool assocQueryString(ASSOCF flags, ASSOCSTR str, QString assoc, QString extra, QString& rOut) + { + // wchar_t must be the same size as QChar + enum { assert_at_compile = 1 / (sizeof(wchar_t) == sizeof(QChar) ? 1 : 0) }; + + wchar_t szOut[MAX_PATH]; + DWORD length = sizeof(szOut); + if (FAILED(AssocQueryString(flags, str, (const wchar_t*)assoc.utf16(), + (const wchar_t*)extra.utf16(), szOut, &length))) + { + return false; + } + + rOut = QString::fromUtf16((ushort *)szOut, -1); + return true; + } + + bool getWinAppForExtension(QString ext, QString& rPath) + { + QString path; + if (!assocQueryString(0, ASSOCSTR_EXECUTABLE, "." + ext, "open", path)) + return false; + + if (path.startsWith("\"")) + { + // extract text between quotes + path.remove(0,1); + + int offset = path.indexOf('"', 1); + if (offset == -1) + return false; + path = path.left(offset); + } + else + { + // extract first word + int offset = path.indexOf(' '); + if (offset != -1) + path = path.left(offset); + } + + rPath = path; + return true; + } +} +#endif + MainWindow::MainWindow(SvnOperationContext* pContext, QString path) : mpModificationsModel(NULL) { mpContext = pContext; @@ -149,7 +200,8 @@ // TODO: This should be configurable. QString app; #if defined(Q_WS_WIN) - app = "winmerge"; + if (!getWinAppForExtension("WinMerge", app)) + return false; #elif defined(Q_WS_MAC) app = "opendiff"; #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-26 03:36:15
|
Revision: 58 http://svn.sourceforge.net/grandmas-svn/?rev=58&view=rev Author: matthiasmiller Date: 2006-10-25 20:36:10 -0700 (Wed, 25 Oct 2006) Log Message: ----------- fix icon in main window and show working copy path in title Modified Paths: -------------- trunk/src/dialogs/mainwindow.cpp trunk/ui/mainwindow.ui Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-26 03:23:52 UTC (rev 57) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-26 03:36:10 UTC (rev 58) @@ -28,6 +28,7 @@ #include "svn/revision.h" #include "ui_mainwindow.h" +#include <QDir> #include <QMessageBox> #include <QProcess> #include <svn_client.h> @@ -103,6 +104,8 @@ mpModificationsModel = new ModificationsModel(); mpUi->changesTreeView->setModel(mpModificationsModel); + setWindowTitle(tr("%1 - %2").arg(QDir::convertSeparators(path)).arg(windowTitle())); + reload(); } Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-10-26 03:23:52 UTC (rev 57) +++ trunk/ui/mainwindow.ui 2006-10-26 03:36:10 UTC (rev 58) @@ -13,7 +13,7 @@ <string>Grandma's SVN</string> </property> <property name="windowIcon" > - <iconset/> + <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> </property> <widget class="QWidget" name="centralwidget" > <layout class="QVBoxLayout" > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-26 12:59:25
|
Revision: 59 http://svn.sourceforge.net/grandmas-svn/?rev=59&view=rev Author: matthiasmiller Date: 2006-10-26 05:59:20 -0700 (Thu, 26 Oct 2006) Log Message: ----------- allow multiple items to be diffed at once; slight tweak to commit dialog layout Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/ui/commit.ui trunk/ui/mainwindow.ui Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-26 03:36:10 UTC (rev 58) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-26 12:59:20 UTC (rev 59) @@ -32,7 +32,7 @@ void showError(QString error); void showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods); - Modification getModificationFromIndex(const QModelIndex& rcIndex) const; + Modification getModificationFromIndex(int row) const; virtual int columnCount(const QModelIndex &rcParent = QModelIndex()) const; virtual int rowCount(const QModelIndex& rcParent = QModelIndex()) const; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-26 03:36:10 UTC (rev 58) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-26 12:59:20 UTC (rev 59) @@ -141,32 +141,42 @@ void MainWindow::diff() { - diff(mpUi->changesTreeView->selectionModel()->currentIndex()); -} - -void MainWindow::diff(const QModelIndex& rcIndex) -{ - if (!rcIndex.isValid()) - return; - - // Generate each side of the diff - QString error, leftPath, rightPath; - Modification mod = mpModificationsModel->getModificationFromIndex(rcIndex); - QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); - if (!RepoFileAccess::getDiffFiles(*mpContext, fullFilePath, mod.getOldRevision(), mod.getNewRevision(), leftPath, rightPath, error)) + // determine which rows are selected (remove duplicate rows, since an index is returned for each column) + QModelIndexList selection = mpUi->changesTreeView->selectionModel()->selectedIndexes(); + QSet<int> rows; + Q_FOREACH(QModelIndex index, selection) { - QMessageBox::critical(this, "", error); - return; + if (index.isValid()) + rows.insert(index.row()); } - // Launch the diff - if (!diffFiles(leftPath, rightPath)) + Q_FOREACH(int row, rows) { - QMessageBox::critical(this, tr("The differences could not be displayed."), tr("The comparison program could not be opened.")); - return; + // Generate each side of the diff + QString error, leftPath, rightPath; + Modification mod = mpModificationsModel->getModificationFromIndex(row); + QString fullFilePath = RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath()); + if (!RepoFileAccess::getDiffFiles(*mpContext, fullFilePath, mod.getOldRevision(), mod.getNewRevision(), leftPath, rightPath, error)) + { + QMessageBox::critical(this, "", error); + return; + } + + // Launch the diff + if (!diffFiles(leftPath, rightPath)) + { + QMessageBox::critical(this, tr("The differences could not be displayed."), tr("The comparison program could not be opened.")); + return; + } } } +void MainWindow::diff(const QModelIndex& rcIndex) +{ + Q_UNUSED(rcIndex); + diff(); +} + void MainWindow::move() { MoveDialog dlg(this); Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-26 03:36:10 UTC (rev 58) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-26 12:59:20 UTC (rev 59) @@ -81,21 +81,15 @@ emit layoutChanged(); } -Modification ModificationsModel::getModificationFromIndex(const QModelIndex& rcIndex) const +Modification ModificationsModel::getModificationFromIndex(int row) const { - if (!rcIndex.isValid()) + if (row < 0 || row >= mAllModifications.count()) { GSVN_ASSERT(false); return Modification(); } - - if (rcIndex.row() < 0 || rcIndex.row() >= mAllModifications.count()) - { - GSVN_ASSERT(false); - return Modification(); - } - return mAllModifications.at(rcIndex.row()); + return mAllModifications.at(row); } int ModificationsModel::columnCount(const QModelIndex &rcParent) const Modified: trunk/ui/commit.ui =================================================================== --- trunk/ui/commit.ui 2006-10-26 03:36:10 UTC (rev 58) +++ trunk/ui/commit.ui 2006-10-26 12:59:20 UTC (rev 59) @@ -13,7 +13,7 @@ <string>Commit</string> </property> <property name="windowIcon" > - <iconset resource="grandmas-svn.qrc" >:/logo/logo-32x32.png</iconset> + <iconset/> </property> <layout class="QVBoxLayout" > <property name="margin" > @@ -74,6 +74,13 @@ </widget> </item> <item> + <widget class="QCheckBox" name="updateCheckBox" > + <property name="text" > + <string>&Also update this working copy.</string> + </property> + </widget> + </item> + <item> <layout class="QHBoxLayout" > <property name="margin" > <number>0</number> @@ -82,13 +89,6 @@ <number>6</number> </property> <item> - <widget class="QCheckBox" name="updateCheckBox" > - <property name="text" > - <string>&Also update this working copy.</string> - </property> - </widget> - </item> - <item> <spacer> <property name="orientation" > <enum>Qt::Horizontal</enum> Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-10-26 03:36:10 UTC (rev 58) +++ trunk/ui/mainwindow.ui 2006-10-26 12:59:20 UTC (rev 59) @@ -169,6 +169,9 @@ </item> <item row="2" column="0" > <widget class="QTreeView" name="changesTreeView" > + <property name="selectionMode" > + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> <property name="indentation" > <number>0</number> </property> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-27 04:43:36
|
Revision: 62 http://svn.sourceforge.net/grandmas-svn/?rev=62&view=rev Author: matthiasmiller Date: 2006-10-26 21:43:32 -0700 (Thu, 26 Oct 2006) Log Message: ----------- create skeleton revisions model Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/mainwindow.h trunk/src/dialogs/mainwindow.cpp Added Paths: ----------- trunk/include/dialogs/revisionsmodel.h trunk/src/dialogs/revisionsmodel.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-10-27 04:30:33 UTC (rev 61) +++ trunk/grandmas_svn.pro 2006-10-27 04:43:32 UTC (rev 62) @@ -116,6 +116,7 @@ include/dialogs/modificationsmodel.h \ include/dialogs/move.h \ include/dialogs/open.h \ + include/dialogs/revisionsmodel.h \ include/dialogs/util.h \ include/settings/userpaths.h \ include/svn/commit_summary.h \ @@ -134,6 +135,8 @@ src/dialogs/modificationsmodel.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/dialogs/revisionsmodel.cpp \ + src/dialogs/util.cpp \ src/settings/userpaths.cpp \ src/svn/commit_summary.cpp \ src/svn/file_access.cpp \ @@ -141,7 +144,6 @@ src/svn/operation_internal.cpp \ src/svn/revision.cpp \ src/svn/server_access.cpp \ - src/dialogs/util.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-10-27 04:30:33 UTC (rev 61) +++ trunk/include/dialogs/mainwindow.h 2006-10-27 04:43:32 UTC (rev 62) @@ -25,6 +25,7 @@ #include "svn/revision.h" class ModificationsModel; +class RevisionsModel; class SvnOperationContext; class Ui_MainWindow; class QModelIndex; @@ -55,6 +56,7 @@ QString mPath; ModificationsModel* mpModificationsModel; Revision mDisplayedRevision; + RevisionsModel* mpRevisionsModel; }; #endif Copied: trunk/include/dialogs/revisionsmodel.h (from rev 60, trunk/templates/h) =================================================================== --- trunk/include/dialogs/revisionsmodel.h (rev 0) +++ trunk/include/dialogs/revisionsmodel.h 2006-10-27 04:43:32 UTC (rev 62) @@ -0,0 +1,35 @@ +/*************************************************************************** + * 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 <QAbstractListModel> + +class RevisionsModel : public QAbstractListModel +{ +public: + RevisionsModel(); + virtual ~RevisionsModel(); + + 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; + virtual QVariant data(const QModelIndex& rcIndex, int role = Qt::DisplayRole) const; + +private: +}; + Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-27 04:30:33 UTC (rev 61) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-27 04:43:32 UTC (rev 62) @@ -23,6 +23,7 @@ #include "dialogs/commit.h" #include "dialogs/modificationsmodel.h" #include "dialogs/move.h" +#include "dialogs/revisionsmodel.h" #include "svn/commit_summary.h" #include "svn/file_access.h" #include "svn/revision.h" @@ -104,6 +105,9 @@ mpModificationsModel = new ModificationsModel(); mpUi->changesTreeView->setModel(mpModificationsModel); + + mpRevisionsModel = new RevisionsModel(); + mpUi->revisionsTreeView->setModel(mpRevisionsModel); setWindowTitle(tr("%1 - %2").arg(QDir::convertSeparators(path)).arg(windowTitle())); @@ -112,6 +116,12 @@ MainWindow::~MainWindow() { + // detach revisions model + mpUi->revisionsTreeView->setModel(NULL); + delete mpRevisionsModel; + mpRevisionsModel = NULL; + + // detach modifications model mpUi->changesTreeView->setModel(NULL); delete mpModificationsModel; mpModificationsModel = NULL; Copied: trunk/src/dialogs/revisionsmodel.cpp (from rev 60, trunk/templates/cpp) =================================================================== --- trunk/src/dialogs/revisionsmodel.cpp (rev 0) +++ trunk/src/dialogs/revisionsmodel.cpp 2006-10-27 04:43:32 UTC (rev 62) @@ -0,0 +1,61 @@ +/*************************************************************************** + * 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 "dialogs/revisionsmodel.h" + +RevisionsModel::RevisionsModel() +{ +} + +RevisionsModel::~RevisionsModel() +{ +} + +int RevisionsModel::columnCount(const QModelIndex &rcParent) const +{ + return 4; +} + +int RevisionsModel::rowCount(const QModelIndex& rcParent) const +{ + return 0; +} + +QVariant RevisionsModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role == Qt::DisplayRole) + { + switch (section) + { + case 0: return tr("Revision"); + case 1: return tr("Author"); + case 2: return tr("Date"); + case 3: return tr("Message"); + default: return QVariant(); + } + } + else + return QVariant(); +} + +QVariant RevisionsModel::data(const QModelIndex& rcIndex, int role) const +{ + return QVariant(); +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-10-27 15:01:27
|
Revision: 65 http://svn.sourceforge.net/grandmas-svn/?rev=65&view=rev Author: highjinx Date: 2006-10-27 08:01:19 -0700 (Fri, 27 Oct 2006) Log Message: ----------- Adding ability to fetch multiple commit summaries Modified Paths: -------------- trunk/include/svn/commit_summary.h trunk/include/svn/modification.h trunk/include/svn/revision.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary.cpp trunk/src/svn/revision.cpp trunk/tests/svn_test.cpp Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/include/svn/commit_summary.h 2006-10-27 15:01:19 UTC (rev 65) @@ -18,6 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include "debug.h" + #include <svn/modification.h> #include <svn/revision.h> #include <svn/server_access.h> @@ -29,30 +31,42 @@ struct svn_error_t; struct apr_hash_t; struct svn_wc_status2_t; +class CommitSummaryFetcher; class CommitSummary { public: - // Must be passed a working copy path (TODO: support full repo path) - bool init(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, QString& rError); - // These functions should only be called for committed revisions QString getCommitAuthor() const { return mAuthor; } QDateTime getCommitDate() const { return mDate; } QString getCommitLogMessage() const { return mLogMessage; } + Revision getRevision() const { return mRevision; } // This function may be called for working copy revision const QList<Modification>& modifications() const { return mModifications; } protected: + friend class CommitSummaryFetcher; QString mAuthor; QDateTime mDate; QString mLogMessage; QList<Modification> mModifications; Revision mRevision; +}; + +class CommitSummaryFetcher +{ +public: + // Must be passed a working copy path (TODO: support full repo path) + bool fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, + Revision startRevision, Revision endRevision, + QList<CommitSummary>& rSummaries, QString& rError); + bool fetchSummary(SvnOperationContext& rContext, QString fullRepoPath, + Revision revision, CommitSummary& rSummary, QString& rError); -private: +protected: QString mWcPath; + QList<CommitSummary> mSummaries; private: // Callbacks static svn_error_t* logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool); Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/include/svn/modification.h 2006-10-27 15:01:19 UTC (rev 65) @@ -26,7 +26,7 @@ #include <QString> class SvnOperationContext; -class CommitSummary; +class CommitSummaryFetcher; class Modification { @@ -80,7 +80,7 @@ Revision getNewRevision() const { return mNewRevision; } private: - friend class CommitSummary; + friend class CommitSummaryFetcher; Type mType; QString mFilePath; Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/include/svn/revision.h 2006-10-27 15:01:19 UTC (rev 65) @@ -35,6 +35,7 @@ static Revision committed(int revision) { Revision rev; rev.mType = Committed; rev.mCommittedRevision = revision; return rev; } static Revision base() { Revision rev; rev.mType = Base; rev.mCommittedRevision = 0; return rev; } static Revision head() { Revision rev; rev.mType = Head; rev.mCommittedRevision = 0; return rev; } + static Revision fromSvn(svn_opt_revision_t revision); enum Type { Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/src/dialogs/commit.cpp 2006-10-27 15:01:19 UTC (rev 65) @@ -74,8 +74,9 @@ void CommitDialog::reload() { CommitSummary summary; + CommitSummaryFetcher fetcher; QString error; - if (summary.init(*mpContext, mPath, Revision(), error)) + if (fetcher.fetchSummary(*mpContext, mPath, Revision::uncommitted(), summary, error)) mpModificationsModel->showModifications(summary.modifications(), false); else mpModificationsModel->showError(error); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-27 15:01:19 UTC (rev 65) @@ -200,9 +200,10 @@ void MainWindow::reload() { CommitSummary summary; + CommitSummaryFetcher fetcher; QString error; - if (summary.init(*mpContext, mPath, mDisplayedRevision, error)) - mpModificationsModel->showModifications(summary.modifications(), true); + if (fetcher.fetchSummary(*mpContext, mPath, mDisplayedRevision, summary, error)) + mpModificationsModel->showModifications(summary.modifications(), false); else mpModificationsModel->showError(error); } Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/src/svn/commit_summary.cpp 2006-10-27 15:01:19 UTC (rev 65) @@ -24,11 +24,12 @@ #include <svn_client.h> #include <svn_path.h> -bool CommitSummary::init(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, QString& rError) +bool CommitSummaryFetcher::fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, + Revision startRevision, Revision endRevision, + QList<CommitSummary>& rSummaries, QString& rError) { - mModifications.clear(); + mSummaries.clear(); rError = ""; - mRevision = revision; const char* fullCanonPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); svn_client_ctx_t* ctx; @@ -37,13 +38,13 @@ return false; svn_error_t* pError = NULL; - if (revision.getType() != Revision::Uncommitted) + if (startRevision.getType() != Revision::Uncommitted) { if (!Operation::getRepoCheckoutUrl(rContext, ctx, fullRepoPath, mWcPath, rError)) return false; - svn_opt_revision_t startRev = revision.getSvnRevision(); - svn_opt_revision_t endRev = revision.getSvnRevision(); + svn_opt_revision_t startRev = startRevision.getSvnRevision(); + svn_opt_revision_t endRev = endRevision.getSvnRevision(); apr_array_header_t *array = apr_array_make(rContext.getAprPool(), 1, sizeof(const char*)); APR_ARRAY_PUSH(array, const char*) = fullCanonPath; @@ -62,7 +63,7 @@ { mWcPath = fullRepoPath; - svn_opt_revision_t svnRevision = revision.getSvnRevision(); + svn_opt_revision_t svnRevision = startRevision.getSvnRevision(); pError = svn_client_status2(NULL, fullCanonPath, &svnRevision, statusCallback, this, @@ -79,12 +80,29 @@ rError = pError->message; return false; } + else + { + rSummaries = mSummaries; + } return true; } -svn_error_t* CommitSummary::logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool) +bool CommitSummaryFetcher::fetchSummary(SvnOperationContext& rContext, QString fullRepoPath, + Revision revision, CommitSummary& rSummary, QString& rError) { - CommitSummary* pThis = (CommitSummary*)baton; + QList<CommitSummary> summaries; + if (!fetchSummaries(rContext, fullRepoPath, revision, revision, summaries, rError)) + return false; + + GSVN_ASSERT(summaries.size() == 1); + rSummary = summaries[0]; + return true; +} + +svn_error_t* CommitSummaryFetcher::logCallback(void *baton, apr_hash_t *changed_paths, svn_revnum_t revision, const char *author, const char *date, const char *message, apr_pool_t *pool) +{ + + CommitSummary summary; for (apr_hash_index_t* pKey = apr_hash_first(pool, changed_paths); pKey; pKey = apr_hash_next(pKey)) { char *path; @@ -94,7 +112,6 @@ Modification mod; mod.mFilePath = path; - mod.mNewRevision = Revision::committed(revision); mod.mOldRevision = Revision::committed(revision-1); svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *>(val); @@ -117,29 +134,23 @@ // TODO: return error break; } - pThis->mModifications.append(mod); + summary.mModifications.append(mod); } - pThis->mAuthor = author; - pThis->mDate = QDateTime::fromString(date, Qt::ISODate); - pThis->mLogMessage = message; + summary.mRevision = Revision::committed(revision); + summary.mAuthor = author; + summary.mDate = QDateTime::fromString(date, Qt::ISODate); + summary.mLogMessage = message; + CommitSummaryFetcher* pThis = (CommitSummaryFetcher*)baton; + pThis->mSummaries.append(summary); + return NULL; } -void CommitSummary::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) +void CommitSummaryFetcher::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) { - CommitSummary* pThis = (CommitSummary*)baton; - Modification mod; - mod.mNewRevision = pThis->mRevision; - - // Set old revision to base, if the file is already under version control - if (status->entry) - mod.mOldRevision = Revision::base(); -// else -// mod.mOldRevision = Revision::unknown(); - switch (status->text_status) { // cases we care about @@ -183,9 +194,29 @@ break; } + + CommitSummaryFetcher* pThis = (CommitSummaryFetcher*)baton; + + // Set file path (removing working copy part) + mod.mNewRevision = Revision::uncommitted(); + mod.mFilePath = path; if (mod.mFilePath.startsWith(pThis->mWcPath)) mod.mFilePath.remove(0, pThis->mWcPath.length()); + + // Set old revision to base, if the file is already under version control + if (status->entry) + mod.mOldRevision = Revision::base(); +// else +// mod.mOldRevision = Revision::unknown(); + + // Assume that if we're here (i.e. checking WC status) that we're only retrieving one revision + if (pThis->mSummaries.size() == 0) + { + CommitSummary summary; + pThis->mSummaries.append(summary); + } + GSVN_ASSERT(pThis->mSummaries.size() == 1); - pThis->mModifications.append(mod); + pThis->mSummaries[0].mModifications.append(mod); } Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/src/svn/revision.cpp 2006-10-27 15:01:19 UTC (rev 65) @@ -42,6 +42,27 @@ return mCommittedRevision; } +Revision Revision::fromSvn(svn_opt_revision_t svnRev) +{ + Revision rev; + switch (svnRev.kind) + { + case svn_opt_revision_working: + return uncommitted(); + case svn_opt_revision_number: + return committed(svnRev.value.number); + case svn_opt_revision_base: + return base(); + case svn_opt_revision_head: + return head(); + default: + return uncommitted(); + } + GSVN_ASSERT(false); + return uncommitted(); +} + + svn_opt_revision_t Revision::getSvnRevision() { svn_opt_revision_t svnRev; Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-10-27 14:59:41 UTC (rev 64) +++ trunk/tests/svn_test.cpp 2006-10-27 15:01:19 UTC (rev 65) @@ -194,23 +194,26 @@ void SvnTester::testModifications() { CommitSummary summary; + CommitSummaryFetcher fetcher; QString rError; Revision rev; rev = Revision::committed(1); - QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); + QVERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, summary, rError)); const QList<Modification>& mods = summary.modifications(); QCOMPARE(mods.size(), 1); QCOMPARE(mods[0].getFilePath(), QString("/first.txt")); QCOMPARE(mods[0].getType(), Modification::Type_Add); + QCOMPARE(summary.getRevision(), Revision::committed(1)); rev = Revision::uncommitted(); - QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); + QVERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, summary, rError)); QCOMPARE(mods.size(), 1); QCOMPARE(mods[0].getFilePath(), QString("/second.txt")); QCOMPARE(mods[0].getType(), Modification::Type_Add); + QCOMPARE(summary.getRevision(), Revision::uncommitted()); } void SvnTester::testRepoFileAccess() @@ -247,7 +250,8 @@ rev = Revision::committed(1); CommitSummary summary; - QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); + CommitSummaryFetcher fetcher; + QVERIFY(fetcher.fetchSummary(*mpContext, getWcPath(), rev, summary, rError)); //QCOMPARE(summary.getCommitAuthor(), QString("billfrank")); //QCOMPARE(summary.getCommitDate(), bogus); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-11-04 19:41:30
|
Revision: 83 http://svn.sourceforge.net/grandmas-svn/?rev=83&view=rev Author: matthiasmiller Date: 2006-11-04 11:41:20 -0800 (Sat, 04 Nov 2006) Log Message: ----------- create a progress dialog for Subversion operations with stub code on the update button to test it Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/mainwindow.h trunk/src/dialogs/mainwindow.cpp Added Paths: ----------- trunk/include/dialogs/progress.h trunk/src/dialogs/progress.cpp trunk/ui/progress.ui Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-11-04 19:07:22 UTC (rev 82) +++ trunk/grandmas_svn.pro 2006-11-04 19:41:20 UTC (rev 83) @@ -103,7 +103,8 @@ FORMS += ui/commit.ui \ ui/mainwindow.ui \ ui/move.ui \ - ui/open.ui + ui/open.ui \ + ui/progress.ui \ ICON = ui/icons/mac.icns RESOURCES = ui/grandmas-svn.qrc @@ -116,6 +117,7 @@ include/dialogs/modificationsmodel.h \ include/dialogs/move.h \ include/dialogs/open.h \ + include/dialogs/progress.h \ include/dialogs/revisionsmodel.h \ include/dialogs/util.h \ include/diff.h \ @@ -138,6 +140,7 @@ src/dialogs/modificationsmodel.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/dialogs/progress.cpp \ src/dialogs/revisionsmodel.cpp \ src/dialogs/util.cpp \ src/diff.cpp \ Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-11-04 19:07:22 UTC (rev 82) +++ trunk/include/dialogs/mainwindow.h 2006-11-04 19:41:20 UTC (rev 83) @@ -45,6 +45,7 @@ virtual void changeEvent(QEvent* pEvent); private slots: + void update(); void commit(); void diff(); void diff(const QModelIndex& rcIndex); Copied: trunk/include/dialogs/progress.h (from rev 74, trunk/templates/h) =================================================================== --- trunk/include/dialogs/progress.h (rev 0) +++ trunk/include/dialogs/progress.h 2006-11-04 19:41:20 UTC (rev 83) @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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/server_access.h" + +#include <QDialog> + +class Ui_ProgressDialog; + +class ProgressDialog : public QDialog, public SvnOperationStatus +{ + Q_OBJECT + +public: + ProgressDialog(QWidget* pParent, QString title); + virtual ~ProgressDialog(); + + virtual void update(QString textToAdd); + virtual bool shouldCancel(); + +private slots: + void reject(); + +private: + bool mbShouldCancel; + Ui_ProgressDialog* mpUi; +}; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-11-04 19:07:22 UTC (rev 82) +++ trunk/src/dialogs/mainwindow.cpp 2006-11-04 19:41:20 UTC (rev 83) @@ -23,6 +23,7 @@ #include "dialogs/commit.h" #include "dialogs/modificationsmodel.h" #include "dialogs/move.h" +#include "dialogs/progress.h" #include "dialogs/revisionsmodel.h" #include "diff.h" #include "svn/commit_summary.h" @@ -35,7 +36,6 @@ #include <QHeaderView> #include <QMessageBox> #include <QProcess> -#include <svn_client.h> MainWindow::MainWindow(SvnOperationContext* pContext, QString path) : mpModificationsModel(NULL) { @@ -57,6 +57,7 @@ mpUi->revisionsTreeView->setAllColumnsShowFocus(true); #endif + connect(mpUi->updateButton, SIGNAL(clicked()), this, SLOT(update())); connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); connect(mpUi->changesTreeView, SIGNAL(activated(const QModelIndex&)), this, SLOT(diff(const QModelIndex&))); connect(mpUi->diffButton, SIGNAL(clicked()), this, SLOT(diff())); @@ -117,6 +118,41 @@ } } +void MainWindow::update() +{ + ProgressDialog progress(this, tr("Updating Working Copy")); + QTime timer; + for (int i = 1; i <= 42; i++) + { + progress.update(tr("Checking server %1...").arg(i)); + + timer.restart(); + while (timer.elapsed() < 50) + { + if (progress.shouldCancel()) + { + qDebug("ProgressDialog cancelled."); + return; + } + } + } + + progress.update("Server found!"); + progress.update("Downloading..."); + + timer.restart(); + while (timer.elapsed() < 2000) + { + if (progress.shouldCancel()) + { + qDebug("cancelled"); + return; + } + } + + qDebug("ProgressDialog done."); +} + void MainWindow::commit() { CommitDialog dlg(mpContext, mPath, this); Copied: trunk/src/dialogs/progress.cpp (from rev 74, trunk/templates/cpp) =================================================================== --- trunk/src/dialogs/progress.cpp (rev 0) +++ trunk/src/dialogs/progress.cpp 2006-11-04 19:41:20 UTC (rev 83) @@ -0,0 +1,76 @@ +/*************************************************************************** + * 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 "dialogs/progress.h" +#include "ui_progress.h" + +#include <QTextCursor> + +ProgressDialog::ProgressDialog(QWidget* pParent, QString title) : QDialog(pParent, Qt::Sheet) +{ + mbShouldCancel = false; + + mpUi = new Ui_ProgressDialog; + mpUi->setupUi(this); + + setWindowTitle(title); + mpUi->statusLabel->setText(title); + + show(); +} + +ProgressDialog::~ProgressDialog() +{ + QDialog::reject(); + + delete mpUi; + mpUi = NULL; +} + +void ProgressDialog::update(QString textToAdd) +{ + QApplication::processEvents(); + + if (textToAdd != "") + { + // append the text + QTextEdit* pEdit = mpUi->statusTextEdit; + QString text = pEdit->document()->toPlainText(); + if (text != "") + text += tr("\n"); + text += textToAdd; + pEdit->document()->setPlainText(text); + + // scroll to the bottom + QTextCursor cursor = pEdit->textCursor(); + cursor.movePosition(QTextCursor::End); + pEdit->setTextCursor(cursor); + } +} + +bool ProgressDialog::shouldCancel() +{ + QApplication::processEvents(); + return mbShouldCancel; +} + +void ProgressDialog::reject() +{ + mbShouldCancel = true; +} \ No newline at end of file Added: trunk/ui/progress.ui =================================================================== --- trunk/ui/progress.ui (rev 0) +++ trunk/ui/progress.ui 2006-11-04 19:41:20 UTC (rev 83) @@ -0,0 +1,113 @@ +<ui version="4.0" > + <author></author> + <comment></comment> + <exportmacro></exportmacro> + <class>ProgressDialog</class> + <widget class="QDialog" name="ProgressDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>226</height> + </rect> + </property> + <property name="windowTitle" > + <string>Dialog</string> + </property> + <property name="modal" > + <bool>true</bool> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="statusLabel" > + <property name="text" > + <string>TextLabel</string> + </property> + </widget> + </item> + <item> + <widget class="QTextEdit" name="statusTextEdit" > + <property name="focusPolicy" > + <enum>Qt::NoFocus</enum> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + <property name="acceptRichText" > + <bool>false</bool> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>131</width> + <height>31</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="cancelButton" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" > + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </widget> + <pixmapfunction></pixmapfunction> + <resources/> + <connections> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>ProgressDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>369</x> + <y>253</y> + </hint> + <hint type="destinationlabel" > + <x>179</x> + <y>282</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-11-22 19:28:14
|
Revision: 92 http://svn.sourceforge.net/grandmas-svn/?rev=92&view=rev Author: matthiasmiller Date: 2006-11-22 11:28:14 -0800 (Wed, 22 Nov 2006) Log Message: ----------- tweak interface for ModificationsModel::getSelectedModifications Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-11-22 19:18:58 UTC (rev 91) +++ trunk/include/dialogs/modificationsmodel.h 2006-11-22 19:28:14 UTC (rev 92) @@ -43,7 +43,7 @@ virtual Qt::ItemFlags flags(const QModelIndex& rcIndex) const; void setAllowSelections(bool allowSelections); - void getSelectedModifications(QList<Modification>& rModifications); + QList<Modification> getSelectedModifications() const; bool hasCheckboxColumn() const; int getCheckboxColumn() const; Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-11-22 19:18:58 UTC (rev 91) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-11-22 19:28:14 UTC (rev 92) @@ -236,15 +236,18 @@ mAllowSelections = allowSelections; } -void ModificationsModel::getSelectedModifications(QList<Modification>& rModifications) +QList<Modification> ModificationsModel::getSelectedModifications() const { GSVN_ASSERT(mAllowSelections); - rModifications.clear(); + + QList<Modification> modifications; Q_FOREACH(Modification mod, mAllModifications) { if (!mDeclinedModifications.contains(DeclinedMod::fromSvnMod(mod))) - rModifications.push_back(mod); + modifications.push_back(mod); } + + return modifications; } bool ModificationsModel::hasCheckboxColumn() const This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-11-23 21:40:46
|
Revision: 93 http://svn.sourceforge.net/grandmas-svn/?rev=93&view=rev Author: highjinx Date: 2006-11-23 13:40:44 -0800 (Thu, 23 Nov 2006) Log Message: ----------- Basic commit support. UI is still rough, and needs to start using status callbacks. Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/dialogs/commit.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary.cpp Added Paths: ----------- trunk/include/svn/svn_commit.h trunk/src/svn/svn_commit.cpp Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/grandmas_svn.kdevelop 2006-11-23 21:40:44 UTC (rev 93) @@ -71,7 +71,7 @@ <general> <dbgshell/> <breakpoints/> - <programargs>-t</programargs> + <programargs/> <gdbpath>/usr/bin/</gdbpath> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/grandmas_svn.pro 2006-11-23 21:40:44 UTC (rev 93) @@ -135,6 +135,7 @@ include/svn/revert.h \ include/svn/revision.h \ include/svn/server_access.h \ + include/svn/svn_commit.h \ include/svn/update.h \ src/grandmas_svn.h @@ -161,6 +162,7 @@ src/svn/revert.cpp \ src/svn/revision.cpp \ src/svn/server_access.cpp \ + src/svn/svn_commit.cpp \ src/svn/update.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ Modified: trunk/include/dialogs/commit.h =================================================================== --- trunk/include/dialogs/commit.h 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/include/dialogs/commit.h 2006-11-23 21:40:44 UTC (rev 93) @@ -22,6 +22,7 @@ #ifndef DIALOGS_COMMIT_H_ #define DIALOGS_COMMIT_H_ +#include <Qt> #include <QDialog> class ModificationsModel; @@ -30,19 +31,26 @@ class CommitDialog : public QDialog { + Q_OBJECT + public: - CommitDialog(SvnOperationContext* pContext, QString path, QWidget* pParent); + CommitDialog(SvnOperationContext* pContext, QString commitMessage, QString path, QWidget* pParent); ~CommitDialog(); protected: virtual void changeEvent(QEvent* pEvent); + void commit(bool bUpdate); +private slots: + void commit(); + private: - void reload(); + void reload(); Ui_CommitDialog* mpUi; SvnOperationContext* mpContext; + QString mCommitMessage; QString mPath; ModificationsModel* mpModificationsModel; }; Added: trunk/include/svn/svn_commit.h =================================================================== --- trunk/include/svn/svn_commit.h (rev 0) +++ trunk/include/svn/svn_commit.h 2006-11-23 21:40:44 UTC (rev 93) @@ -0,0 +1,5 @@ + +namespace Svn +{ + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError); +} Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/src/dialogs/commit.cpp 2006-11-23 21:40:44 UTC (rev 93) @@ -22,14 +22,19 @@ #include "dialogs/modificationsmodel.h" #include "dialogs/util.h" #include "svn/commit_summary.h" +#include "svn/file_access.h" #include "svn/revision.h" +#include "svn/svn_commit.h" +#include "svn/update.h" #include "ui_commit.h" #include <QHeaderView> +#include <QMessageBox> -CommitDialog::CommitDialog(SvnOperationContext* pContext, QString path, QWidget* pParent) : QDialog(pParent) +CommitDialog::CommitDialog(SvnOperationContext* pContext, QString commitMessage, QString path, QWidget* pParent) : QDialog(pParent) { mpContext = pContext; + mCommitMessage = commitMessage; mPath = path; mpUi = new Ui_CommitDialog(); @@ -42,6 +47,9 @@ mpModificationsModel->setAllowSelections(true); mpUi->changesTreeView->setModel(mpModificationsModel); mpUi->changesTreeView->header()->setMovable(false); + mpUi->logTextEdit->setPlainText(mCommitMessage); + + connect(mpUi->okButton, SIGNAL(clicked()), this, SLOT(commit())); reload(); @@ -71,6 +79,28 @@ } } + +void CommitDialog::commit() +{ + commit(mpUi->updateCheckBox->isChecked()); +} + +void CommitDialog::commit(bool bUpdate) +{ + QStringList files; + foreach(Modification mod, mpModificationsModel->getSelectedModifications()) + { + files.push_back(RepoFileAccess::getCanonicalPath(*mpContext, mPath, mod.getFilePath())); + } + + QString error; + if (!Svn::commit(*mpContext, mCommitMessage, files, error)) + QMessageBox::critical(this, tr("Commit Error"), error); + + if (bUpdate && !Svn::update(*mpContext, mPath, Revision::head(), error)) + QMessageBox::critical(this, tr("Update Error"), error); +} + void CommitDialog::reload() { CommitSummary summary; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/src/dialogs/mainwindow.cpp 2006-11-23 21:40:44 UTC (rev 93) @@ -144,7 +144,7 @@ void MainWindow::commit() { - CommitDialog dlg(mpContext, mPath, this); + CommitDialog dlg(mpContext, mpUi->logEdit->toPlainText(), mPath, this); dlg.exec(); } Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-11-22 19:28:14 UTC (rev 92) +++ trunk/src/svn/commit_summary.cpp 2006-11-23 21:40:44 UTC (rev 93) @@ -201,7 +201,7 @@ case svn_wc_status_replaced: case svn_wc_status_incomplete: case svn_wc_status_external: - assert(false); + Q_ASSERT(false); break; } Added: trunk/src/svn/svn_commit.cpp =================================================================== --- trunk/src/svn/svn_commit.cpp (rev 0) +++ trunk/src/svn/svn_commit.cpp 2006-11-23 21:40:44 UTC (rev 93) @@ -0,0 +1,90 @@ +/*************************************************************************** + * 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 "dialogs/commit.h" +#include "dialogs/modificationsmodel.h" +#include "dialogs/util.h" +#include "svn/commit_summary.h" +#include "svn/operation.h" +#include "svn/revision.h" +#include "ui_commit.h" + +#include <QHeaderView> + +#include <svn_client.h> + +namespace Svn +{ + class Committer + { + public: + Committer() { mpContext = NULL; } + ~Committer() {} + + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError) + { + mLogMessage = commitMessage; + + svn_client_ctx_t* ctx = NULL; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!Operation::initAuthProviders(rContext, ctx, rError)) + return false; + + ctx->log_msg_func2 = getLogMessage; + ctx->log_msg_baton2 = this; +// ctx->notify_func2 = ; +// ctx->notify_baton2 = this; + + apr_array_header_t *filesArray = apr_array_make(rContext.getAprPool(), 1, sizeof(const char*)); + foreach(QString file, filePaths) + { + APR_ARRAY_PUSH(filesArray, const char*) = file.toAscii(); + } + + svn_commit_info_t* pResultingInfo = NULL; + svn_error_t* pError = svn_client_commit3(&pResultingInfo, filesArray, true, true, ctx, rContext.getAprPool()); + if (pError) + { + rError = pError->message; + return false; + } + + return true; + } + + private: + static svn_error_t* getLogMessage(const char **log_msg, const char **/*tmp_file*/, const apr_array_header_t */*commit_items*/, void *baton, apr_pool_t */*pool*/) + { + Svn::Committer* pThis = (Svn::Committer*)baton; + *log_msg = pThis->mLogMessage.toAscii(); + return NULL; + } + + SvnOperationContext* mpContext; + QString mLogMessage; + }; + + + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError) + { + Svn::Committer comitter; + return comitter.commit(rContext, commitMessage, filePaths, rError); + } +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-12-19 01:47:04
|
Revision: 99 http://svn.sourceforge.net/grandmas-svn/?rev=99&view=rev Author: matthiasmiller Date: 2006-12-18 17:47:04 -0800 (Mon, 18 Dec 2006) Log Message: ----------- fix several warnings in vc2005 and delete obsolete script Modified Paths: -------------- trunk/src/svn/operation.cpp trunk/src/svn/svn_commit.cpp trunk/src/svn/update.cpp trunk/tests/svn_test.cpp Removed Paths: ------------- trunk/mingw-install.sh Deleted: trunk/mingw-install.sh =================================================================== --- trunk/mingw-install.sh 2006-12-19 01:38:39 UTC (rev 98) +++ trunk/mingw-install.sh 2006-12-19 01:47:04 UTC (rev 99) @@ -1,80 +0,0 @@ -#!/bin/sh - -# This script is used to create a MinGW build environment for the Subversion libraries. - -DOWNLOAD_DIR="/tmp/svn-mingw-installer" - -SF_MIRROR='internap' -SF_MIRROR='superb-east' -SF_MIRROR='kent' - -MINGW_PACKAGES=' - gcc-core-3.4.5-20060117-1.tar.gz - gcc-g++-3.4.5-20060117-1.tar.gz - w32api-3.7.tar.gz - mingw-runtime-3.9.tar.gz - binutils-2.16.91-20060119-1.tar.gz - ' - -MSYS_PACKAGES=' - msys-autoconf-2.59.tar.bz2 - msys-automake-1.8.2.tar.bz2 - msys-libtool-1.5.tar.bz2 - ' - -if test "no$WGET" = "no"; then - echo "Please set the WGET environment variable." - echo "For example:" - echo " WGET=wget.exe sh mingw-install.sh" - exit 1 -fi -if ! [ -d $DOWNLOAD_DIR ] && ! mkdir $DOWNLOAD_DIR; then - echo "The download directory could not be created: $DOWNLOAD_DIR"; - exit 1 -fi - -# DOWNLOAD MINGW -# -for PACKAGE in $MINGW_PACKAGES $MSYS_PACKAGES; do - URL=http://$SF_MIRROR.dl.sourceforge.net/sourceforge/mingw/$PACKAGE - if ! $WGET --continue --output-document=$DOWNLOAD_DIR/$PACKAGE $URL; then - echo "Could not download $PACKAGE" - exit 1 - fi -done -echo "All files successfully downloaded." - - -# INSTALL MINGW -# -extract_package() { - PACKAGE=$1 - TARGET_DIR=$2 - - echo "Extracting $PACKAGE into $TARGET_DIR" - if (echo $PACKAGE | grep '.tar.gz') > /dev/null; then - TAR_FLAG="z" - elif (echo $PACKAGE | grep '.tar.bz2') > /dev/null; then - TAR_FLAG="j" - else - echo "Unrecognized file type: $PACKAGE" - exit 1 - fi - - if ! tar -${TAR_FLAG}xf $DOWNLOAD_DIR/$PACKAGE -C$TARGET_DIR; then - echo "Could not extract $PACKAGE" - exit 1 - fi -} - -for PACKAGE in $MSYS_PACKAGES; -do - extract_package $PACKAGE / -done - -for PACKAGE in $MINGW_PACKAGES -do - extract_package $PACKAGE /mingw/ -done - -echo "All files successfully installed." Modified: trunk/src/svn/operation.cpp =================================================================== --- trunk/src/svn/operation.cpp 2006-12-19 01:38:39 UTC (rev 98) +++ trunk/src/svn/operation.cpp 2006-12-19 01:47:04 UTC (rev 99) @@ -27,7 +27,7 @@ #include <QString> -svn_error_t* simpleAuthPrompt(svn_auth_cred_simple_t **cred, void *baton, const char */*realm*/, const char *username, svn_boolean_t /*_may_save*/, apr_pool_t *pool) +svn_error_t* simpleAuthPrompt(svn_auth_cred_simple_t **cred, void *baton, const char * /*realm*/, const char *username, svn_boolean_t /*_may_save*/, apr_pool_t *pool) { QString promptUsername = username; QString promptPassword; @@ -98,7 +98,7 @@ } protected: - static svn_error_t* infoCallback(void *baton, const char */*path*/, const svn_info_t *info, apr_pool_t */*pool*/) + static svn_error_t* infoCallback(void *baton, const char * /*path*/, const svn_info_t *info, apr_pool_t * /*pool*/) { SvnInfo* pThis = (SvnInfo*)baton; Modified: trunk/src/svn/svn_commit.cpp =================================================================== --- trunk/src/svn/svn_commit.cpp 2006-12-19 01:38:39 UTC (rev 98) +++ trunk/src/svn/svn_commit.cpp 2006-12-19 01:47:04 UTC (rev 99) @@ -73,14 +73,14 @@ } private: - static svn_error_t* getLogMessage(const char **log_msg, const char **/*tmp_file*/, const apr_array_header_t */*commit_items*/, void *baton, apr_pool_t */*pool*/) + static svn_error_t* getLogMessage(const char **log_msg, const char ** /*tmp_file*/, const apr_array_header_t * /*commit_items*/, void *baton, apr_pool_t * /*pool*/) { Svn::Committer* pThis = (Svn::Committer*)baton; *log_msg = pThis->mLogMessage.toAscii(); return NULL; } - static void updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t */*pool*/) + static void updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t * /*pool*/) { Svn::Committer* pThis = (Svn::Committer*)baton; pThis->mpContext->getStatus()->update(QObject::tr("Committing %1...").arg(notify->path)); Modified: trunk/src/svn/update.cpp =================================================================== --- trunk/src/svn/update.cpp 2006-12-19 01:38:39 UTC (rev 98) +++ trunk/src/svn/update.cpp 2006-12-19 01:47:04 UTC (rev 99) @@ -72,7 +72,7 @@ return true; } -void Svn::Updater::updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t */*pool*/) +void Svn::Updater::updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t * /*pool*/) { Svn::Updater* pThis = (Svn::Updater*)baton; pThis->mpContext->getStatus()->update(QObject::tr("Updating %1...").arg(notify->path)); Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-19 01:38:39 UTC (rev 98) +++ trunk/tests/svn_test.cpp 2006-12-19 01:47:04 UTC (rev 99) @@ -181,7 +181,7 @@ } -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*/) +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*/) { SvnTester* pThis = (SvnTester*)baton; Q_ASSERT(pThis->mCurrentCommitMsg != ""); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-12-19 16:57:47
|
Revision: 108 http://svn.sourceforge.net/grandmas-svn/?rev=108&view=rev Author: highjinx Date: 2006-12-19 08:57:47 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Fix commit messages Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/src/svn/commit_summary.cpp trunk/src/svn/svn_commit.cpp Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2006-12-19 16:13:55 UTC (rev 107) +++ trunk/grandmas_svn.kdevelop 2006-12-19 16:57:47 UTC (rev 108) @@ -89,7 +89,7 @@ </kdevdebugger> <kdevtrollproject> <run> - <mainprogram>bin/grandmas-svn</mainprogram> + <mainprogram>bin/debug/grandmas-svn</mainprogram> <programargs>-t</programargs> <directoryradio>build</directoryradio> <customdirectory>/</customdirectory> Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-12-19 16:13:55 UTC (rev 107) +++ trunk/src/svn/commit_summary.cpp 2006-12-19 16:57:47 UTC (rev 108) @@ -201,7 +201,6 @@ case svn_wc_status_replaced: case svn_wc_status_incomplete: case svn_wc_status_external: - Q_ASSERT(false); return; } Modified: trunk/src/svn/svn_commit.cpp =================================================================== --- trunk/src/svn/svn_commit.cpp 2006-12-19 16:13:55 UTC (rev 107) +++ trunk/src/svn/svn_commit.cpp 2006-12-19 16:57:47 UTC (rev 108) @@ -77,7 +77,7 @@ static svn_error_t* getLogMessage(const char **log_msg, const char ** /*tmp_file*/, const apr_array_header_t * /*commit_items*/, void *baton, apr_pool_t * /*pool*/) { Svn::Committer* pThis = (Svn::Committer*)baton; - *log_msg = pThis->mLogMessage.toAscii(); + *log_msg = apr_pstrdup(pThis->mpContext->getAprPool(), pThis->mLogMessage.toAscii()); return NULL; } 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 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-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 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 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: <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 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: <hig...@us...> - 2007-01-12 17:26:51
|
Revision: 147 http://svn.sourceforge.net/grandmas-svn/?rev=147&view=rev Author: highjinx Date: 2007-01-12 09:26:51 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Add interface to save commit log message Modified Paths: -------------- trunk/include/svn/commit_summary.h trunk/include/svn/helpers.h trunk/src/svn/commit_summary.cpp trunk/src/svn/helpers.cpp trunk/tests/svn_test.cpp trunk/tests/svn_test.h Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/include/svn/commit_summary.h 2007-01-12 17:26:51 UTC (rev 147) @@ -51,6 +51,10 @@ // This function may be called for working copy revision QList<Modification> modifications() const { return mModifications; } + static bool SaveUncommittedLogMessage(QString fullRepoPath, QString message); + static bool LoadUncommittedLogMessage(QString fullRepoPath, QString& rMessage); + static bool RemoveUncommittedLogMessage(QString fullRepoPath); + protected: friend class CommitSummaryFetcher; QString mAuthor; @@ -64,9 +68,10 @@ { public: // Must be passed a working copy path (TODO: support full repo path) + // iLimitToNumRevisions may be -1, to indicate no limit bool fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, - Revision startRevision, Revision endRevision, bool fetchModifications, - QList<CommitSummary>& rSummaries, QString& rError); + Revision startRevision, Revision endRevision, int iLimitToNumRevisions, + bool fetchModifications, QList<CommitSummary>& rSummaries, QString& rError); bool fetchSummary(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, bool fetchModifications, CommitSummary& rSummary, QString& rError); Modified: trunk/include/svn/helpers.h =================================================================== --- trunk/include/svn/helpers.h 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/include/svn/helpers.h 2007-01-12 17:26:51 UTC (rev 147) @@ -33,4 +33,6 @@ bool removePrefixNoCase(QString& rString, QString prefix); bool addSuffixUnlessExists(QString& rString, QString suffix); + + bool removeDirectory(QString dirPath); }; Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/src/svn/commit_summary.cpp 2007-01-12 17:26:51 UTC (rev 147) @@ -25,10 +25,42 @@ #include <svn_client.h> #include <svn_path.h> +#include <QDir> +#include <QFile> #include <QStringList> +#include <QTextStream> using namespace Svn; + +bool Svn::CommitSummary::SaveUncommittedLogMessage(QString fullRepoPath, QString message) +{ + QFile file(QDir::convertSeparators(fullRepoPath+"/svn-commit.tmp")); + if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) + return false; + + QTextStream messageWriter(&file); + messageWriter << message; + return file.error() == QFile::NoError; +} + +bool Svn::CommitSummary::LoadUncommittedLogMessage(QString fullRepoPath, QString& rMessage) +{ + QFile file(QDir::convertSeparators(fullRepoPath+"/svn-commit.tmp")); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return false; + + QTextStream messageReader(&file); + rMessage = messageReader.readAll(); + return file.error() == QFile::NoError; +} + +bool Svn::CommitSummary::RemoveUncommittedLogMessage(QString fullRepoPath) +{ + QFile file(QDir::convertSeparators(fullRepoPath+"/svn-commit.tmp")); + return file.remove(); +} + bool Svn::CommitSummaryFetcher::fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, Revision startRevision, Revision endRevision, bool fetchModifications, QList<CommitSummary>& rSummaries, QString& rError) Modified: trunk/src/svn/helpers.cpp =================================================================== --- trunk/src/svn/helpers.cpp 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/src/svn/helpers.cpp 2007-01-12 17:26:51 UTC (rev 147) @@ -20,6 +20,7 @@ #include "svn/helpers.h" +#include <QDir> #include <QString> #include <QStringList> @@ -31,6 +32,32 @@ using namespace Svn; + +namespace +{ + bool clearReadOnlyFlag(QFileInfo file) + { +#ifdef Q_WS_WIN + const wchar_t* path = (const wchar_t*)file.absoluteFilePath().utf16(); + DWORD dwAttr = ::GetFileAttributes(path); + if (dwAttr == (DWORD)~0) + return false; + + if ((dwAttr & FILE_ATTRIBUTE_READONLY) != 0) + { + dwAttr &= ~FILE_ATTRIBUTE_READONLY; + if (!::SetFileAttributes(path, dwAttr)) + return false; + } + + return true; +#else + Q_UNUSED(file); + return false; //unimpl +#endif + } +} + apr_array_header_t* Svn::aprArrayFromQStringList(const QStringList& rList, apr_pool_t* pPool) { apr_array_header_t* array = apr_array_make(pPool, rList.size(), sizeof(const char*)); @@ -77,3 +104,27 @@ return false; } +bool Svn::removeDirectory(QString dirPath) +{ + QDir dir(dirPath); + QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::Hidden|QDir::System|QDir::AllDirs|QDir::Files); + foreach(QFileInfo entry, entries) + { + if (entry.isDir()) + { + if (!removeDirectory(entry.absoluteFilePath())) + return false; + } + else + { + clearReadOnlyFlag(entry); + if (!QFile::remove(entry.absoluteFilePath())) + return false; + } + } + if (dir.exists() && !dir.rmdir(dirPath)) + return false; + + return true; +} + Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/tests/svn_test.cpp 2007-01-12 17:26:51 UTC (rev 147) @@ -22,9 +22,10 @@ #include "svn/add.h" #include "svn/svn_commit.h" -#include <svn/commit_summary.h> -#include <svn/file_access.h> -#include <svn/modification.h> +#include "svn/commit_summary.h" +#include "svn/file_access.h" +#include "svn/helpers.h" +#include "svn/modification.h" #include "svn/operation.h" #include <svn_client.h> @@ -57,31 +58,7 @@ } while (0) -namespace -{ - bool clearReadOnlyFlag(QFileInfo file) - { -#ifdef Q_WS_WIN - const wchar_t* path = (const wchar_t*)file.absoluteFilePath().utf16(); - DWORD dwAttr = ::GetFileAttributes(path); - if (dwAttr == (DWORD)~0) - return false; - if ((dwAttr & FILE_ATTRIBUTE_READONLY) != 0) - { - dwAttr &= ~FILE_ATTRIBUTE_READONLY; - if (!::SetFileAttributes(path, dwAttr)) - return false; - } - - return true; -#else - Q_UNUSED(file); - return false; //unimpl -#endif - } -} - SvnTester::SvnTester() { apr_pool_t* pool; @@ -114,29 +91,6 @@ return true; } -bool SvnTester::removeDirectory(QString filePath) -{ - QDir dir(filePath); - QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::Hidden|QDir::System|QDir::AllDirs|QDir::Files); - foreach(QFileInfo entry, entries) - { - if (entry.isDir()) - { - if (!removeDirectory(entry.absoluteFilePath())) - return false; - } - else - { - clearReadOnlyFlag(entry); - if (!QFile::remove(entry.absoluteFilePath())) - return false; - } - } - if (dir.exists() && !dir.rmdir(filePath)) - return false; - - return true; -} QString SvnTester::getFileContents(QString filePath) { @@ -186,8 +140,8 @@ void SvnTester::cleanup() { - QVERIFY(removeDirectory(getRepoPath())); - QVERIFY(removeDirectory(getWcPath())); + QVERIFY(Svn::removeDirectory(getRepoPath())); + QVERIFY(Svn::removeDirectory(getWcPath())); } void SvnTester::assertModsMatch(QString wcPath, Revision rev, QList<Modification> mods) Modified: trunk/tests/svn_test.h =================================================================== --- trunk/tests/svn_test.h 2006-12-29 15:16:22 UTC (rev 146) +++ trunk/tests/svn_test.h 2007-01-12 17:26:51 UTC (rev 147) @@ -61,7 +61,6 @@ bool touchFile(QString relFilePath, QString fileText); // fails if the file exists - bool removeDirectory(QString filePath); QString getFileContents(QString filePath); void createRepoAndWc(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2007-01-12 17:31:31
|
Revision: 148 http://svn.sourceforge.net/grandmas-svn/?rev=148&view=rev Author: highjinx Date: 2007-01-12 09:31:28 -0800 (Fri, 12 Jan 2007) Log Message: ----------- Adding interface to limit number of returned commit summaries Modified Paths: -------------- trunk/include/svn/commit_summary.h trunk/src/svn/commit_summary.cpp trunk/src/svn/commit_summary_thread.cpp trunk/src/svn/file_access.cpp Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2007-01-12 17:26:51 UTC (rev 147) +++ trunk/include/svn/commit_summary.h 2007-01-12 17:31:28 UTC (rev 148) @@ -68,7 +68,7 @@ { public: // Must be passed a working copy path (TODO: support full repo path) - // iLimitToNumRevisions may be -1, to indicate no limit + // iLimitToNumRevisions may be 0, to indicate no limit bool fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, Revision startRevision, Revision endRevision, int iLimitToNumRevisions, bool fetchModifications, QList<CommitSummary>& rSummaries, QString& rError); Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2007-01-12 17:26:51 UTC (rev 147) +++ trunk/src/svn/commit_summary.cpp 2007-01-12 17:31:28 UTC (rev 148) @@ -62,11 +62,14 @@ } bool Svn::CommitSummaryFetcher::fetchSummaries(SvnOperationContext& rContext, QString fullRepoPath, - Revision startRevision, Revision endRevision, bool fetchModifications, - QList<CommitSummary>& rSummaries, QString& rError) + Revision startRevision, Revision endRevision, int iLimitToNumRevisions, + bool fetchModifications, QList<CommitSummary>& rSummaries, QString& rError) { mSummaries.clear(); rError = ""; + + Q_ASSERT(iLimitToNumRevisions >= 0); + const char* svnPath = svn_path_internal_style(fullRepoPath.toAscii(), rContext.getAprPool()); const char* fullCanonPath = svn_path_canonicalize(svnPath, rContext.getAprPool()); @@ -89,7 +92,7 @@ pError = svn_client_log2(array, &startRev, &endRev, - 0/*limit*/, + iLimitToNumRevisions/*limit*/, fetchModifications/*discover_changed_paths*/, false/*strict_node_history*/, logCallback, @@ -139,7 +142,7 @@ Revision revision, bool fetchModifications, CommitSummary& rSummary, QString& rError) { QList<CommitSummary> summaries; - if (!fetchSummaries(rContext, fullRepoPath, revision, revision, fetchModifications, summaries, rError)) + if (!fetchSummaries(rContext, fullRepoPath, revision, revision, -1, fetchModifications, summaries, rError)) return false; GSVN_ASSERT(summaries.size() == 1); Modified: trunk/src/svn/commit_summary_thread.cpp =================================================================== --- trunk/src/svn/commit_summary_thread.cpp 2007-01-12 17:26:51 UTC (rev 147) +++ trunk/src/svn/commit_summary_thread.cpp 2007-01-12 17:31:28 UTC (rev 148) @@ -54,7 +54,7 @@ Svn::CommitSummaryFetcher fetcher; QList<Svn::CommitSummary> summaries; QString error; - if (fetcher.fetchSummaries(context, fullRepoPath, startRevision, endRevision, true, summaries, error)) + if (fetcher.fetchSummaries(context, fullRepoPath, startRevision, endRevision, true, -1, summaries, error)) { qRegisterMetaType<QList<Svn::CommitSummary> >("QList<Svn::CommitSummary>"); emit fetchedSummaries(fullRepoPath, summaries); Modified: trunk/src/svn/file_access.cpp =================================================================== --- trunk/src/svn/file_access.cpp 2007-01-12 17:26:51 UTC (rev 147) +++ trunk/src/svn/file_access.cpp 2007-01-12 17:31:28 UTC (rev 148) @@ -31,7 +31,7 @@ namespace { - bool getRandomFilePath(QString dirPath, QString filePrefix, QString fileExtension, QString& rFilePath, SvnOperationContext& rContext) + bool getRandomFilePath(QString dirPath, QString filePrefix, QString fileExtension, QString& rFilePath) { QString randString; while (true) @@ -60,7 +60,7 @@ // this user to be able to read and write to the file QFileInfo info(fullRepoPath); apr_file_t* pAprFile = NULL; - if (!getRandomFilePath(QDir::tempPath(), info.baseName(), info.completeSuffix(), rCreatedFilePath, rContext) || + if (!getRandomFilePath(QDir::tempPath(), info.baseName(), info.completeSuffix(), rCreatedFilePath) || apr_file_open(&pAprFile, rCreatedFilePath.toAscii(), APR_WRITE | APR_CREATE | APR_TRUNCATE | APR_BINARY, APR_OS_DEFAULT, rContext.getAprPool())) { rError = "Unable to create temporary file."; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |