Thread: [Grandmas-svn-commit] SF.net SVN: grandmas-svn: [152] trunk (Page 2)
Brought to you by:
matthiasmiller
From: <hig...@us...> - 2007-01-13 20:00:34
|
Revision: 152 http://svn.sourceforge.net/grandmas-svn/?rev=152&view=rev Author: highjinx Date: 2007-01-13 12:00:32 -0800 (Sat, 13 Jan 2007) Log Message: ----------- * Save commit log if the commit fails * Connect the "Cleanup" menu action to the actual functionality Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/ui/mainwindow.ui Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2007-01-13 18:39:40 UTC (rev 151) +++ trunk/include/dialogs/mainwindow.h 2007-01-13 20:00:32 UTC (rev 152) @@ -48,14 +48,16 @@ virtual void changeEvent(QEvent* pEvent); private slots: - void update(); + void add(); + void cleanup(); void commit(); void diff(); void diff(const QModelIndex& rcIndex); + void move(); + void remove(); void revert(); - void add(); - void remove(); - void move(); + void update(); + void modificationSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); void afterCommitSummaryAdded(Revision rev); Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2007-01-13 18:39:40 UTC (rev 151) +++ trunk/src/dialogs/commit.cpp 2007-01-13 20:00:32 UTC (rev 152) @@ -110,18 +110,21 @@ { QMessageBox::critical(this, tr("Update Error"), error); reject(); + return; } if (!Svn::commit(*mpContext, mCommitMessage, files, error)) { QMessageBox::critical(this, tr("Commit Error"), error); reject(); + return; } if (bUpdate && !Svn::update(*mpContext, mPath, Revision::head(), error)) { QMessageBox::critical(this, tr("Update Error"), error); reject(); + return; } accept(); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2007-01-13 18:39:40 UTC (rev 151) +++ trunk/src/dialogs/mainwindow.cpp 2007-01-13 20:00:32 UTC (rev 152) @@ -151,6 +151,13 @@ reloadCommittedSummaries(); } +void MainWindow::cleanup() +{ + QString error; + if (!Svn::cleanup(*mpContext, mPath, error)) + QMessageBox::critical(this, "", error); +} + void MainWindow::commit() { CommitDialog dlg(mpContext, mpUi->logEdit->toPlainText(), mPath, this); Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2007-01-13 18:39:40 UTC (rev 151) +++ trunk/ui/mainwindow.ui 2007-01-13 20:00:32 UTC (rev 152) @@ -404,6 +404,22 @@ <y>285</y> </hint> </hints> +</connection> +<connection> + <sender>action_Cleanup</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>cleanup()</slot> + <hints> + <hint type="sourcelabel" > + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel" > + <x>323</x> + <y>301</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: <hig...@us...> - 2007-01-13 17:49:05
|
Revision: 150 http://svn.sourceforge.net/grandmas-svn/?rev=150&view=rev Author: highjinx Date: 2007-01-13 09:49:02 -0800 (Sat, 13 Jan 2007) Log Message: ----------- * Add delete functionality * Consolidate a bunch of little svn operation files into two files, wc_operations and wc_info Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/dialogs/mainwindow.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/svn/commit_summary.cpp trunk/src/svn/file_access.cpp trunk/src/svn/svn_commit.cpp trunk/tests/svn_test.cpp trunk/ui/mainwindow.ui Added Paths: ----------- trunk/include/svn/operations.h trunk/include/svn/wc_info.h trunk/include/svn/wc_operations.h trunk/src/svn/wc_info.cpp trunk/src/svn/wc_operations.cpp Removed Paths: ------------- trunk/include/svn/add.h trunk/include/svn/delete.h trunk/include/svn/operation.h trunk/include/svn/revert.h trunk/include/svn/svn_commit.h trunk/include/svn/update.h trunk/src/svn/add.cpp trunk/src/svn/delete.cpp trunk/src/svn/operation.cpp trunk/src/svn/operation_internal.cpp trunk/src/svn/revert.cpp trunk/src/svn/update.cpp Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/grandmas_svn.kdevelop 2007-01-13 17:49:02 UTC (rev 150) @@ -90,7 +90,7 @@ <kdevtrollproject> <run> <mainprogram>bin/debug/grandmas-svn</mainprogram> - <programargs>-t</programargs> + <programargs></programargs> <directoryradio>build</directoryradio> <customdirectory>/</customdirectory> <terminal>false</terminal> Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/grandmas_svn.pro 2007-01-13 17:49:02 UTC (rev 150) @@ -213,20 +213,16 @@ include/diff.h \ include/nullable.h \ include/settings/userpaths.h \ - include/svn/add.h \ include/svn/commit_summary.h \ include/svn/commit_summary_thread.h \ include/svn/file_access.h \ include/svn/helpers.h \ include/svn/modification.h \ - include/svn/operation.h \ - include/svn/operation_internal.h \ include/svn/pool.h \ - include/svn/revert.h \ include/svn/revision.h \ include/svn/server_access.h \ - include/svn/svn_commit.h \ - include/svn/update.h \ + include/svn/wc_info.h \ + include/svn/wc_operations.h \ src/grandmas_svn.h SOURCES += src/commandline.cpp \ @@ -244,20 +240,16 @@ src/dialogs/util.cpp \ src/diff.cpp \ src/settings/userpaths.cpp \ - src/svn/add.cpp \ src/svn/commit_summary.cpp \ 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 \ - src/svn/revert.cpp \ src/svn/revision.cpp \ src/svn/server_access.cpp \ - src/svn/svn_commit.cpp \ - src/svn/update.cpp \ + src/svn/wc_info.cpp \ + src/svn/wc_operations.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/dialogs/mainwindow.h 2007-01-13 17:49:02 UTC (rev 150) @@ -54,6 +54,7 @@ void diff(const QModelIndex& rcIndex); void revert(); void add(); + void remove(); void move(); void modificationSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); Deleted: trunk/include/svn/add.h =================================================================== --- trunk/include/svn/add.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/svn/add.h 2007-01-13 17:49:02 UTC (rev 150) @@ -1,27 +0,0 @@ -/*************************************************************************** - * 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. * - ***************************************************************************/ - -class SvnOperationContext; -class QString; - -namespace Svn -{ - bool add(SvnOperationContext& rContext, const QString& filePath, QString& rError); -}; Deleted: trunk/include/svn/delete.h =================================================================== Deleted: trunk/include/svn/operation.h =================================================================== --- trunk/include/svn/operation.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/svn/operation.h 2007-01-13 17:49:02 UTC (rev 150) @@ -1,35 +0,0 @@ -/*************************************************************************** - * 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. * - ***************************************************************************/ - -struct svn_client_ctx_t; -struct svn_error_t; -struct svn_info_t; -struct apr_pool_t; - -class SvnOperationContext; -class QString; - -namespace Operation -{ - bool initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& rError); - - bool getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); - bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rFullPath, QString fullRepoPath, QString& rError); -}; Added: trunk/include/svn/operations.h =================================================================== --- trunk/include/svn/operations.h (rev 0) +++ trunk/include/svn/operations.h 2007-01-13 17:49:02 UTC (rev 150) @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + + +class SvnOperationContext; +class QString; + +namespace Svn +{ + // operations performed on a working-copy + bool add(SvnOperationContext& rContext, const QString& filePath, QString& rError); + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError); + bool update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError); + bool revert(SvnOperationContext& rContext, const QString& filePath, QString& rError); + + // Functions to retrieve information about a working copy + bool getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); + bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rFullPath, QString fullRepoPath, QString& rError); + + bool initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& rError); + Deleted: trunk/include/svn/revert.h =================================================================== --- trunk/include/svn/revert.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/svn/revert.h 2007-01-13 17:49:02 UTC (rev 150) @@ -1,27 +0,0 @@ -/*************************************************************************** - * 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. * - ***************************************************************************/ - -class QString; -class SvnOperationContext; - -namespace Svn -{ - bool revert(SvnOperationContext& rContext, const QString& filePath, QString& rError); -}; Deleted: trunk/include/svn/svn_commit.h =================================================================== --- trunk/include/svn/svn_commit.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/svn/svn_commit.h 2007-01-13 17:49:02 UTC (rev 150) @@ -1,5 +0,0 @@ - -namespace Svn -{ - bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError); -} Deleted: trunk/include/svn/update.h =================================================================== --- trunk/include/svn/update.h 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/include/svn/update.h 2007-01-13 17:49:02 UTC (rev 150) @@ -1,28 +0,0 @@ -/*************************************************************************** - * 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. * - ***************************************************************************/ - -class QString; -class SvnOperationContext; -class Revision; - -namespace Svn -{ - bool update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError); -}; Added: trunk/include/svn/wc_info.h =================================================================== --- trunk/include/svn/wc_info.h (rev 0) +++ trunk/include/svn/wc_info.h 2007-01-13 17:49:02 UTC (rev 150) @@ -0,0 +1,31 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + + +class SvnOperationContext; +class QString; + +struct svn_client_ctx_t; + +namespace Svn +{ + bool getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); + bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rFullPath, QString fullRepoPath, QString& rError); +} Added: trunk/include/svn/wc_operations.h =================================================================== --- trunk/include/svn/wc_operations.h (rev 0) +++ trunk/include/svn/wc_operations.h 2007-01-13 17:49:02 UTC (rev 150) @@ -0,0 +1,38 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + + +class SvnOperationContext; +class QString; +class QStringList; +class Revision; +struct svn_client_ctx_t; + +namespace Svn +{ + bool add(SvnOperationContext& rContext, const QString& filePath, QString& rError); + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError); + bool remove(SvnOperationContext& rContext, const QString& filePath, QString& rError); // equivalent to svn del + bool update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError); + bool revert(SvnOperationContext& rContext, const QString& filePath, QString& rError); + + bool initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& rError); +} + Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/dialogs/commit.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -27,8 +27,7 @@ #include "svn/commit_summary.h" #include "svn/file_access.h" #include "svn/revision.h" -#include "svn/svn_commit.h" -#include "svn/update.h" +#include "svn/wc_operations.h" #include "ui_commit.h" #include <QHeaderView> Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/dialogs/mainwindow.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -29,12 +29,10 @@ #include "dialogs/progress.h" #include "dialogs/revisionsmodel.h" #include "diff.h" -#include "svn/add.h" #include "svn/commit_summary.h" #include "svn/file_access.h" -#include "svn/revert.h" #include "svn/revision.h" -#include "svn/update.h" +#include "svn/wc_operations.h" #include "ui_mainwindow.h" #include <QDir> @@ -70,6 +68,7 @@ connect(mpUi->diffButton, SIGNAL(clicked()), this, SLOT(diff())); connect(mpUi->revertButton, SIGNAL(clicked()), this, SLOT(revert())); connect(mpUi->addButton, SIGNAL(clicked()), this, SLOT(add())); + connect(mpUi->deleteButton, SIGNAL(clicked()), this, SLOT(remove())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); mpModificationsModel = new ModificationsModel(mpCommitSummaryCache); @@ -238,6 +237,23 @@ reloadUncommittedSummary(); } +void MainWindow::remove() +{ + mpUi->changesTreeView->setFocus(); + + QList<Modification> mods = getSelectedModifications(); + Q_FOREACH(Modification mod, mods) + { + QString error; + if (!Svn::remove(*mpContext, mod.getFilePath(), error)) + { + QMessageBox::critical(this, "", error); + return; + } + } + reloadUncommittedSummary(); +} + void MainWindow::move() { MoveDialog dlg(this); @@ -276,7 +292,7 @@ mpUi->diffButton->setEnabled(true); mpUi->revertButton->setEnabled(isUncommitted && hasVersionedMod); mpUi->addButton->setEnabled(isUncommitted && hasUnversionedMod); - mpUi->deleteButton->setEnabled(false); + mpUi->deleteButton->setEnabled(isUncommitted); // TODO: yes, this is too loose mpUi->moveButton->setEnabled(false); } Deleted: trunk/src/svn/add.cpp =================================================================== --- trunk/src/svn/add.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/add.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -1,50 +0,0 @@ -/*************************************************************************** - * 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/add.h" - -#include "svn/helpers.h" -#include "svn/operation.h" -#include "svn/server_access.h" - -#include <svn_client.h> -#include <svn_path.h> -#include <Qt> - - -bool Svn::add(SvnOperationContext& rContext, const QString& filePath, QString& rError) -{ - const char* svnPath = svn_path_internal_style(filePath.toAscii(), rContext.getAprPool()); - const char* fullCanonPath = svn_path_canonicalize(svnPath, rContext.getAprPool()); - - svn_client_ctx_t* ctx; - svn_client_create_context(&ctx, rContext.getAprPool()); - if (!Operation::initAuthProviders(rContext, ctx, rError)) - return false; - - svn_error_t* pError = svn_client_add2(fullCanonPath, true, false, ctx, rContext.getAprPool()); - if (pError) - { - rError = formatSvnErrorMessage(pError); - return false; - } - - return true; -} Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/commit_summary.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -20,7 +20,8 @@ #include "svn/commit_summary.h" #include "svn/helpers.h" -#include "svn/operation.h" +#include "svn/wc_info.h" +#include "svn/wc_operations.h" #include <svn_client.h> #include <svn_path.h> @@ -75,13 +76,13 @@ svn_client_ctx_t* ctx; svn_client_create_context(&ctx, rContext.getAprPool()); - if (!Operation::initAuthProviders(rContext, ctx, rError)) + if (!initAuthProviders(rContext, ctx, rError)) return false; svn_error_t* pError = NULL; if (startRevision.getType() != Revision::Uncommitted) { - if (!Operation::getRepoCheckoutUrl(rContext, ctx, mRepoUrl, fullCanonPath, rError)) + if (!getRepoCheckoutUrl(rContext, ctx, mRepoUrl, fullCanonPath, rError)) return false; addSuffixUnlessExists(mRepoUrl, "/"); @@ -104,7 +105,7 @@ { mWcPath = fullCanonPath; addSuffixUnlessExists(mWcPath, "/"); - if (!Operation::getRepoUrlWithPath(rContext, ctx, mRepoUrl, fullCanonPath, rError)) + if (!getRepoUrlWithPath(rContext, ctx, mRepoUrl, fullCanonPath, rError)) return false; addSuffixUnlessExists(mRepoUrl, "/"); Deleted: trunk/src/svn/delete.cpp =================================================================== Modified: trunk/src/svn/file_access.cpp =================================================================== --- trunk/src/svn/file_access.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/file_access.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -20,7 +20,8 @@ #include "svn/file_access.h" #include "svn/helpers.h" -#include "svn/operation.h" +#include "svn/wc_info.h" +#include "svn/wc_operations.h" #include <svn_client.h> #include <svn_path.h> @@ -77,7 +78,7 @@ svn_client_ctx_t* pCtx = NULL; svn_client_create_context(&pCtx, rContext.getAprPool()); - if (!Operation::initAuthProviders(rContext, pCtx, rError)) + if (!Svn::initAuthProviders(rContext, pCtx, rError)) return false; svn_opt_revision_t svnRev = rev.getSvnRevision(); Deleted: trunk/src/svn/operation.cpp =================================================================== --- trunk/src/svn/operation.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/operation.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -1,138 +0,0 @@ -/*************************************************************************** - * 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/helpers.h" -#include "svn/operation.h" -#include "svn/server_access.h" - -#include <svn_client.h> -#include <svn_path.h> -#include <apr_pools.h> - -#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) -{ - QString promptUsername = username; - QString promptPassword; - SvnAuthentication* pAuth = ((SvnAuthentication*)baton); - if (!pAuth->getAuthentication(promptUsername)) - 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(); - lcred->password = pAuth->getPassword(); - - // tell svn if the credentials need to be saved - lcred->may_save = true; - *cred = lcred; - - return SVN_NO_ERROR; - } - - -bool Operation::initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& /*rError*/) -{ - apr_array_header_t *providers = apr_array_make(rContext.getAprPool(), 7, sizeof(svn_auth_provider_object_t *)); - - svn_auth_provider_object_t *provider; - -#ifdef WIN32 - svn_client_get_windows_simple_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; -#endif - // TODO: keychain provider? - svn_client_get_simple_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - svn_client_get_username_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - - // The server-cert, client-cert, and client-cert-password providers. - svn_client_get_ssl_server_trust_file_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; - svn_client_get_ssl_client_cert_file_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; - svn_client_get_ssl_client_cert_pw_file_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; - - svn_client_get_simple_prompt_provider(&provider, simpleAuthPrompt, rContext.getAuthenticationCallback(), 100000000, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - - svn_auth_baton_t *authBaton; - svn_auth_open(&authBaton, providers, rContext.getAprPool()); - - context->auth_baton = authBaton; - return true; -} - -class SvnInfo -{ -public: - bool getRepoUrls(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelCheckoutPath, QString& rRepoUrlWithPath, QString& rError) - { - const char* fullCanonPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); - svn_error_t* pError = svn_client_info(fullCanonPath, NULL, NULL, infoCallback, this, false, ctx, rContext.getAprPool()); - if (pError) - { - rError = Svn::formatSvnErrorMessage(pError); - return false; - } - rRelCheckoutPath = mRelativeRepoUrl; - rRepoUrlWithPath = mRepoUrlWithPath; - return true; - } - -protected: - static svn_error_t* infoCallback(void *baton, const char * /*path*/, const svn_info_t *info, apr_pool_t * /*pool*/) - { - SvnInfo* pThis = (SvnInfo*)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."); - - pThis->mRepoUrlWithPath = sRepoUrl; - - sRepoUrl.remove(0, sRootUrl.length()); - pThis->mRelativeRepoUrl = sRepoUrl; - return NULL; - } - - QString mRelativeRepoUrl; - QString mRepoUrlWithPath; -}; - - -bool Operation::getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) -{ - SvnInfo info; - QString ignored; - return info.getRepoUrls(rContext, fullRepoPath, ctx, rRelPath, ignored, rError); -} - -bool Operation::getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) -{ - SvnInfo info; - QString ignored; - return info.getRepoUrls(rContext, fullRepoPath, ctx, ignored, rRelPath, rError); -} - Deleted: trunk/src/svn/operation_internal.cpp =================================================================== --- trunk/src/svn/operation_internal.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/operation_internal.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -1,21 +0,0 @@ -/*************************************************************************** - * 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/operation_internal.h> Deleted: trunk/src/svn/revert.cpp =================================================================== --- trunk/src/svn/revert.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/revert.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -1,51 +0,0 @@ -/*************************************************************************** - * 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/revert.h" - -#include "svn/helpers.h" -#include "svn/operation.h" -#include "svn/server_access.h" - -#include <svn_client.h> -#include <svn_path.h> -#include <QStringList> -#include <Qt> - - -bool Svn::revert(SvnOperationContext& rContext, const QString& filePath, QString& rError) -{ - const char* fullCanonPath = svn_path_canonicalize(filePath.toAscii(), rContext.getAprPool()); - - svn_client_ctx_t* ctx; - svn_client_create_context(&ctx, rContext.getAprPool()); - if (!Operation::initAuthProviders(rContext, ctx, rError)) - return false; - - apr_array_header_t *array = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); - svn_error_t* pError = svn_client_revert(array, true, ctx, rContext.getAprPool()); - if (pError) - { - rError = formatSvnErrorMessage(pError); - return false; - } - - return true; -} Modified: trunk/src/svn/svn_commit.cpp =================================================================== --- trunk/src/svn/svn_commit.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/svn_commit.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -31,66 +31,3 @@ #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; - mpContext = &rContext; - - mpContext->getStatus()->update(QObject::tr("Connecting to server to commit changes...")); - - 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 = updateNotifyCallback; - ctx->notify_baton2 = this; - - apr_array_header_t *filesArray = aprArrayFromQStringList(filePaths, rContext.getAprPool()); - - svn_commit_info_t* pResultingInfo = NULL; - svn_error_t* pError = svn_client_commit3(&pResultingInfo, filesArray, true, true, ctx, rContext.getAprPool()); - if (pError) - { - rError = formatSvnErrorMessage(pError); - 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 = apr_pstrdup(pThis->mpContext->getAprPool(), pThis->mLogMessage.toAscii()); - return NULL; - } - - 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)); - } - - 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); - } -}; Deleted: trunk/src/svn/update.cpp =================================================================== --- trunk/src/svn/update.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/src/svn/update.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -1,85 +0,0 @@ -/*************************************************************************** - * 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/update.h" - -#include "svn/helpers.h" -#include "svn/operation.h" -#include "svn/revision.h" -#include "svn/server_access.h" - -#include <svn_client.h> -#include <svn_path.h> -#include <QObject> -#include <QStringList> - -namespace Svn -{ - class Updater - { - public: - bool update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError); - - private: - static void updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool); - - SvnOperationContext* mpContext; - }; -} - -bool Svn::Updater::update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError) -{ - rError = ""; - mpContext = &rContext; - - const char* fullCanonPath = svn_path_canonicalize(filePath.toAscii(), rContext.getAprPool()); - - svn_client_ctx_t* ctx; - svn_client_create_context(&ctx, rContext.getAprPool()); - if (!Operation::initAuthProviders(rContext, ctx, rError)) - return false; - - ctx->notify_func2 = updateNotifyCallback; - ctx->notify_baton2 = this; - - svn_opt_revision_t svnRev = revision.getSvnRevision(); - - apr_array_header_t *paths = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); - svn_error_t* pError = svn_client_update2(NULL, paths, &svnRev, true, false, ctx, rContext.getAprPool()); - if (pError) - { - rError = formatSvnErrorMessage(pError); - return false; - } - - return true; -} - -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)); -} - -bool Svn::update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError) -{ - Svn::Updater updater; - return updater.update(rContext, filePath, revision, rError); -} Added: trunk/src/svn/wc_info.cpp =================================================================== --- trunk/src/svn/wc_info.cpp (rev 0) +++ trunk/src/svn/wc_info.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -0,0 +1,86 @@ +/*************************************************************************** + * 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/wc_info.h" + +#include "svn/helpers.h" +#include "svn/server_access.h" + +#include <svn_client.h> +#include <svn_path.h> +#include <apr_pools.h> + +#include <QString> + + +class SvnInfo +{ +public: + bool getRepoUrls(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelCheckoutPath, QString& rRepoUrlWithPath, QString& rError) + { + const char* fullCanonPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); + svn_error_t* pError = svn_client_info(fullCanonPath, NULL, NULL, infoCallback, this, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = Svn::formatSvnErrorMessage(pError); + return false; + } + rRelCheckoutPath = mRelativeRepoUrl; + rRepoUrlWithPath = mRepoUrlWithPath; + return true; + } + +protected: + static svn_error_t* infoCallback(void *baton, const char * /*path*/, const svn_info_t *info, apr_pool_t * /*pool*/) + { + SvnInfo* pThis = (SvnInfo*)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."); + + pThis->mRepoUrlWithPath = sRepoUrl; + + sRepoUrl.remove(0, sRootUrl.length()); + pThis->mRelativeRepoUrl = sRepoUrl; + return NULL; + } + + QString mRelativeRepoUrl; + QString mRepoUrlWithPath; +}; + + +bool Svn::getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) +{ + SvnInfo info; + QString ignored; + return info.getRepoUrls(rContext, fullRepoPath, ctx, rRelPath, ignored, rError); +} + +bool Svn::getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) +{ + SvnInfo info; + QString ignored; + return info.getRepoUrls(rContext, fullRepoPath, ctx, ignored, rRelPath, rError); +} + Added: trunk/src/svn/wc_operations.cpp =================================================================== --- trunk/src/svn/wc_operations.cpp (rev 0) +++ trunk/src/svn/wc_operations.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -0,0 +1,264 @@ +/*************************************************************************** + * 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/wc_operations.h" + +#include "svn/helpers.h" +#include "svn/revision.h" +#include "svn/server_access.h" +#include "svn/wc_info.h" + +#include <svn_client.h> +#include <svn_path.h> + +#include <Qt> +#include <QObject> +#include <QStringList> + + +namespace Svn +{ + class Updater + { + public: + bool update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError); + + private: + static void updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool); + + SvnOperationContext* mpContext; + }; + + class Committer + { + public: + Committer() { mpContext = NULL; } + ~Committer() {} + + bool commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError); + + 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 = apr_pstrdup(pThis->mpContext->getAprPool(), pThis->mLogMessage.toAscii()); + return NULL; + } + + 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)); + } + + SvnOperationContext* mpContext; + QString mLogMessage; + }; +} + +bool Svn::add(SvnOperationContext& rContext, const QString& filePath, QString& rError) +{ + const char* svnPath = svn_path_internal_style(filePath.toAscii(), rContext.getAprPool()); + const char* fullCanonPath = svn_path_canonicalize(svnPath, rContext.getAprPool()); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!initAuthProviders(rContext, ctx, rError)) + return false; + + svn_error_t* pError = svn_client_add2(fullCanonPath, true, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + + return true; +} + + +bool Svn::remove(SvnOperationContext& rContext, const QString& filePath, QString& rError) +{ + const char* svnPath = svn_path_internal_style(filePath.toAscii(), rContext.getAprPool()); + const char* fullCanonPath = svn_path_canonicalize(svnPath, rContext.getAprPool()); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + + apr_array_header_t *array = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); + svn_client_commit_info_t* pResultingInfo = NULL; + svn_error_t* pError = svn_client_delete(&pResultingInfo, array, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + + return true; +} + +bool Svn::commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError) +{ + Committer comitter; + return comitter.commit(rContext, commitMessage, filePaths, rError); +} + +bool Svn::revert(SvnOperationContext& rContext, const QString& filePath, QString& rError) +{ + const char* fullCanonPath = svn_path_canonicalize(filePath.toAscii(), rContext.getAprPool()); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!initAuthProviders(rContext, ctx, rError)) + return false; + + apr_array_header_t *array = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); + svn_error_t* pError = svn_client_revert(array, true, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + + return true; +} + +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; + SvnAuthentication* pAuth = ((SvnAuthentication*)baton); + if (!pAuth->getAuthentication(promptUsername)) + 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(); + lcred->password = pAuth->getPassword(); + + // tell svn if the credentials need to be saved + lcred->may_save = true; + *cred = lcred; + + return SVN_NO_ERROR; +} + +bool Svn::initAuthProviders(SvnOperationContext& rContext, svn_client_ctx_t* context, QString& /*rError*/) +{ + apr_array_header_t *providers = apr_array_make(rContext.getAprPool(), 7, sizeof(svn_auth_provider_object_t *)); + + svn_auth_provider_object_t *provider; + +#ifdef WIN32 + svn_client_get_windows_simple_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; +#endif + // TODO: keychain provider? + svn_client_get_simple_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + svn_client_get_username_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + // The server-cert, client-cert, and client-cert-password providers. + svn_client_get_ssl_server_trust_file_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; + svn_client_get_ssl_client_cert_file_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; + svn_client_get_ssl_client_cert_pw_file_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers, svn_auth_provider_object_t *) = provider; + + svn_client_get_simple_prompt_provider(&provider, simpleAuthPrompt, rContext.getAuthenticationCallback(), 100000000, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + svn_auth_baton_t *authBaton; + svn_auth_open(&authBaton, providers, rContext.getAprPool()); + + context->auth_baton = authBaton; + return true; +} + +bool Svn::Updater::update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError) +{ + rError = ""; + mpContext = &rContext; + + const char* fullCanonPath = svn_path_canonicalize(filePath.toAscii(), rContext.getAprPool()); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!initAuthProviders(rContext, ctx, rError)) + return false; + + ctx->notify_func2 = updateNotifyCallback; + ctx->notify_baton2 = this; + + svn_opt_revision_t svnRev = revision.getSvnRevision(); + + apr_array_header_t *paths = aprArrayFromQStringList(QStringList() << fullCanonPath, rContext.getAprPool()); + svn_error_t* pError = svn_client_update2(NULL, paths, &svnRev, true, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + + return true; +} + +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)); +} + +bool Svn::update(SvnOperationContext& rContext, const QString& filePath, const Revision& revision, QString& rError) +{ + Svn::Updater updater; + return updater.update(rContext, filePath, revision, rError); +} + +bool Svn::Committer::commit(SvnOperationContext& rContext, QString commitMessage, const QStringList& filePaths, QString& rError) +{ + mLogMessage = commitMessage; + mpContext = &rContext; + + mpContext->getStatus()->update(QObject::tr("Connecting to server to commit changes...")); + + svn_client_ctx_t* ctx = NULL; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!Svn::initAuthProviders(rContext, ctx, rError)) + return false; + + ctx->log_msg_func2 = getLogMessage; + ctx->log_msg_baton2 = this; + ctx->notify_func2 = updateNotifyCallback; + ctx->notify_baton2 = this; + + apr_array_header_t *filesArray = aprArrayFromQStringList(filePaths, rContext.getAprPool()); + + svn_commit_info_t* pResultingInfo = NULL; + svn_error_t* pError = svn_client_commit3(&pResultingInfo, filesArray, true, true, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + + return true; +} Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/tests/svn_test.cpp 2007-01-13 17:49:02 UTC (rev 150) @@ -20,13 +20,11 @@ #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/helpers.h" #include "svn/modification.h" -#include "svn/operation.h" +#include "svn/wc_operations.h" #include <svn_client.h> #include <svn_repos.h> @@ -68,7 +66,7 @@ svn_client_create_context(&mpCtx, mpContext->getAprPool()); QString rIgnoredError; - Q_ASSERT(Operation::initAuthProviders(*mpContext, mpCtx, rIgnoredError)); + Q_ASSERT(Svn::initAuthProviders(*mpContext, mpCtx, rIgnoredError)); } SvnTester::~SvnTester() Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2007-01-13 04:40:39 UTC (rev 149) +++ trunk/ui/mainwindow.ui 2007-01-13 17:49:02 UTC (rev 150) @@ -242,7 +242,7 @@ <item> <widget class="QPushButton" name="deleteButton" > <property name="text" > - <string>Delete...</string> + <string>D&elete...</string> </property> </widget> </item> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2007-01-20 02:33:28
|
Revision: 160 http://svn.sourceforge.net/grandmas-svn/?rev=160&view=rev Author: highjinx Date: 2007-01-19 18:33:28 -0800 (Fri, 19 Jan 2007) Log Message: ----------- * Numerous fixes/improvements to diffing modifications Modified Paths: -------------- trunk/include/svn/file_access.h trunk/src/dialogs/mainwindow.cpp trunk/src/svn/file_access.cpp trunk/src/svn/modification.cpp Modified: trunk/include/svn/file_access.h =================================================================== --- trunk/include/svn/file_access.h 2007-01-20 02:15:57 UTC (rev 159) +++ trunk/include/svn/file_access.h 2007-01-20 02:33:28 UTC (rev 160) @@ -30,5 +30,8 @@ Revision rev, QString& rCreatedFilePath, QString& rError); bool getDiffFiles(SvnOperationContext& rContext, const QString& repoPath, const QString& relFilePath, Revision leftRevision, Revision rightRevision, QString& rLeftFilePath, QString& rRightFilePath, QString& rError); + + bool getDiffFiles(SvnOperationContext& rContext, const QString& repoPath, Modification mod, + QString& rLeftFilePath, QString& rRightFilePath, QString& rError); }; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2007-01-20 02:15:57 UTC (rev 159) +++ trunk/src/dialogs/mainwindow.cpp 2007-01-20 02:33:28 UTC (rev 160) @@ -176,18 +176,12 @@ Q_FOREACH(Modification mod, mods) { QString error, leftPath, rightPath; - if (mod.getType() == Modification::Type_Addition) + // Generate each side of the diff + if (!Svn::getDiffFiles(*mpContext, mPath, mod, leftPath, rightPath, error)) { + QMessageBox::critical(this, "", error); + return; } - else - { - // Generate each side of the diff - if (!Svn::getDiffFiles(*mpContext, mPath, mod.getFilePath(), mod.fileModification_getOldRevision(), mod.getRevision(), leftPath, rightPath, error)) - { - QMessageBox::critical(this, "", error); - return; - } - } // Launch the diff bool allowMerge = mod.getRevision().getType() == Revision::Uncommitted; Modified: trunk/src/svn/file_access.cpp =================================================================== --- trunk/src/svn/file_access.cpp 2007-01-20 02:15:57 UTC (rev 159) +++ trunk/src/svn/file_access.cpp 2007-01-20 02:33:28 UTC (rev 160) @@ -103,6 +103,36 @@ bool Svn::getDiffFiles(SvnOperationContext& rContext, const QString& repoPath, const QString& relFilePath, Revision leftRevision, Revision rightRevision, QString& rLeftFilePath, QString& rRightFilePath, QString& rError) { - return getFile(rContext, repoPath, relFilePath, leftRevision, rLeftFilePath, rError) && getFile(rContext, repoPath, relFilePath, rightRevision, rRightFilePath, rError); + return getFile(rContext, repoPath, relFilePath, leftRevision, rLeftFilePath, rError) && + getFile(rContext, repoPath, relFilePath, rightRevision, rRightFilePath, rError); } +bool Svn::getDiffFiles(SvnOperationContext& rContext, const QString& repoPath, Modification mod, + QString& rLeftFilePath, QString& rRightFilePath, QString& rError) +{ + switch (mod.getType()) + { + case Modification::Type_FileModification: + return getDiffFiles(rContext, repoPath, mod.getFilePath(), mod.fileModification_getOldRevision(), mod.getRevision(), rLeftFilePath, rRightFilePath, rError); + case Modification::Type_Addition: + if (!mod.isAddedWithHistory()) + rLeftFilePath = ""; + else + { + if (!getFile(rContext, repoPath, mod.getHistoryFilePath(), mod.getHistoryRevision(), rLeftFilePath, rError)) + return false; + } + return getFile(rContext, repoPath, mod.getFilePath(), mod.getRevision(), rRightFilePath, rError); + case Modification::Type_Deletion: + rRightFilePath = ""; + return getFile(rContext, repoPath, mod.getFilePath(), mod.getRevision(), rLeftFilePath, rError); + case Modification::Type_PropertyModification: + case Modification::Type_Conflict: + case Modification::Type_Creation: + case Modification::Type_Missing: + break; + } + + rError = "This modification type is not diffable at this time."; + return false; +} Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2007-01-20 02:15:57 UTC (rev 159) +++ trunk/src/svn/modification.cpp 2007-01-20 02:33:28 UTC (rev 160) @@ -122,6 +122,12 @@ return mHistoryFilePath; } +Revision Modification::getHistoryRevision() const +{ + Q_ASSERT(isAddedWithHistory()); + return mHistoryRevision; +} + Revision Modification::fileModification_getOldRevision() const { return mOldRevision; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2007-01-30 04:24:00
|
Revision: 164 http://svn.sourceforge.net/grandmas-svn/?rev=164&view=rev Author: highjinx Date: 2007-01-29 20:23:58 -0800 (Mon, 29 Jan 2007) Log Message: ----------- Adding API for annotate feature. No UI tie-in as of yet. Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/svn/revision.h trunk/src/svn/revision.cpp Added Paths: ----------- trunk/include/svn/annotate.h trunk/src/svn/annotate.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2007-01-20 21:02:02 UTC (rev 163) +++ trunk/grandmas_svn.pro 2007-01-30 04:23:58 UTC (rev 164) @@ -213,6 +213,7 @@ include/diff.h \ include/nullable.h \ include/settings/userpaths.h \ + include/svn/annotate.h \ include/svn/commit_summary.h \ include/svn/commit_summary_thread.h \ include/svn/file_access.h \ @@ -240,6 +241,7 @@ src/dialogs/util.cpp \ src/diff.cpp \ src/settings/userpaths.cpp \ + src/svn/annotate.cpp \ src/svn/commit_summary.cpp \ src/svn/commit_summary_thread.cpp \ src/svn/file_access.cpp \ Added: trunk/include/svn/annotate.h =================================================================== --- trunk/include/svn/annotate.h (rev 0) +++ trunk/include/svn/annotate.h 2007-01-30 04:23:58 UTC (rev 164) @@ -0,0 +1,54 @@ +/*************************************************************************** + * 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 <Qt> +#include <QDateTime> +#include <QString> + +#include "svn/revision.h" +#include "svn/server_access.h" + +namespace Svn +{ + class AnnotateLine + { + public: + AnnotateLine(); + AnnotateLine(QString author, Revision revision, QDateTime date, QString line); + + bool annotateInfoAvailable(); + + QString getAuthor(); + Revision getRevision(); + QDateTime getDate(); + + QString getLine(); + + protected: + bool mInformationAvailable; + QString mAuthor; + Revision mRevision; + QDateTime mDate; + QString mLine; + }; + + bool getAnnotateInformation(SvnOperationContext& rContext, QString repoPath, QString relFilePath, Revision startRevision, + Revision endRevision, QList<AnnotateLine>& rAnnotateInfo, QString& rError); +} Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2007-01-20 21:02:02 UTC (rev 163) +++ trunk/include/svn/revision.h 2007-01-30 04:23:58 UTC (rev 164) @@ -36,6 +36,7 @@ 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); + static Revision fromSvn(svn_revnum_t revision); enum Type { Added: trunk/src/svn/annotate.cpp =================================================================== --- trunk/src/svn/annotate.cpp (rev 0) +++ trunk/src/svn/annotate.cpp 2007-01-30 04:23:58 UTC (rev 164) @@ -0,0 +1,132 @@ +/*************************************************************************** + * 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/annotate.h" + +#include "svn/helpers.h" +#include "svn/wc_operations.h" + +#include <svn_client.h> +#include <svn_path.h> +#include <QList> + +Svn::AnnotateLine::AnnotateLine() +{ + mInformationAvailable = false; +} + +Svn::AnnotateLine::AnnotateLine(QString author, Revision revision, QDateTime date, QString line) +{ + mInformationAvailable = true; + + mAuthor = author; + mRevision = revision; + mDate = date; + mLine = line; +} + +bool Svn::AnnotateLine::annotateInfoAvailable() +{ + return mInformationAvailable; +} + +QString Svn::AnnotateLine::getAuthor() +{ + Q_ASSERT(annotateInfoAvailable()); + + return mAuthor; +} + +Revision Svn::AnnotateLine::getRevision() +{ + Q_ASSERT(annotateInfoAvailable()); + + return mRevision; +} + +QDateTime Svn::AnnotateLine::getDate() +{ + Q_ASSERT(annotateInfoAvailable()); + + return mDate; +} + +QString Svn::AnnotateLine::getLine() +{ + Q_ASSERT(annotateInfoAvailable()); + + return mLine; +} + +namespace Svn +{ + class AnnotateInfoFetcher + { + public: + AnnotateInfoFetcher() {} + + bool getAnnotateInformation(SvnOperationContext& rContext, QString repoPath, QString relFilePath, + Revision startRevision, Revision endRevision, QList<AnnotateLine>& rAnnotateInfo, QString& rError) + { + const char* svnPath = svn_path_internal_style(combinePaths(repoPath, relFilePath).toAscii(), rContext.getAprPool()); + const char* fullCanonPath = svn_path_canonicalize(svnPath, rContext.getAprPool()); + + svn_opt_revision_t pegRevision = endRevision.getSvnRevision(); + pegRevision.kind = svn_opt_revision_unspecified; + svn_opt_revision_t svnStartRevision = startRevision.getSvnRevision(); + svn_opt_revision_t svnEndRevision = endRevision.getSvnRevision(); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!initAuthProviders(rContext, ctx, rError)) + return false; + + svn_error_t* pError = svn_client_blame2(fullCanonPath, &pegRevision, &svnStartRevision, &svnEndRevision, annotateInfoCallback, this, ctx, rContext.getAprPool()); + if (pError) + { + rError = formatSvnErrorMessage(pError); + return false; + } + rAnnotateInfo = mAnnotateInfo; + return true; + } + + protected: + static svn_error_t* annotateInfoCallback(void *baton, apr_int64_t line_no, svn_revnum_t revision, + const char *author, const char *date, const char *line, apr_pool_t */*pool*/) + { + AnnotateInfoFetcher* pThis = (AnnotateInfoFetcher*)baton; + + Q_ASSERT(line_no == pThis->mAnnotateInfo.size()); + + pThis->mAnnotateInfo.push_back(AnnotateLine(author, Revision::fromSvn(revision), QDateTime::fromString(date, Qt::ISODate), line)); + return NULL; + } + + QList<AnnotateLine> mAnnotateInfo; + }; +} + +bool Svn::getAnnotateInformation(SvnOperationContext& rContext, QString repoPath, QString relFilePath, Revision startRevision, + Revision endRevision, QList<AnnotateLine>& rAnnotateInfo, QString& rError) +{ + AnnotateInfoFetcher fetcher; + return fetcher.getAnnotateInformation(rContext, repoPath, relFilePath, startRevision, endRevision, rAnnotateInfo, rError); +} Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2007-01-20 21:02:02 UTC (rev 163) +++ trunk/src/svn/revision.cpp 2007-01-30 04:23:58 UTC (rev 164) @@ -83,6 +83,11 @@ return svnRev; } +Revision Revision::fromSvn(svn_revnum_t revision) +{ + return committed(revision); +} + QString Revision::getRevisionString() { switch(getType()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2007-03-01 17:18:29
|
Revision: 165 http://svn.sourceforge.net/grandmas-svn/?rev=165&view=rev Author: highjinx Date: 2007-03-01 09:18:06 -0800 (Thu, 01 Mar 2007) Log Message: ----------- * Implemented Update to Revision functionality * Improved error messages when we are unable to get commit summary history * Update .kdevelop project to 3.4 Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/dialogs/mainwindow.h trunk/include/dialogs/revisionsmodel.h trunk/include/svn/wc_info.h trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/revisionsmodel.cpp trunk/src/svn/wc_info.cpp trunk/src/svn/wc_operations.cpp trunk/ui/mainwindow.ui Added Paths: ----------- trunk/include/dialogs/updateToRevision.h trunk/src/dialogs/updateToRevision.cpp trunk/ui/updateToRevision.ui Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/grandmas_svn.kdevelop 2007-03-01 17:18:06 UTC (rev 165) @@ -12,8 +12,9 @@ <ignoreparts/> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> + <description/> <versioncontrol/> + <projectname>grandmas_svn</projectname> </general> <kdevfileview> <groups> @@ -69,16 +70,16 @@ </kdevdoctreeview> <kdevdebugger> <general> - <dbgshell></dbgshell> + <dbgshell/> <breakpoints/> - <programargs></programargs> + <programargs/> <gdbpath>/usr/bin/</gdbpath> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> </general> <display> <staticmembers>false</staticmembers> @@ -90,7 +91,7 @@ <kdevtrollproject> <run> <mainprogram>bin/debug/grandmas-svn</mainprogram> - <programargs></programargs> + <programargs/> <directoryradio>build</directoryradio> <customdirectory>/</customdirectory> <terminal>false</terminal> @@ -105,7 +106,7 @@ <runmultiplejobs>false</runmultiplejobs> <numberofjobs>1</numberofjobs> <dontact>false</dontact> - <makebin></makebin> + <makebin/> <prio>0</prio> <envvars/> </make> @@ -155,14 +156,34 @@ <codeCompletionDelay>250</codeCompletionDelay> <argumentsHintDelay>400</argumentsHintDelay> <headerCompletionDelay>250</headerCompletionDelay> + <showOnlyAccessibleItems>false</showOnlyAccessibleItems> + <completionBoxItemOrder>0</completionBoxItemOrder> + <howEvaluationContextMenu>true</howEvaluationContextMenu> + <showCommentWithArgumentHint>true</showCommentWithArgumentHint> + <statusBarTypeEvaluation>false</statusBarTypeEvaluation> + <namespaceAliases>std=_GLIBCXX_STD;__gnu_cxx=std</namespaceAliases> + <processPrimaryTypes>true</processPrimaryTypes> + <processFunctionArguments>false</processFunctionArguments> + <preProcessAllHeaders>false</preProcessAllHeaders> + <parseMissingHeaders>false</parseMissingHeaders> + <resolveIncludePaths>true</resolveIncludePaths> + <alwaysParseInBackground>true</alwaysParseInBackground> + <usePermanentCaching>true</usePermanentCaching> + <alwaysIncludeNamespaces>false</alwaysIncludeNamespaces> + <includePaths>.;</includePaths> </codecompletion> <qt> <used>true</used> <version>4</version> - <root></root> + <root>/usr/lib/qt4</root> + <includestyle>3</includestyle> + <designerintegration>ExternalDesigner</designerintegration> + <qmake>/usr/bin/qmake-qt4</qmake> + <designer>/usr/bin/designer-qt4</designer> + <designerpluginpaths/> </qt> <creategettersetter> - <prefixGet></prefixGet> + <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/grandmas_svn.pro 2007-03-01 17:18:06 UTC (rev 165) @@ -192,6 +192,7 @@ ui/move.ui \ ui/open.ui \ ui/progress.ui \ + ui/updateToRevision.ui ICON = ui/icons/mac.icns RESOURCES = ui/grandmas-svn.qrc @@ -209,6 +210,7 @@ include/dialogs/open.h \ include/dialogs/progress.h \ include/dialogs/revisionsmodel.h \ + include/dialogs/updateToRevision.h \ include/dialogs/util.h \ include/diff.h \ include/nullable.h \ @@ -238,6 +240,7 @@ src/dialogs/open.cpp \ src/dialogs/progress.cpp \ src/dialogs/revisionsmodel.cpp \ + src/dialogs/updateToRevision.cpp \ src/dialogs/util.cpp \ src/diff.cpp \ src/settings/userpaths.cpp \ Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/include/dialogs/mainwindow.h 2007-03-01 17:18:06 UTC (rev 165) @@ -57,12 +57,13 @@ void remove(); void revert(); void update(); + void updateToRevision(); void modificationSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); void revisionSelectionChanged(const QItemSelection& rcSelected, const QItemSelection& rcDeselected); void afterCommitSummaryAdded(Revision rev); void modelDataChanged(const QModelIndex&, const QModelIndex&); - + private: void reloadCommittedSummaries(); void reloadUncommittedSummary(); @@ -77,6 +78,8 @@ CommitSummaryCache* mpCommitSummaryCache; ModificationsModel* mpModificationsModel; RevisionsModel* mpRevisionsModel; + + bool mUncommittedRevSelected; }; #endif Modified: trunk/include/dialogs/revisionsmodel.h =================================================================== --- trunk/include/dialogs/revisionsmodel.h 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/include/dialogs/revisionsmodel.h 2007-03-01 17:18:06 UTC (rev 165) @@ -22,6 +22,7 @@ #include <QAbstractListModel> class CommitSummaryCache; +class QStringList; namespace Svn { class CommitSummary; @@ -51,8 +52,11 @@ private: static QString getRevisionAsString(Revision rev); static QString getDateTimeAsString(QDateTime dateTime); + + QStringList getFetchErrors() const; CommitSummaryCache* mpCommitSummaryCache; - QString mError; + QString mCommittedFetchError; + QString mUncommittedFetchError; }; Added: trunk/include/dialogs/updateToRevision.h =================================================================== --- trunk/include/dialogs/updateToRevision.h (rev 0) +++ trunk/include/dialogs/updateToRevision.h 2007-03-01 17:18:06 UTC (rev 165) @@ -0,0 +1,56 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + + +#ifndef DIALOGS_UPDATETOREVISION_H_ +#define DIALOGS_UPDATETOREVISION_H_ + +#include <Qt> +#include <QDialog> + +#include "svn/revision.h" + +class SvnOperationContext; +class Ui_UpdateToRevisionDialog; + +class UpdateToRevisionDialog : public QDialog +{ + Q_OBJECT + +public: + UpdateToRevisionDialog(SvnOperationContext* pContext, QString repoPath, QWidget* pParent); + ~UpdateToRevisionDialog(); + +private slots: + void browse(); + void update(); + +protected: + bool updateToRevision(QString relDirPath, Revision rev, QString& error); + +private: + Ui_UpdateToRevisionDialog* mpUi; + + SvnOperationContext* mpContext; + QString mRepoPath; + QString mDirPath; +}; + +#endif Modified: trunk/include/svn/wc_info.h =================================================================== --- trunk/include/svn/wc_info.h 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/include/svn/wc_info.h 2007-03-01 17:18:06 UTC (rev 165) @@ -29,4 +29,6 @@ // Functions to get information about the working copy bool getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError); bool getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rFullPath, QString fullRepoPath, QString& rError); + + bool getRepoBaseRevision(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString fullRepoPath, int& riRevision, QString& rError); } Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/src/dialogs/mainwindow.cpp 2007-03-01 17:18:06 UTC (rev 165) @@ -28,10 +28,12 @@ #include "dialogs/move.h" #include "dialogs/progress.h" #include "dialogs/revisionsmodel.h" +#include "dialogs/updateToRevision.h" #include "diff.h" #include "svn/commit_summary.h" #include "svn/file_access.h" #include "svn/revision.h" +#include "svn/wc_info.h" #include "svn/wc_operations.h" #include "ui_mainwindow.h" @@ -70,7 +72,7 @@ connect(mpUi->addButton, SIGNAL(clicked()), this, SLOT(add())); connect(mpUi->deleteButton, SIGNAL(clicked()), this, SLOT(remove())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); - + mpModificationsModel = new ModificationsModel(mpCommitSummaryCache); connect(mpModificationsModel, SIGNAL(dataChanged(const QModelIndex&,const QModelIndex&)), this, SLOT(modelDataChanged(const QModelIndex&,const QModelIndex&))); @@ -145,6 +147,16 @@ reloadCommittedSummaries(); } +void MainWindow::updateToRevision() +{ + // Display dialog + UpdateToRevisionDialog dlg(mpContext, mPath, this); + dlg.exec(); + + reloadUncommittedSummary(); + reloadCommittedSummaries(); +} + void MainWindow::cleanup() { QString error; @@ -289,8 +301,17 @@ { // check whether the uncommitted revision is selected Svn::CommitSummary summary; - bool isUncommitted = getSelectedCommitSummary(summary) && - summary.getRevision().getType() == Revision::Uncommitted; + if (!getSelectedCommitSummary(summary)) + { + mpUi->diffButton->setEnabled(false); + mpUi->revertButton->setEnabled(false); + mpUi->addButton->setEnabled(false); + mpUi->deleteButton->setEnabled(false); + mpUi->moveButton->setEnabled(false); + return; + } + + bool isUncommitted = summary.getRevision().getType() == Revision::Uncommitted; // check for versioned/unversioned mods bool hasVersionedMod = false, hasUnversionedMod = false; @@ -321,17 +342,34 @@ { Q_UNUSED(rcSelected); Q_UNUSED(rcDeselected); - + Svn::CommitSummary commitSummary; if (getSelectedCommitSummary(commitSummary)) { - mpUi->logEdit->setReadOnly(commitSummary.getRevision().getType() != Revision::Uncommitted); + bool uncommittedNowSelected = commitSummary.getRevision().getType() != Revision::Uncommitted; + bool loadCommitSummary = false; + { + // If we're moving from an uncommitted message to a committed one, save the log message. + // If vice-versa, load the log message + + if (uncommittedNowSelected && mUncommittedRevSelected) + Svn::CommitSummary::SaveUncommittedLogMessage(mPath, mpUi->logEdit->toPlainText()); + else if (uncommittedNowSelected && mUncommittedRevSelected) + loadCommitSummary = true; + } + mpUi->logEdit->setReadOnly(uncommittedNowSelected); mpUi->logEdit->document()->setPlainText(commitSummary.getCommitLogMessage()); mpModificationsModel->setRevision(commitSummary.getRevision()); if (commitSummary.getRevision().getType() == Revision::Uncommitted) reloadUncommittedSummary(); + + if (loadCommitSummary) + { + //Svn::CommitSummary::LoadUncommittedLogMessage + } + mUncommittedRevSelected = uncommittedNowSelected; } else mpModificationsModel->clearRevision(); Modified: trunk/src/dialogs/revisionsmodel.cpp =================================================================== --- trunk/src/dialogs/revisionsmodel.cpp 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/src/dialogs/revisionsmodel.cpp 2007-03-01 17:18:06 UTC (rev 165) @@ -24,6 +24,8 @@ #include "debug.h" #include "svn/commit_summary.h" +#include <QStringList> + RevisionsModel::RevisionsModel(CommitSummaryCache* pCommitSummaryCache) { mpCommitSummaryCache = pCommitSummaryCache; @@ -82,7 +84,7 @@ { Q_UNUSED(rcParent); - if (!mError.isNull()) + if (getFetchErrors().size() > 0) return 1; return 4; @@ -92,8 +94,9 @@ { Q_UNUSED(rcParent); - if (!mError.isNull()) - return 1; + // TODO: think through uncommitted fetch error + if (getFetchErrors().size() > 0) + return getFetchErrors().size() + mpCommitSummaryCache->getCommitSummaries().count(); return mpCommitSummaryCache->getCommitSummaries().count(); } @@ -104,8 +107,8 @@ if (role == Qt::DisplayRole) { - if (!mError.isNull()) - return QVariant(); + if (getFetchErrors().size() > 0) + return section == 0 ? "Error:" : QVariant(); switch (section) { @@ -125,8 +128,13 @@ if (role == Qt::DisplayRole) { // display the error - if (!mError.isNull()) - return mError; + if (getFetchErrors().size() > 0) + { + if (rcIndex.row() == 0 && !mUncommittedFetchError.isNull()) + return mUncommittedFetchError; + if (rcIndex.row() == 1 && !mCommittedFetchError.isNull()) + return mCommittedFetchError; + } Svn::CommitSummary summary; if (!rcIndex.isValid() || !getCommitSummaryForRow(rcIndex.row(), summary)) @@ -154,8 +162,10 @@ bool RevisionsModel::getCommitSummaryForRow(int row, Svn::CommitSummary& rSummary) const { // showing error? - if (!mError.isNull()) + if (row == 0 && !mUncommittedFetchError.isNull()) return false; + if (row == 1 && !mCommittedFetchError.isNull()) + return false; if (row >= 0 && row < mpCommitSummaryCache->getCommitSummaries().count()) { @@ -168,11 +178,17 @@ void RevisionsModel::beforeCommitSummaryAdded(Revision rev) { - if (!mError.isNull()) + bool revIsCommitted = rev.getType() != Revision::Uncommitted; + if (revIsCommitted && !mCommittedFetchError.isNull()) { - mError = QString(); + mCommittedFetchError = QString(); reset(); } + if (!revIsCommitted && !mUncommittedFetchError.isNull()) + { + mUncommittedFetchError = QString(); + reset(); + } int index = -1; if (CommitSummaryFinder::findByRevision(mpCommitSummaryCache->getCommitSummaries(), rev, index)) @@ -188,8 +204,6 @@ void RevisionsModel::afterCommitSummaryChanged(Revision rev) { - GSVN_ASSERT(mError.isNull()); - int row = -1; if (CommitSummaryFinder::findByRevision(mpCommitSummaryCache->getCommitSummaries(), rev, row)) emit dataChanged(index(row,0), index(row,columnCount())); @@ -201,9 +215,19 @@ { Q_UNUSED(startRevision); Q_UNUSED(endRevision); - if (mpCommitSummaryCache->getCommitSummaries().size() == 0) - { - mError = error; - reset(); - } + if (startRevision.getType() == Revision::Uncommitted || endRevision.getType() == Revision::Uncommitted) + mUncommittedFetchError = error; + else + mCommittedFetchError = error; + reset(); } + +QStringList RevisionsModel::getFetchErrors() const +{ + QStringList errors; + if (!mCommittedFetchError.isNull()) + errors.push_back(mCommittedFetchError); + if (!mUncommittedFetchError.isNull()) + errors.push_back(mUncommittedFetchError); + return errors; +} Added: trunk/src/dialogs/updateToRevision.cpp =================================================================== --- trunk/src/dialogs/updateToRevision.cpp (rev 0) +++ trunk/src/dialogs/updateToRevision.cpp 2007-03-01 17:18:06 UTC (rev 165) @@ -0,0 +1,98 @@ +/*************************************************************************** + * 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/updateToRevision.h" +#include "dialogs/util.h" +#include "svn/helpers.h" +#include "svn/wc_info.h" +#include "svn/wc_operations.h" + +#include "ui_updateToRevision.h" + +#include <QFileDialog> +#include <QMessageBox> + +UpdateToRevisionDialog::UpdateToRevisionDialog(SvnOperationContext* pContext, QString repoPath, QWidget* pParent) : QDialog(pParent) +{ + mpUi = new Ui_UpdateToRevisionDialog(); + mpUi->setupUi(this); + + mpContext = pContext; + mRepoPath = repoPath; + mDirPath = ""; + + connect(mpUi->browseButton, SIGNAL(clicked()), this, SLOT(browse())); + connect(mpUi->updateButton, SIGNAL(clicked()), this, SLOT(update())); + + // Misc UI beautification + QString pathLabel = mpUi->pathLabel->text(); + pathLabel.replace("%s", mRepoPath); + mpUi->pathLabel->setText(pathLabel); + + int baseRevision; + QString error; + if (!Svn::getRepoBaseRevision(*mpContext, NULL, mRepoPath, baseRevision, error)) + { + QMessageBox::critical(this, "", error); + return; + } + mpUi->revisionsSpin->setValue(baseRevision); + mpUi->revisionsSpin->setMaximum(baseRevision); + + +#ifdef Q_WS_MAC + exchangeWidgets(mpUi->hboxLayout1, mpUi->updateButton, mpUi->cancelButton); +#endif +} + +UpdateToRevisionDialog::~UpdateToRevisionDialog() +{ + delete mpUi; + mpUi = NULL; +} + +void UpdateToRevisionDialog::browse() +{ + QString pathToUpdate = QFileDialog::getExistingDirectory(this, tr("Select directory to update"), + mRepoPath, QFileDialog::ShowDirsOnly); + if (pathToUpdate != "") + { + if (Svn::removePrefixNoCase(pathToUpdate, mRepoPath)) + mpUi->pathEdit->setText(pathToUpdate); + else + QMessageBox::critical(this, "Invalid path", "The selected directory is not part of the active repository."); + } +} + +void UpdateToRevisionDialog::update() +{ + QString relDirPath = mpUi->pathEdit->text(); + int revisionNum = mpUi->revisionsSpin->value(); + QString error; + if (updateToRevision(relDirPath, Revision::committed(revisionNum), error)) + accept(); + else + QMessageBox::critical(this, "Update failed", error); +} + +bool UpdateToRevisionDialog::updateToRevision(QString relDirPath, Revision rev, QString& rError) +{ + return Svn::update(*mpContext, mRepoPath, relDirPath, rev, rError); +} Modified: trunk/src/svn/wc_info.cpp =================================================================== --- trunk/src/svn/wc_info.cpp 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/src/svn/wc_info.cpp 2007-03-01 17:18:06 UTC (rev 165) @@ -22,6 +22,7 @@ #include "svn/helpers.h" #include "svn/server_access.h" +#include "svn/wc_operations.h" #include <svn_client.h> #include <svn_path.h> @@ -33,8 +34,21 @@ class SvnInfo { public: - bool getRepoUrls(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelCheckoutPath, QString& rRepoUrlWithPath, QString& rError) + struct RepoInfo { + QString mRelCheckoutPath; + QString mRepoUrlWithPath; + int mBaseRevision; + }; + bool getRepoInfo(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, RepoInfo& rRepoInfo, QString& rError) + { + if (!ctx) + { + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!Svn::initAuthProviders(rContext, ctx, rError)) + return false; + } + const char* fullCanonPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); svn_error_t* pError = svn_client_info(fullCanonPath, NULL, NULL, infoCallback, this, false, ctx, rContext.getAprPool()); if (pError) @@ -42,8 +56,7 @@ rError = Svn::formatSvnErrorMessage(pError); return false; } - rRelCheckoutPath = mRelativeRepoUrl; - rRepoUrlWithPath = mRepoUrlWithPath; + rRepoInfo = mInfo; return true; } @@ -52,35 +65,55 @@ { SvnInfo* pThis = (SvnInfo*)baton; + // Repo URL information 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."); - pThis->mRepoUrlWithPath = sRepoUrl; + pThis->mInfo.mRepoUrlWithPath = sRepoUrl; sRepoUrl.remove(0, sRootUrl.length()); - pThis->mRelativeRepoUrl = sRepoUrl; + pThis->mInfo.mRelCheckoutPath = sRepoUrl; + + // Repo revision information + pThis->mInfo.mBaseRevision = info->rev; + return NULL; } - QString mRelativeRepoUrl; - QString mRepoUrlWithPath; + RepoInfo mInfo; }; bool Svn::getRepoCheckoutUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) { - SvnInfo info; - QString ignored; - return info.getRepoUrls(rContext, fullRepoPath, ctx, rRelPath, ignored, rError); + SvnInfo getter; + SvnInfo::RepoInfo info; + if (!getter.getRepoInfo(rContext, fullRepoPath, ctx, info, rError)) + return false; + rRelPath = info.mRelCheckoutPath; + return true; } bool Svn::getRepoUrlWithPath(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rRelPath, QString fullRepoPath, QString& rError) { - SvnInfo info; - QString ignored; - return info.getRepoUrls(rContext, fullRepoPath, ctx, ignored, rRelPath, rError); + SvnInfo getter; + SvnInfo::RepoInfo info; + if (!getter.getRepoInfo(rContext, fullRepoPath, ctx, info, rError)) + return false; + rRelPath = info.mRepoUrlWithPath; + return true; } +bool Svn::getRepoBaseRevision(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString fullRepoPath, int& riBaseRevision, QString& rError) +{ + SvnInfo getter; + SvnInfo::RepoInfo info; + if (!getter.getRepoInfo(rContext, fullRepoPath, ctx, info, rError)) + return false; + riBaseRevision = info.mBaseRevision; + return true; +} + Modified: trunk/src/svn/wc_operations.cpp =================================================================== --- trunk/src/svn/wc_operations.cpp 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/src/svn/wc_operations.cpp 2007-03-01 17:18:06 UTC (rev 165) @@ -43,6 +43,15 @@ private: static void updateNotifyCallback(void *baton, const svn_wc_notify_t *notify, apr_pool_t *pool); + static svn_error_t* cancelCallback(void *cancel_baton) + { + Svn::Updater* pThis = (Svn::Updater*)cancel_baton; + if (pThis->mpContext->getStatus()->shouldCancel()) + return svn_error_create(SVN_ERR_CANCELLED, NULL, "User cancelled."); ; + + return SVN_NO_ERROR; + } + SvnOperationContext* mpContext; }; @@ -220,6 +229,8 @@ ctx->notify_func2 = updateNotifyCallback; ctx->notify_baton2 = this; + ctx->cancel_func = cancelCallback; + ctx->cancel_baton = this; svn_opt_revision_t svnRev = revision.getSvnRevision(); Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2007-01-30 04:23:58 UTC (rev 164) +++ trunk/ui/mainwindow.ui 2007-03-01 17:18:06 UTC (rev 165) @@ -321,9 +321,15 @@ <x>0</x> <y>0</y> <width>639</width> - <height>21</height> + <height>29</height> </rect> </property> + <widget class="QMenu" name="menu_File" > + <property name="title" > + <string>&File</string> + </property> + <addaction name="actionExit" /> + </widget> <widget class="QMenu" name="menuAdvanced" > <property name="title" > <string>Ad&vanced</string> @@ -332,12 +338,6 @@ <addaction name="action_Annotate" /> <addaction name="action_Cleanup" /> </widget> - <widget class="QMenu" name="menu_File" > - <property name="title" > - <string>&File</string> - </property> - <addaction name="actionExit" /> - </widget> <addaction name="menu_File" /> <addaction name="menuAdvanced" /> </widget> @@ -358,18 +358,18 @@ <property name="shortcut" > <string>Ctrl+Shift+U</string> </property> -</action> -<action name="action_Annotate" > + </action> + <action name="action_Annotate" > <property name="text" > - <string>&Annotate</string> + <string>&Annotate</string> </property> <property name="shortcut" > - <string>Ctrl+T</string> + <string>Ctrl+T</string> </property> -</action> -<action name="action_Cleanup" > + </action> + <action name="action_Cleanup" > <property name="text" > - <string>&Cleanup</string> + <string>&Cleanup</string> </property> </action> </widget> @@ -404,9 +404,9 @@ <y>285</y> </hint> </hints> -</connection> -<connection> - <sender>action_Cleanup</sender> + </connection> + <connection> + <sender>action_Cleanup</sender> <signal>triggered()</signal> <receiver>MainWindow</receiver> <slot>cleanup()</slot> @@ -421,5 +421,21 @@ </hint> </hints> </connection> + <connection> + <sender>actionUpdate_Path_to_Revision</sender> + <signal>triggered()</signal> + <receiver>MainWindow</receiver> + <slot>updateToRevision()</slot> + <hints> + <hint type="sourcelabel" > + <x>-1</x> + <y>-1</y> + </hint> + <hint type="destinationlabel" > + <x>319</x> + <y>295</y> + </hint> + </hints> + </connection> </connections> </ui> Added: trunk/ui/updateToRevision.ui =================================================================== --- trunk/ui/updateToRevision.ui (rev 0) +++ trunk/ui/updateToRevision.ui 2007-03-01 17:18:06 UTC (rev 165) @@ -0,0 +1,152 @@ +<ui version="4.0" > + <class>UpdateToRevisionDialog</class> + <widget class="QDialog" name="UpdateToRevisionDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>349</width> + <height>140</height> + </rect> + </property> + <property name="windowTitle" > + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" > + <property name="margin" > + <number>9</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLabel" name="pathLabel" > + <property name="lineWidth" > + <number>0</number> + </property> + <property name="text" > + <string>Path (relative to %s):</string> + </property> + <property name="margin" > + <number>-2</number> + </property> + <property name="indent" > + <number>3</number> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QLineEdit" name="pathEdit" /> + </item> + <item> + <widget class="QPushButton" name="browseButton" > + <property name="text" > + <string>Browse...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <spacer> + <property name="orientation" > + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType" > + <enum>QSizePolicy::MinimumExpanding</enum> + </property> + <property name="sizeHint" > + <size> + <width>20</width> + <height>10</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLabel" name="label_2" > + <property name="text" > + <string>Revision:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" > + <property name="margin" > + <number>0</number> + </property> + <property name="spacing" > + <number>6</number> + </property> + <item> + <widget class="QSpinBox" name="revisionsSpin" > + <property name="minimumSize" > + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="maximum" > + <number>1000000</number> + </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> + <item> + <widget class="QPushButton" name="updateButton" > + <property name="text" > + <string>Update</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelButton" > + <property name="text" > + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>cancelButton</sender> + <signal>clicked()</signal> + <receiver>UpdateToRevisionDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel" > + <x>301</x> + <y>116</y> + </hint> + <hint type="destinationlabel" > + <x>174</x> + <y>69</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-05-08 23:52:34
|
Revision: 7 Author: matthiasmiller Date: 2006-05-06 19:54:16 -0700 (Sat, 06 May 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=7&view=rev Log Message: ----------- branching dialog initialization for different platforms and improving UI for Windows and Mac Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/commit.h trunk/include/dialogs/move.h trunk/include/dialogs/open.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/move.cpp trunk/src/dialogs/open.cpp trunk/src/grandmas_svn.cpp trunk/ui/mainwindow.ui trunk/ui/open.ui Added Paths: ----------- trunk/include/dialogs/core/ trunk/include/dialogs/core/base.h trunk/src/dialogs/core/ trunk/src/dialogs/core/base.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/grandmas_svn.pro 2006-05-07 02:54:16 UTC (rev 7) @@ -110,9 +110,10 @@ TARGET = bin/grandmas-svn -OBJECTS_DIR = build/ +OBJECTS_DIR = build/obj MOC_DIR = build/moc UI_DIR = build/ui +RCC_DIR = build/rcc CONFIG += debug \ warn_on \ @@ -134,12 +135,14 @@ HEADERS += include/settings/userpaths.h \ include/dialogs/commit.h \ + include/dialogs/core/base.h \ include/dialogs/move.h \ include/dialogs/open.h \ include/dialogs/mainwindow.h \ src/grandmas_svn.h SOURCES += src/dialogs/commit.cpp \ + src/dialogs/core/base.cpp \ src/dialogs/mainwindow.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ Modified: trunk/include/dialogs/commit.h =================================================================== --- trunk/include/dialogs/commit.h 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/include/dialogs/commit.h 2006-05-07 02:54:16 UTC (rev 7) @@ -22,16 +22,19 @@ #ifndef DIALOGS_COMMIT_H_ #define DIALOGS_COMMIT_H_ -#include <QDialog> +#include "dialogs/core/base.h" class Ui_CommitDialog; -class CommitDialog : public QDialog +class CommitDialog : public BaseDialog { public: - CommitDialog(); + CommitDialog(QWidget* pParent); ~CommitDialog(); +protected: + virtual void initMac(); + private: Ui_CommitDialog* mpUi; }; Added: trunk/include/dialogs/core/base.h =================================================================== --- trunk/include/dialogs/core/base.h (rev 0) +++ trunk/include/dialogs/core/base.h 2006-05-07 02:54:16 UTC (rev 7) @@ -0,0 +1,43 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +#ifndef DIALOGS_CORE_BASE_H_ +#define DIALOGS_CORE_BASE_H_ + +#include <QDialog> + +class QBoxLayout; + +class BaseDialog : public QDialog +{ +public: + BaseDialog(QWidget* pParent=NULL); + +protected: + void init(); + + virtual void initX11(); + virtual void initMac(); + virtual void initWin(); + + void exchangeWidgets(QBoxLayout* pLayout, QWidget* pFirst, QWidget* pSecond); +}; + +#endif Modified: trunk/include/dialogs/move.h =================================================================== --- trunk/include/dialogs/move.h 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/include/dialogs/move.h 2006-05-07 02:54:16 UTC (rev 7) @@ -22,19 +22,22 @@ #ifndef DIALOGS_MOVE_H_ #define DIALOGS_MOVE_H_ -#include <QDialog> +#include "dialogs/core/base.h" class Ui_moveDialog; -class MoveDialog : public QDialog +class MoveDialog : public BaseDialog { Q_OBJECT public: - MoveDialog(); + MoveDialog(QWidget* pParent); ~MoveDialog(); private: + virtual void initMac(); + +private: Ui_moveDialog* mpUi; }; Modified: trunk/include/dialogs/open.h =================================================================== --- trunk/include/dialogs/open.h 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/include/dialogs/open.h 2006-05-07 02:54:16 UTC (rev 7) @@ -22,12 +22,13 @@ #ifndef DIALOGS_OPEN_H_ #define DIALOGS_OPEN_H_ -#include <QDialog> +#include "dialogs/core/base.h" class Ui_OpenDialog; class UserPathsModel; +class QKeyEvent; -class OpenDialog : public QDialog +class OpenDialog : public BaseDialog { Q_OBJECT @@ -43,6 +44,9 @@ private slots: void accept(); +protected: + virtual void initMac(); + private: Ui_OpenDialog* mpUi; UserPathsModel* mpPathsModel; Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/src/dialogs/commit.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -21,10 +21,12 @@ #include "dialogs/commit.h" #include "ui_commit.h" -CommitDialog::CommitDialog() +CommitDialog::CommitDialog(QWidget* pParent) : BaseDialog(pParent) { mpUi = new Ui_CommitDialog(); mpUi->setupUi(this); + + init(); } CommitDialog::~CommitDialog() @@ -32,3 +34,8 @@ delete mpUi; mpUi = NULL; } + +void CommitDialog::initMac() +{ + exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); +} Added: trunk/src/dialogs/core/base.cpp =================================================================== --- trunk/src/dialogs/core/base.cpp (rev 0) +++ trunk/src/dialogs/core/base.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -0,0 +1,67 @@ +/*************************************************************************** + * 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/core/base.h" + +#include <QBoxLayout> +#include <QPushButton> + +BaseDialog::BaseDialog(QWidget* pParent) : QDialog(pParent) +{ +} + +void BaseDialog::init() +{ +#if defined(Q_WS_X11) + initX11(); +#elif defined(Q_WS_MAC) + initMac(); +#elif defined(Q_WS_WIN) + initWin(); +#endif +} + +void BaseDialog::initX11() +{ +} + +void BaseDialog::initMac() +{ +} + +void BaseDialog::initWin() +{ +} + +void BaseDialog::exchangeWidgets(QBoxLayout* pLayout, QWidget* pFirstWidget, QWidget* pSecondWidget) +{ + // If both widgets are in the same layout, it's important to move them in the correct order. + int firstIndex = pLayout->indexOf(pFirstWidget); + int secondIndex = pLayout->indexOf(pSecondWidget); + Q_ASSERT(firstIndex != -1); + Q_ASSERT(secondIndex != -1); + Q_ASSERT(firstIndex < secondIndex); + + pLayout->removeWidget(pSecondWidget); + pLayout->insertWidget(firstIndex, pSecondWidget); + + pLayout->removeWidget(pFirstWidget); + pLayout->insertWidget(secondIndex, pFirstWidget); +} Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/src/dialogs/mainwindow.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -58,12 +58,12 @@ void MainWindow::commit() { - CommitDialog dlg; + CommitDialog dlg(this); dlg.exec(); } void MainWindow::move() { - MoveDialog dlg; + MoveDialog dlg(this); dlg.exec(); } Modified: trunk/src/dialogs/move.cpp =================================================================== --- trunk/src/dialogs/move.cpp 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/src/dialogs/move.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -21,10 +21,11 @@ #include "dialogs/move.h" #include "ui_move.h" -MoveDialog::MoveDialog() +MoveDialog::MoveDialog(QWidget* pParent) : BaseDialog(pParent) { mpUi = new Ui_moveDialog(); mpUi->setupUi(this); + init(); } MoveDialog::~MoveDialog() @@ -33,3 +34,7 @@ mpUi = NULL; } +void MoveDialog::initMac() +{ + exchangeWidgets(mpUi->hboxLayout2, mpUi->okButton, mpUi->cancelButton); +} Modified: trunk/src/dialogs/open.cpp =================================================================== --- trunk/src/dialogs/open.cpp 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/src/dialogs/open.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -29,6 +29,8 @@ mpUi = new Ui_OpenDialog(); mpUi->setupUi(this); mpUi->workingCopyListView->setModel(mpPathsModel); + + init(); } OpenDialog::~OpenDialog() @@ -55,3 +57,7 @@ } } +void OpenDialog::initMac() +{ + exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); +} Modified: trunk/src/grandmas_svn.cpp =================================================================== --- trunk/src/grandmas_svn.cpp 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/src/grandmas_svn.cpp 2006-05-07 02:54:16 UTC (rev 7) @@ -33,7 +33,7 @@ #ifdef Q_WS_MAC initMac(); #else - connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()) ); + connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit())); #endif // Show OpenDialog on startup Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/ui/mainwindow.ui 2006-05-07 02:54:16 UTC (rev 7) @@ -118,6 +118,9 @@ <property name="text" > <string>Commit Log Entry:</string> </property> + <property name="buddy" > + <cstring>logEdit</cstring> + </property> </widget> </item> <item> @@ -141,6 +144,9 @@ <property name="text" > <string>Changes:</string> </property> + <property name="buddy" > + <cstring>changesTableView</cstring> + </property> </widget> </item> <item> @@ -266,6 +272,9 @@ <property name="text" > <string>Recent Activity:</string> </property> + <property name="buddy" > + <cstring>revisionsTableView</cstring> + </property> </widget> </item> <item> Modified: trunk/ui/open.ui =================================================================== --- trunk/ui/open.ui 2006-05-04 04:22:39 UTC (rev 6) +++ trunk/ui/open.ui 2006-05-07 02:54:16 UTC (rev 7) @@ -28,8 +28,11 @@ <item> <widget class="QLabel" name="workingCopylabel" > <property name="text" > - <string>Working Copy:</string> + <string>&Working Copy:</string> </property> + <property name="buddy" > + <cstring>workingCopyListView</cstring> + </property> </widget> </item> <item> @@ -133,7 +136,7 @@ </connection> <connection> <sender>workingCopyListView</sender> - <signal>doubleClicked(QModelIndex)</signal> + <signal>activated(QModelIndex)</signal> <receiver>OpenDialog</receiver> <slot>accept()</slot> <hints> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-07-31 16:19:21
|
Revision: 8 Author: highjinx Date: 2006-07-31 09:19:11 -0700 (Mon, 31 Jul 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=8&view=rev Log Message: ----------- Misc initial work on getting modifications Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/svn/file_access.h trunk/include/svn/modification.h trunk/include/svn/revision.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.pro =================================================================== --- trunk/grandmas_svn.pro 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/grandmas_svn.pro 2006-07-31 16:19:11 UTC (rev 8) @@ -58,7 +58,7 @@ SVN_INCLUDE_DIR = $$(SVN_DEV_DIR)\include SVN_LIB_DIR = $$(SVN_DEV_DIR)\lib - INCLUDEPATH += $${SVN_INCLUDE_DIR} + INCLUDEPATH += $${SVN_INCLUDE_DIR} INCLUDEPATH += $${SVN_INCLUDE_DIR}\apr INCLUDEPATH += $${SVN_INCLUDE_DIR}\apr-util INCLUDEPATH += $${SVN_INCLUDE_DIR}\apr-iconv @@ -115,7 +115,7 @@ UI_DIR = build/ui RCC_DIR = build/rcc -CONFIG += debug \ +CONFIG += release \ warn_on \ qt \ thread \ @@ -139,6 +139,9 @@ include/dialogs/move.h \ include/dialogs/open.h \ include/dialogs/mainwindow.h \ + include/svn/server_access.h \ + include/svn/modification.h \ + include/svn/revision.h \ src/grandmas_svn.h SOURCES += src/dialogs/commit.cpp \ @@ -146,6 +149,9 @@ src/dialogs/mainwindow.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/svn/server_access.cpp \ + src/svn/modification.cpp \ + src/svn/revision.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ src/settings/userpaths.cpp Modified: trunk/include/svn/file_access.h =================================================================== --- trunk/include/svn/file_access.h 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/include/svn/file_access.h 2006-07-31 16:19:11 UTC (rev 8) @@ -27,7 +27,7 @@ { public: bool init(QString fullRepoPath, Revision oldRevision, Revision newRevision, QString& rError); - bool getOldFile(QString relFilePath, QString& rFilePath, ServerAccess& rAccess, QString& rError); - bool getNewFile(QString relFilePath, QString& rFilePath, ServerAccess& rAccess, QString& rError); - bool getDiff(QString relFilePath, QString& rDiff, ServerAccess& rAccess, QString& rError); + bool getOldFile(ServerAccess& rAccess, QString relFilePath, QString& rCreatedFilePath, QString& rError); + bool getNewFile(ServerAccess& rAccess, QString relFilePath, QString& rCreatedFilePath, QString& rError); + bool getDiff(ServerAccess& rAccess, QString relLeftFilePath, QString relRightFilePath, QString& rDiff, QString& rError); }; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/include/svn/modification.h 2006-07-31 16:19:11 UTC (rev 8) @@ -18,21 +18,72 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <Qt> +#include "revision.h" -class ModificationSummary +#include <QList> +#include <QString> + +class SvnOperationContext; +struct svn_wc_status2_t; +struct svn_client_ctx_t; + +class Modification { public: enum Type { + Type_TextMod, Type_Add, Type_Delete, - Type_TextMod, - Type_PropertyMod + Type_Move, + Type_PropMod, + Type_Copy, + + // Pseudo-types: types that are not modifications, but need to be displayed + Type_New, // exists, but has not been added + Type_Missing, + Type_Conflicting, }; - Type getType(); - QString getRelFilePath(); + QString getFilePath(); - bool isAddedWithHistory(QString& rSrcFilePath); + // Only use for move and copy mods + QString getDestFilePath(); + +private: + friend class Modifications; + + Type mType; + QString mFilePath; + QString mDestFilePath; + Revision oldRevision; + Revision newRevision; }; + +class SvnOperation +{ +public: + bool initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& rError); +}; + +class Modifications : public SvnOperation +{ +public: + bool init(SvnOperationContext& rContext, QString path, Revision revision, QString& rError); + + void getModifications(QList<Modification>& rModifications); + bool uncommittedFileIsConflicted(Modification modification); +protected: + SvnOperationContext* mpContext; + Revision mRevision; + + QList<Modification> mModifications; + QList<bool> mModificationIsConflicted; + +public: + void statusCallback(void *baton, const char *path, svn_wc_status2_t *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); +}; + + Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/include/svn/revision.h 2006-07-31 16:19:11 UTC (rev 8) @@ -20,21 +20,26 @@ #include <Qt> +#include <svn_wc.h> + class Revision { public: - void SetHeadRevision(); - void SetBaseRevision(); - void SetCommittedRevision(int revision); + Revision(); + ~Revision(); - enum Type - { - Type_Head, - Type_Base, - Type_Committed - }; + void setUncommittedRevision(); + void setCommittedRevision(int revision); - Type GetType(); - int GetCommittedRevision(); + bool isCommittedRevision(); + int getCommittedRevision(); + +// svn wrapper functions +public: + svn_opt_revision_t getSvnRevision(); + +private: + bool mIsCommitted; + int mCommittedRevision; }; Modified: trunk/include/svn/server_access.h =================================================================== --- trunk/include/svn/server_access.h 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/include/svn/server_access.h 2006-07-31 16:19:11 UTC (rev 8) @@ -18,11 +18,55 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <QString> -class ServerAccess +struct apr_pool_t; + +class SvnOperationStatus { public: - void* GetStatusDisplay(); - void* GetAuthenticationCallback(); + virtual ~SvnOperationStatus() {} + virtual void update(QString textToAdd)=0; + //virtual void update(int progressPercent)=0; // maybe someday? + + virtual bool shouldCancel()=0; }; +class SvnAuthentication +{ +public: + virtual ~SvnAuthentication() {} + + bool getAuthentication(QString defaultUsername) + { + mUsername = defaultUsername; + mPassword = ""; + return getAuthentication(mUsername, mPassword); + } + const char* getUsername() { return mUsername.toAscii(); } + const char* getPassword() { return mPassword.toAscii(); } + +protected: + virtual bool getAuthentication(QString& rUsername, QString& rPassword)=0; + + QString mUsername; + QString mPassword; +}; + +class SvnOperationContext +{ +public: + SvnOperationContext(apr_pool_t* pMainPool, SvnOperationStatus& rStatus, SvnAuthentication& rAuthentication); + ~SvnOperationContext(); + +// used by svn layer + apr_pool_t* getAprPool() const { return mpSubPool; } + SvnOperationStatus* getStatus() const { return mpStatus; } + SvnAuthentication* getAuthenticationCallback() const { return mpAuthentication; } + +private: + apr_pool_t* mpSubPool; + SvnOperationStatus* mpStatus; + SvnAuthentication* mpAuthentication; +}; + Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/src/main.cpp 2006-07-31 16:19:11 UTC (rev 8) @@ -19,9 +19,62 @@ ***************************************************************************/ #include "grandmas_svn.h" +#include <svn/modification.h> +#include <svn/server_access.h> +#include <apr_general.h> + + +class QSvnOperationStatus : public SvnOperationStatus +{ +public: + virtual void update(QString textToAdd) + { + textToAdd = textToAdd; + } + + virtual bool shouldCancel() + { + return false; + } +}; + +class QSvnAuthentication : public SvnAuthentication +{ +public: + virtual bool getAuthentication(QString& rUsername, QString& rPassword) + { + rUsername = ""; + rPassword = ""; + return false; + } +}; + int main(int argc, char** argv) { +// BEGIN TEST CODE + apr_status_t rv = apr_initialize(); + if (rv != APR_SUCCESS) + return -1; + + apr_pool_t* pool; + apr_pool_create(&pool, NULL); + + QSvnOperationStatus status; + QSvnAuthentication auth; + SvnOperationContext context(pool, status, auth);; + + QString error; + Revision revision; + revision.setCommittedRevision(5); + + Modifications mods; + mods.init(context, "/home/joshn/projects/gsvn", revision, error); + + apr_pool_destroy(pool); + +// END TEST CODE + GrandmasSVNApp app(argc, argv); return app.exec(); } Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/src/svn/modification.cpp 2006-07-31 16:19:11 UTC (rev 8) @@ -19,16 +19,256 @@ ***************************************************************************/ #include <svn/modification.h> +#include <svn/server_access.h> -ModificationSummary::Type ModificationSummary::getType() +#include <apr_pools.h> +#include <assert.h> +#include <iostream> +#include <svn_client.h> +#include <svn_path.h> +#include <svn_pools.h> + +using namespace std; + +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; + SvnAuthentication* pAuth = ((SvnAuthentication*)baton); + if (!pAuth->getAuthentication(promptUsername)) + 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(); + lcred->password = pAuth->getPassword(); + + // tell svn if the credentials need to be saved + lcred->may_save = true; + *cred = lcred; + + return SVN_NO_ERROR; + } + + +bool SvnOperation::initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& /*rError*/) +{ + apr_array_header_t *providers = apr_array_make(rContext.getAprPool(), 3, sizeof(svn_auth_provider_object_t *)); + + svn_auth_provider_object_t *provider; + + svn_client_get_simple_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + svn_client_get_username_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + svn_client_get_simple_prompt_provider(&provider, simpleAuthPrompt, rContext.getAuthenticationCallback(), 100000000, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + // TODO: add ssl providers + + svn_auth_baton_t *authBaton; + svn_auth_open(&authBaton, providers, rContext.getAprPool()); + + context->auth_baton = authBaton; + return true; } -QString ModificationSummary::getRelFilePath() +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; } -bool ModificationSummary::isAddedWithHistory(QString& rSrcFilePath) +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; + + 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; + + svn_error_t* pError = NULL; + if (revision.isCommittedRevision()) + { + svn_opt_revision_t startRev = svnRevisionFromRevision(revision); + svn_opt_revision_t endRev = svnRevisionFromRevision(revision); + 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()); + + pError = svn_client_log2(array, + &startRev, + &endRev, + 0/*limit*/, + true/*discover_changed_paths*/, + false/*strict_node_history*/, + ::logCallback, + this, + ctx, + rServer.getAprPool()); + } + else + { + svn_opt_revision_t svnRevision = svnRevisionFromRevision(revision); + pError = svn_client_status2(NULL, path.toAscii(), &svnRevision, + ::statusCallback, + this, + true/*recurse*/, + false/*get_all*/, + false/*update*/, + false /*no_ignore*/, + true/*ignore_externals*/, + ctx/*svn_client_ctx_t *ctx*/, + rServer.getAprPool()); + } + if (pError) + { + rError = pError->message; + cout << (const char*)rError.toAscii() << endl; + return false; + } + return true; +} + +void Modifications::getModifications(QList<Modification>& rModifications) +{ + rModifications = mModifications; +} + +bool Modifications::uncommittedFileIsConflicted(Modification /*modification*/) +{ + return false; +} + +void Modifications::statusCallback(void */*baton*/, const char *path, svn_wc_status2_t *status) +{ + Modification mod; + mod.newRevision = mRevision; + + // Set old revision to base, if the file is already under version control + if (status->entry) + mod.oldRevision.setCommittedRevision(status->entry->revision); + + switch (status->text_status) + { + // cases we care about + case svn_wc_status_unversioned: + mod.mFilePath = path; + mod.mType = Modification::Type_New; + break; + case svn_wc_status_added: + mod.mFilePath = path; + mod.mType = Modification::Type_Add; + 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; + + // cases we can ignore + case svn_wc_status_ignored: + case svn_wc_status_obstructed: + case svn_wc_status_merged: + case svn_wc_status_normal: + case svn_wc_status_none: + return; + + // cases we need to learn how to handle + case svn_wc_status_replaced: + case svn_wc_status_incomplete: + case svn_wc_status_external: + assert(false); + break; + + } + 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) +{ + for (apr_hash_index_t* pKey = apr_hash_first(pool, changed_paths); pKey; pKey = apr_hash_next(pKey)) + { + char *path; + void *val; + apr_hash_this(pKey, (const void **)&path, NULL, &val); + + 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); + switch (log_item->action) + { + case 'A': + mod.mType = Modification::Type_Add; + break; + case 'D': + mod.mType = Modification::Type_Delete; + break; + case 'R': + // TODO: handle "replace" + mod.mType = Modification::Type_Add; + break; + case 'M': + mod.mType = Modification::Type_TextMod; + break; + default: + // TODO: return error + break; + } + mModifications.append(mod); + } + + return NULL; +} + Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2006-05-07 02:54:16 UTC (rev 7) +++ trunk/src/svn/revision.cpp 2006-07-31 16:19:11 UTC (rev 8) @@ -20,23 +20,42 @@ #include <svn/revision.h> -void Revision::SetHeadRevision() +Revision::Revision() { + mIsCommitted = false; + mCommittedRevision = -1; } -void Revision::SetBaseRevision() +Revision::~Revision() { } -void Revision::SetCommittedRevision(int revision) +void Revision::setUncommittedRevision() { + mIsCommitted = false; } -Revision::Type Revision::GetType() +void Revision::setCommittedRevision(int revision) { + mIsCommitted = true; + mCommittedRevision = revision; } -int Revision::GetCommittedRevision() +bool Revision::isCommittedRevision() { + return mIsCommitted; } +int Revision::getCommittedRevision() +{ +// assert(mIsCommitted); + return mCommittedRevision; +} + +svn_opt_revision_t Revision::getSvnRevision() +{ + svn_opt_revision_t svnRev; + svnRev.value.number = mCommittedRevision; + return svnRev; +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-08-09 00:52:43
|
Revision: 11 Author: matthiasmiller Date: 2006-08-08 17:52:38 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=11&view=rev Log Message: ----------- implement open dialog Modified Paths: -------------- trunk/include/dialogs/open.h trunk/include/settings/userpaths.h trunk/src/dialogs/open.cpp trunk/src/grandmas_svn.cpp trunk/src/grandmas_svn.h trunk/src/main.cpp trunk/src/settings/userpaths.cpp Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Name: svn:ignore - *.pcs *.kdevses Makefile Makefile.Debug Makefile.Release bin build debug release object_script.grandmas-svn.Debug object_script.grandmas-svn.Release + *.pcs *.kdevses Makefile Makefile.Debug Makefile.Release bin build debug release object_script.grandmas-svn.Debug object_script.grandmas-svn.Release grandmas-svn.xcodeproj Info.plist Modified: trunk/include/dialogs/open.h =================================================================== --- trunk/include/dialogs/open.h 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/include/dialogs/open.h 2006-08-09 00:52:38 UTC (rev 11) @@ -27,22 +27,22 @@ class Ui_OpenDialog; class UserPathsModel; class QKeyEvent; +class QSettings; class OpenDialog : public BaseDialog { Q_OBJECT public: - OpenDialog(); + OpenDialog(QSettings* pSettings); ~OpenDialog(); - bool load(QString& rError); - signals: void openPath(QString path); private slots: void accept(); + void openOther(); protected: virtual void initMac(); Modified: trunk/include/settings/userpaths.h =================================================================== --- trunk/include/settings/userpaths.h 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/include/settings/userpaths.h 2006-08-09 00:52:38 UTC (rev 11) @@ -21,20 +21,38 @@ #include <QAbstractItemModel> #include <QStringList> +class QSettings; + class UserPathsModel : public QAbstractListModel { public: - UserPathsModel(); + UserPathsModel(QSettings* pSettings); virtual ~UserPathsModel(); - bool load(QString& rError); - virtual int rowCount(const QModelIndex& rcParent = QModelIndex()) const; virtual QVariant data(const QModelIndex& rcIndex, int role = Qt::DisplayRole) const; QString getPath(const QModelIndex& rcIndex) const; + QModelIndex addPath(QString path); private: - QStringList mNames, mPaths; + class WorkingCopy + { + public: + WorkingCopy(QString path); + QString getDisplayName() const; + QString getPath() const; + bool operator<(const WorkingCopy& rcOther) const; + + static void load(QSettings* pSettings, QList<WorkingCopy>& rWorkingCopies); + static void save(QSettings* pSettings, const QList<WorkingCopy>& rcWorkingCopies); + static void sort(QList<WorkingCopy>& rWorkingCopies); + + private: + QString mPath; + }; + + QSettings* mpSettings; + QList<WorkingCopy> mWorkingCopies; }; Modified: trunk/src/dialogs/open.cpp =================================================================== --- trunk/src/dialogs/open.cpp 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/src/dialogs/open.cpp 2006-08-09 00:52:38 UTC (rev 11) @@ -21,14 +21,17 @@ #include "dialogs/open.h" #include "settings/userpaths.h" #include "ui_open.h" +#include <QFileDialog> +#include <QMessageBox> -OpenDialog::OpenDialog() +OpenDialog::OpenDialog(QSettings* pSettings) { - mpPathsModel = new UserPathsModel(); + mpPathsModel = new UserPathsModel(pSettings); mpUi = new Ui_OpenDialog(); mpUi->setupUi(this); mpUi->workingCopyListView->setModel(mpPathsModel); + connect(mpUi->otherButton, SIGNAL(clicked()), this, SLOT(openOther())); init(); } @@ -42,11 +45,6 @@ mpUi = NULL; } -bool OpenDialog::load(QString& rError) -{ - return mpPathsModel->load(rError); -} - void OpenDialog::accept() { QModelIndex index = mpUi->workingCopyListView->currentIndex(); @@ -57,6 +55,18 @@ } } +void OpenDialog::openOther() +{ + QString other = QFileDialog::getExistingDirectory(this); + if (!other.isNull()) + { + // TODO: give an error if this is not a valid working copy + QModelIndex index = mpPathsModel->addPath(other); + mpUi->workingCopyListView->setCurrentIndex(index); + mpUi->workingCopyListView->setFocus(); + } +} + void OpenDialog::initMac() { exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); Modified: trunk/src/grandmas_svn.cpp =================================================================== --- trunk/src/grandmas_svn.cpp 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/src/grandmas_svn.cpp 2006-08-09 00:52:38 UTC (rev 11) @@ -23,7 +23,7 @@ #include "dialogs/open.h" #include <QMenuBar> -#include <QMessageBox> +#include <QSettings> GrandmasSVNApp::GrandmasSVNApp(int& argc, char** argv) : QApplication(argc, argv) { @@ -42,6 +42,9 @@ GrandmasSVNApp::~GrandmasSVNApp() { + delete mpOpenDlg; + mpOpenDlg = NULL; + delete mpAppMenu; mpAppMenu = NULL; } @@ -59,6 +62,11 @@ pOpen->setShortcut(tr("Ctrl+O")); } +QSettings* GrandmasSVNApp::createSettings() +{ + return new QSettings(QSettings::IniFormat, QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName()); +} + void GrandmasSVNApp::open() { if (mpOpenDlg) @@ -68,14 +76,12 @@ } else { - mpOpenDlg = new OpenDialog(); + QSettings* pSettings = createSettings(); + mpOpenDlg = new OpenDialog(pSettings); + pSettings->setParent(mpOpenDlg); + connect(mpOpenDlg, SIGNAL(openPath(QString)), this, SLOT(openPath(QString))); connect(mpOpenDlg, SIGNAL(finished(int)), this, SLOT(open_done(int))); - - QString error; - if (!mpOpenDlg->load(error)) - QMessageBox::critical(NULL, error, tr("Grandma's SVN")); - mpOpenDlg->show(); } } Modified: trunk/src/grandmas_svn.h =================================================================== --- trunk/src/grandmas_svn.h 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/src/grandmas_svn.h 2006-08-09 00:52:38 UTC (rev 11) @@ -26,6 +26,7 @@ class OpenDialog; class QMenuBar; +class QSettings; class GrandmasSVNApp : public QApplication { @@ -37,6 +38,7 @@ private: void initMac(); + static QSettings* createSettings(); private slots: void open(); @@ -47,6 +49,7 @@ private: QMenuBar* mpAppMenu; OpenDialog* mpOpenDlg; + QSettings* mpSettings; }; #endif Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/src/main.cpp 2006-08-09 00:52:38 UTC (rev 11) @@ -52,6 +52,11 @@ int main(int argc, char** argv) { + // This information is used for the QSettings object. + QCoreApplication::setOrganizationName("grandmas-svn.org"); + QCoreApplication::setOrganizationDomain("grandmas-svn.org"); + QCoreApplication::setApplicationName("Grandma's SVN"); + // BEGIN TEST CODE apr_status_t rv = apr_initialize(); if (rv != APR_SUCCESS) Modified: trunk/src/settings/userpaths.cpp =================================================================== --- trunk/src/settings/userpaths.cpp 2006-07-31 16:33:15 UTC (rev 10) +++ trunk/src/settings/userpaths.cpp 2006-08-09 00:52:38 UTC (rev 11) @@ -19,31 +19,93 @@ ***************************************************************************/ #include "settings/userpaths.h" +#include <QDir> +#include <QSettings> -UserPathsModel::UserPathsModel() +UserPathsModel::WorkingCopy::WorkingCopy(QString path) { + mPath = path; } -UserPathsModel::~UserPathsModel() +QString UserPathsModel::WorkingCopy::getDisplayName() const { + return QDir(mPath).dirName(); } -bool UserPathsModel::load(QString& rError) +QString UserPathsModel::WorkingCopy::getPath() const { -// BEGIN SCAFFOLDING - mNames.push_back(tr("Foo")); - mPaths.push_back(tr("Foo")); - mNames.push_back(tr("Bar")); - mPaths.push_back(tr("Bar")); - rError = ""; - return true; -// END SCAFFOLDING + return mPath; } +bool UserPathsModel::WorkingCopy::operator <(const UserPathsModel::WorkingCopy& rcOther) const +{ + int result = getDisplayName().compare(rcOther.getDisplayName()); + if (result == 0) + result = getPath().compare(rcOther.getPath()); + return result < 0; +} + +void UserPathsModel::WorkingCopy::load(QSettings* pSettings, QList<WorkingCopy>& rWorkingCopies) +{ + rWorkingCopies.empty(); + + // load working copy locations + int numWCs = pSettings->beginReadArray("WorkingCopies"); + for (int wc = 0; wc < numWCs; wc++) + { + pSettings->setArrayIndex(wc); + + QString path = pSettings->value("Path").toString(); + // TODO: check for valid repository? + if (QDir(path).exists()) + rWorkingCopies.push_back(WorkingCopy(path)); + } + pSettings->endArray(); + + sort(rWorkingCopies); +} + +void UserPathsModel::WorkingCopy::save(QSettings* pSettings, const QList<WorkingCopy>& rcWorkingCopies) +{ + pSettings->beginWriteArray("WorkingCopies"); + for (int wc = 0; wc < rcWorkingCopies.size(); wc++) + { + pSettings->setArrayIndex(wc); + pSettings->setValue("Path", rcWorkingCopies.at(wc).getPath()); + } + pSettings->endArray(); +} + +void UserPathsModel::WorkingCopy::sort(QList<WorkingCopy>& rWorkingCopies) +{ + qSort(rWorkingCopies); + + // remove duplicates + QList<WorkingCopy>::iterator iter = rWorkingCopies.begin(); + while (iter != rWorkingCopies.end()) + { + if (qBinaryFind(iter+1, rWorkingCopies.end(), *iter) != rWorkingCopies.end()) + iter = rWorkingCopies.erase(iter); + else + iter++; + } +} + + + +UserPathsModel::UserPathsModel(QSettings* pSettings) +{ + mpSettings = pSettings; + WorkingCopy::load(mpSettings, mWorkingCopies); +} + +UserPathsModel::~UserPathsModel() +{ +} + int UserPathsModel::rowCount(const QModelIndex& /*rcParent*/) const { - Q_ASSERT(mNames.count() == mPaths.count()); - return mNames.count(); + return mWorkingCopies.count(); } QVariant UserPathsModel::data(const QModelIndex& rcIndex, int role) const @@ -51,18 +113,31 @@ if (!rcIndex.isValid()) return QVariant(); - if (rcIndex.row() >= mNames.size()) + if (rcIndex.row() >= mWorkingCopies.size()) return QVariant(); if (role != Qt::DisplayRole) return QVariant(); - return mNames.at(rcIndex.row()); + return mWorkingCopies.at(rcIndex.row()).getDisplayName(); } QString UserPathsModel::getPath(const QModelIndex& rcIndex) const { Q_ASSERT(rcIndex.isValid() && rcIndex.row() <= mPaths.size()); - return mPaths.at(rcIndex.row()); + return mWorkingCopies.at(rcIndex.row()).getPath(); } +QModelIndex UserPathsModel::addPath(QString path) +{ + WorkingCopy wc(path); + mWorkingCopies.push_back(wc); + WorkingCopy::sort(mWorkingCopies); + WorkingCopy::save(mpSettings, mWorkingCopies); + emit layoutChanged(); + + int offset = qBinaryFind(mWorkingCopies.begin(), mWorkingCopies.end(), WorkingCopy(wc)) - mWorkingCopies.begin(); + Q_ASSERT(offset >= 0); + Q_ASSERT(offset < mWorkingCopies.size()); + return index(offset, 0); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-08-09 06:36:02
|
Revision: 13 Author: matthiasmiller Date: 2006-08-08 23:35:51 -0700 (Tue, 08 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=13&view=rev Log Message: ----------- add unit tests that can be run from the command-line Modified Paths: -------------- trunk/grandmas_svn.pro trunk/src/main.cpp Added Paths: ----------- trunk/include/commandline.h trunk/src/commandline.cpp trunk/tests/ trunk/tests/commandlinetest.cpp trunk/tests/commandlinetest.h trunk/tests/tests.cpp trunk/tests/tests.h Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-09 01:41:08 UTC (rev 12) +++ trunk/grandmas_svn.pro 2006-08-09 06:35:51 UTC (rev 13) @@ -133,26 +133,43 @@ RESOURCES = ui/grandmas-svn.qrc RC_FILE = ui/icons/win32.rc -HEADERS += include/settings/userpaths.h \ +HEADERS += include/commandline.h \ include/dialogs/commit.h \ include/dialogs/core/base.h \ include/dialogs/move.h \ include/dialogs/open.h \ include/dialogs/mainwindow.h \ + include/settings/userpaths.h \ include/svn/server_access.h \ include/svn/modification.h \ include/svn/revision.h \ src/grandmas_svn.h -SOURCES += src/dialogs/commit.cpp \ +SOURCES += src/commandline.cpp \ + src/dialogs/commit.cpp \ src/dialogs/core/base.cpp \ src/dialogs/mainwindow.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/grandmas_svn.cpp \ + src/main.cpp \ + src/settings/userpaths.cpp \ src/svn/server_access.cpp \ src/svn/modification.cpp \ - src/svn/revision.cpp \ - src/grandmas_svn.cpp \ - src/main.cpp \ - src/settings/userpaths.cpp + src/svn/revision.cpp + +# UNIT TESTS + +debug { + DEFINES += GSVN_TESTS +} +contains(DEFINES, GSVN_TESTS) { + CONFIG += qtestlib + HEADERS += tests/commandlinetest.h \ + tests/tests.h + SOURCES += tests/commandlinetest.cpp \ + tests/tests.cpp + LIBS += -lsvn_repos-1 +} + Added: trunk/include/commandline.h =================================================================== --- trunk/include/commandline.h (rev 0) +++ trunk/include/commandline.h 2006-08-09 06:35:51 UTC (rev 13) @@ -0,0 +1,56 @@ +/*************************************************************************** + * 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 <QChar> +#include <QList> +#include <QObject> +#include <QStringList> + +class CommandLine : public QObject +{ +public: + void addAvailableOption(QChar shortName, QString longName, QString desc, bool canHaveValue); + + bool parse(int argc, char** argv, QString& rError); + bool parse(const QStringList& rcArgs, QString& rError); + QString usage(); + + // must correspond with addAvailableOption + bool checkOption(QChar shortName, QString longName); + bool checkOption(QChar shortName, QString longName, QString& rValue); + +private: + bool setArgByShortName(QChar shortName, QString& rError); + bool setArgByLongName(QString longName, QString value, QString& rError); + + struct CommandLineOption + { + QChar shortName; + QString longName; + QString desc; + bool canHaveValue; + + bool isSet; + QString value; + }; + + QList<CommandLineOption> mOptions; +}; + Added: trunk/src/commandline.cpp =================================================================== --- trunk/src/commandline.cpp (rev 0) +++ trunk/src/commandline.cpp 2006-08-09 06:35:51 UTC (rev 13) @@ -0,0 +1,195 @@ +/*************************************************************************** + * 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 "commandline.h" + +void CommandLine::addAvailableOption(QChar shortName, QString longName, QString desc, bool canHaveValue) +{ + Q_ASSERT(!shortName.isNull() || !longName.isEmpty()); + Q_FOREACH(CommandLineOption opt, mOptions) + { + // verify uniqueness of names + Q_ASSERT(shortName.isNull() || shortName != opt.shortName); + Q_ASSERT(longName.isEmpty() || longName != opt.longName); + } + + // register the option + CommandLineOption opt; + opt.shortName = shortName; + opt.longName = longName; + opt.desc = desc; + opt.canHaveValue = canHaveValue; + opt.isSet = false; + Q_UNUSED(opt.value); + mOptions.push_back(opt); +} + +bool CommandLine::parse(int argc, char** argv, QString& rError) +{ + argc--; + argv++; + + QStringList args; + while (args.size() < argc) + args.push_back(argv[args.size()]); + return parse(args, rError); +} + +bool CommandLine::parse(const QStringList& rcArgs, QString& rError) +{ + for (QStringList::const_iterator iter = rcArgs.begin(); iter != rcArgs.end(); iter++) + { + if (iter->startsWith("--")) + { + // long names + QString longName = iter->mid(2); + + QString value; + if (iter+1 != rcArgs.end() && !(iter+1)->startsWith("-")) + { + iter++; + value = *iter; + } + + if (!setArgByLongName(longName, value, rError)) + return false; + } + else if (iter->startsWith("-")) + { + // short names + if (*iter == "-") + { + rError = tr("Invalid parameter: %1").arg(*iter); + return false; + } + for (int i = 1; i < iter->length(); i++) + { + if (!setArgByShortName(iter->at(i), rError)) + return false; + } + } + else + { + rError = tr("Invalid parameter: %1").arg(*iter); + return false; + } + } + + return true; +} + +QString CommandLine::usage() +{ + return tr(""); +} + +bool CommandLine::checkOption(QChar shortName, QString longName) +{ + Q_FOREACH(const CommandLineOption& rOpt, mOptions) + { + if (rOpt.shortName == shortName && rOpt.longName == longName) + return rOpt.isSet; + } + + Q_ASSERT(false); + return false; +} + +bool CommandLine::checkOption(QChar shortName, QString longName, QString& rValue) +{ + Q_FOREACH(const CommandLineOption& rOpt, mOptions) + { + if (rOpt.shortName == shortName && rOpt.longName == longName) + { + Q_ASSERT(rOpt.canHaveValue); + rValue = rOpt.value; + return rOpt.isSet; + } + } + + Q_ASSERT(false); + return false; +} + +bool CommandLine::setArgByShortName(QChar shortName, QString& rError) +{ + for (int opt = 0; opt < mOptions.size(); opt++) + { + if (mOptions[opt].shortName.isNull()) + continue; + + if (mOptions[opt].shortName != shortName) + continue; + + if (!mOptions[opt].value.isNull()) + { + Q_ASSERT(rOpt.isSet); + rError = tr("Duplicate parameter: %1").arg(shortName); + return false; + } + + mOptions[opt].isSet = true; + return true; + } + + rError = tr("Invalid parameter: %1").arg(shortName); + return false; +} + +bool CommandLine::setArgByLongName(QString longName, QString value, QString& rError) +{ + for (int opt = 0; opt < mOptions.size(); opt++) + { + if (mOptions[opt].longName.isEmpty()) + continue; + + if (mOptions[opt].longName != longName) + continue; + + // check for an existing value + if (!mOptions[opt].value.isNull()) + { + Q_ASSERT(mOptions[opt].isSet); + rError = tr("Duplicate parameter: %1").arg("--"+longName); + return false; + } + + if (!value.isNull()) + { + if (mOptions[opt].isSet) + { + rError = tr("Duplicate parameter: %1").arg("--"+longName); + return false; + } + if (!mOptions[opt].canHaveValue) + { + rError = tr("Invalid parameter: %1").arg(value); + return false; + } + } + + mOptions[opt].isSet = true; + mOptions[opt].value = value; + return true; + } + + rError = tr("Invalid parameter: %1").arg("--"+longName); + return false; +} Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-08-09 01:41:08 UTC (rev 12) +++ trunk/src/main.cpp 2006-08-09 06:35:51 UTC (rev 13) @@ -19,13 +19,18 @@ ***************************************************************************/ #include "grandmas_svn.h" +#include "commandline.h" + +#ifdef GSVN_TESTS +#include "../tests/tests.h" +#endif + +#include <apr_general.h> #include <svn/modification.h> #include <svn/server_access.h> -#include <apr_general.h> #include <iostream> - class QSvnOperationStatus : public SvnOperationStatus { public: @@ -85,7 +90,25 @@ apr_pool_destroy(pool); // END TEST CODE + GrandmasSVNApp app(argc, argv); - GrandmasSVNApp app(argc, argv); + CommandLine cmd; +#ifdef GSVN_TESTS + cmd.addAvailableOption('t', "tests", "run unit tests", false); +#endif + + if (!cmd.parse(argc, argv, error)) + { + fputs(error.toAscii(), stderr); + fputs("\n", stderr); + fputs(cmd.usage().toAscii(), stderr); + return 1; + } + +#ifdef GSVN_TESTS + if (cmd.checkOption('t', "tests")) + return runTests(); +#endif + return app.exec(); } Added: trunk/tests/commandlinetest.cpp =================================================================== --- trunk/tests/commandlinetest.cpp (rev 0) +++ trunk/tests/commandlinetest.cpp 2006-08-09 06:35:51 UTC (rev 13) @@ -0,0 +1,256 @@ +/*************************************************************************** + * 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 "commandlinetest.h" +#include "commandline.h" +#include <QtTest/QtTest> + +CommandLineTest::CommandLineTest() +{ + mpCmd = NULL; +} + +void CommandLineTest::init() +{ + Q_ASSERT(mpCmd == NULL); + mpCmd = new CommandLine; + mpCmd->addAvailableOption('s', NULL, "short parameter (without value)", false); + mpCmd->addAvailableOption('S', NULL, "short parameter (with value)", true); + mpCmd->addAvailableOption(NULL, "long", "long parameter (without value)", false); + mpCmd->addAvailableOption(NULL, "long-value", "long parameter (with value)", true); + mpCmd->addAvailableOption('b', "both", "both long and short parameter (without value)", false); + mpCmd->addAvailableOption('B', "both-value", "both long and short parameter (with value)", true); +} + +void CommandLineTest::testUsage() +{ + QString usage = mpCmd->usage(); + QVERIFY(usage.contains("-B")); + QVERIFY(usage.contains("--both-value")); + QVERIFY(usage.contains("both long and short parameter (with value)")); +} + +void CommandLineTest::testCheckOptionBeforeParse() +{ + QVERIFY(!mpCmd->checkOption('?', "unknown")); + + CommandLine cmd; + QString value; + QVERIFY(!cmd.checkOption('!', "unspecified")); + QVERIFY(!cmd.checkOption('!', "unspecified", value)); + QVERIFY(value.isNull()); +} + +void CommandLineTest::testAddAvailableOptionAfterParse() +{ + mpCmd->addAvailableOption('!', "extra", "extra parameter", false); + + QString value; + QVERIFY(!mpCmd->checkOption('!', "extra")); + QVERIFY(!mpCmd->checkOption('!', "extra", value)); + QVERIFY(value.isNull()); +} + +void CommandLineTest::testPath() +{ + QStringList args; + args.push_back("/my/path/"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("/my/path/")); +} + +void CommandLineTest::testBogusShort() +{ + QStringList args; + args.push_back("-?"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("?")); +} + +void CommandLineTest::testBogusLong() +{ + QStringList args; + args.push_back("-?"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("?")); +} + +void CommandLineTest::testTripleDash() +{ + QStringList args; + args.push_back("---long"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("---long")); +} + +void CommandLineTest::testDuplicateShort() +{ + QStringList args; + args.push_back("-s"); + args.push_back("-s"); + + QString error; + QVERIFY(mpCmd->parse(args, error)); + QVERIFY(error.isNull()); + QVERIFY(mpCmd->checkOption('s', NULL)); +} + +void CommandLineTest::testLongWithValue() +{ + QStringList args; + args.push_back("--long-value"); + args.push_back("value"); + + QString error; + QVERIFY(mpCmd->parse(args, error)); + QVERIFY(error.isNull()); + + QString value; + QVERIFY(mpCmd->checkOption(NULL, "long-value", value)); + QCOMPARE(value, QString("value")); +} + +void CommandLineTest::testDuplicateLongWithoutValue() +{ + QStringList args; + args.push_back("--long"); + args.push_back("--long"); + + QString error; + QVERIFY(mpCmd->parse(args, error)); + QVERIFY(error.isNull()); + QVERIFY(mpCmd->checkOption(NULL, "long")); +} + +void CommandLineTest::testDuplicateLongWithoutValue1() +{ + QStringList args; + args.push_back("--long"); + args.push_back("--long"); + args.push_back("value"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Duplicate parameter: %1").arg("--long")); +} + +void CommandLineTest::testDuplicateLongWithoutValue2() +{ + QStringList args; + args.push_back("--long"); + args.push_back("value"); + args.push_back("--long"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("value")); +} + +void CommandLineTest::testDuplicateLongWithValue1() +{ + QStringList args; + args.push_back("--long-value"); + args.push_back("--long-value"); + args.push_back("value"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Duplicate parameter: %1").arg("--long-value")); +} + +void CommandLineTest::testDuplicateLongWithValue2() +{ + QStringList args; + args.push_back("--long-value"); + args.push_back("value"); + args.push_back("--long-value"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Duplicate parameter: %1").arg("--long-value")); +} + +void CommandLineTest::testShortAndLongWithValue() +{ + QStringList args; + args.push_back("--both-value"); + args.push_back("value"); + + QString error; + QVERIFY(mpCmd->parse(args, error)); + QVERIFY(error.isNull()); + + QString value; + QVERIFY(mpCmd->checkOption('B', "both-value", value)); + QCOMPARE(value, QString("value")); +} + +void CommandLineTest::testDuplicateShortAndLongWithoutValue() +{ + QStringList args; + args.push_back("-b"); + args.push_back("--both"); + + QString error; + QVERIFY(mpCmd->parse(args, error)); + QVERIFY(error.isNull()); + + QString value; + QVERIFY(mpCmd->checkOption('b', "both")); + QVERIFY(value.isNull()); +} + +void CommandLineTest::testDuplicateShortAndLongWithValue() +{ + QStringList args; + args.push_back("-B"); + args.push_back("--both-value"); + args.push_back("value"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Duplicate parameter: %1").arg("--both-value")); +} + +void CommandLineTest::testDuplicateLongAndShortWithValue() +{ + QStringList args; + args.push_back("--both-value"); + args.push_back("-B"); + args.push_back("value"); + + QString error; + QVERIFY(!mpCmd->parse(args, error)); + QCOMPARE(error, tr("Invalid parameter: %1").arg("value")); +} + +void CommandLineTest::cleanup() +{ + delete mpCmd; + mpCmd = NULL; +} Added: trunk/tests/commandlinetest.h =================================================================== --- trunk/tests/commandlinetest.h (rev 0) +++ trunk/tests/commandlinetest.h 2006-08-09 06:35:51 UTC (rev 13) @@ -0,0 +1,56 @@ +/*************************************************************************** + * 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 CommandLine; + +class CommandLineTest : public QObject +{ + Q_OBJECT +public: + CommandLineTest(); + +private slots: + void init(); + void testUsage(); + void testCheckOptionBeforeParse(); + void testAddAvailableOptionAfterParse(); + void testPath(); + void testBogusShort(); + void testBogusLong(); + void testTripleDash(); + void testDuplicateShort(); + void testLongWithValue(); + void testDuplicateLongWithoutValue(); + void testDuplicateLongWithoutValue1(); + void testDuplicateLongWithoutValue2(); + void testDuplicateLongWithValue1(); + void testDuplicateLongWithValue2(); + void testShortAndLongWithValue(); + void testDuplicateShortAndLongWithoutValue(); + void testDuplicateShortAndLongWithValue(); + void testDuplicateLongAndShortWithValue(); + void cleanup(); + +private: + CommandLine* mpCmd; +}; + Added: trunk/tests/tests.cpp =================================================================== --- trunk/tests/tests.cpp (rev 0) +++ trunk/tests/tests.cpp 2006-08-09 06:35:51 UTC (rev 13) @@ -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 "tests.h" +#include "commandlinetest.h" + +#include <QtTest/QtTest> + +#define TEST(ObjectType) \ + do \ + { \ + ObjectType obj; \ + int testResult = QTest::qExec(&obj); \ + if (testResult > result) \ + result = testResult; \ + } while (0) + +int runTests() +{ + int result = 0; + TEST(CommandLineTest); + return result; +} Added: trunk/tests/tests.h =================================================================== --- trunk/tests/tests.h (rev 0) +++ trunk/tests/tests.h 2006-08-09 06:35:51 UTC (rev 13) @@ -0,0 +1,22 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +int runTests(); + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-08-09 14:28:40
|
Revision: 14 Author: matthiasmiller Date: 2006-08-09 07:28:30 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=14&view=rev Log Message: ----------- ignore assertions during unit tests Modified Paths: -------------- trunk/grandmas_svn.pro trunk/src/commandline.cpp trunk/src/dialogs/core/base.cpp trunk/src/settings/userpaths.cpp trunk/src/svn/modification.cpp trunk/src/svn/revision.cpp trunk/tests/commandlinetest.cpp Added Paths: ----------- trunk/include/debug.h trunk/src/debug.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/grandmas_svn.pro 2006-08-09 14:28:30 UTC (rev 14) @@ -115,7 +115,7 @@ UI_DIR = build/ui RCC_DIR = build/rcc -CONFIG += release \ +CONFIG += debug \ warn_on \ qt \ thread \ @@ -134,6 +134,7 @@ RC_FILE = ui/icons/win32.rc HEADERS += include/commandline.h \ + include/debug.h \ include/dialogs/commit.h \ include/dialogs/core/base.h \ include/dialogs/move.h \ @@ -146,6 +147,7 @@ src/grandmas_svn.h SOURCES += src/commandline.cpp \ + src/debug.cpp \ src/dialogs/commit.cpp \ src/dialogs/core/base.cpp \ src/dialogs/mainwindow.cpp \ Copied: trunk/include/debug.h (from rev 13, trunk/templates/h) =================================================================== --- trunk/include/debug.h (rev 0) +++ trunk/include/debug.h 2006-08-09 14:28:30 UTC (rev 14) @@ -0,0 +1,27 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +bool gsvn_allowAssert(); + +#ifndef QT_NO_DEBUG +# define GSVN_ASSERT(cond) do {if(gsvn_allowAssert() && !(cond))qt_assert(#cond,__FILE__,__LINE__);} while (0) +#else +# define GSVN_ASSERT(cond) do{}while(0) +#endif Modified: trunk/src/commandline.cpp =================================================================== --- trunk/src/commandline.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/src/commandline.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -19,15 +19,16 @@ ***************************************************************************/ #include "commandline.h" +#include "debug.h" void CommandLine::addAvailableOption(QChar shortName, QString longName, QString desc, bool canHaveValue) { - Q_ASSERT(!shortName.isNull() || !longName.isEmpty()); + GSVN_ASSERT(!shortName.isNull() || !longName.isEmpty()); Q_FOREACH(CommandLineOption opt, mOptions) { // verify uniqueness of names - Q_ASSERT(shortName.isNull() || shortName != opt.shortName); - Q_ASSERT(longName.isEmpty() || longName != opt.longName); + GSVN_ASSERT(shortName.isNull() || shortName != opt.shortName); + GSVN_ASSERT(longName.isEmpty() || longName != opt.longName); } // register the option @@ -108,7 +109,7 @@ return rOpt.isSet; } - Q_ASSERT(false); + GSVN_ASSERT(false); return false; } @@ -118,13 +119,13 @@ { if (rOpt.shortName == shortName && rOpt.longName == longName) { - Q_ASSERT(rOpt.canHaveValue); + GSVN_ASSERT(rOpt.canHaveValue); rValue = rOpt.value; return rOpt.isSet; } } - Q_ASSERT(false); + GSVN_ASSERT(false); return false; } @@ -140,7 +141,7 @@ if (!mOptions[opt].value.isNull()) { - Q_ASSERT(rOpt.isSet); + GSVN_ASSERT(mOptions[opt].isSet); rError = tr("Duplicate parameter: %1").arg(shortName); return false; } @@ -166,7 +167,7 @@ // check for an existing value if (!mOptions[opt].value.isNull()) { - Q_ASSERT(mOptions[opt].isSet); + GSVN_ASSERT(mOptions[opt].isSet); rError = tr("Duplicate parameter: %1").arg("--"+longName); return false; } Copied: trunk/src/debug.cpp (from rev 13, trunk/templates/cpp) =================================================================== --- trunk/src/debug.cpp (rev 0) +++ trunk/src/debug.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -0,0 +1,27 @@ +/*************************************************************************** + * 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 "debug.h" +#include <QtTest/QtTest> + +bool gsvn_allowAssert() +{ + return (QTest::currentTestFunction() == NULL); +} Modified: trunk/src/dialogs/core/base.cpp =================================================================== --- trunk/src/dialogs/core/base.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/src/dialogs/core/base.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -19,6 +19,7 @@ ***************************************************************************/ #include "dialogs/core/base.h" +#include "debug.h" #include <QBoxLayout> #include <QPushButton> @@ -55,9 +56,9 @@ // If both widgets are in the same layout, it's important to move them in the correct order. int firstIndex = pLayout->indexOf(pFirstWidget); int secondIndex = pLayout->indexOf(pSecondWidget); - Q_ASSERT(firstIndex != -1); - Q_ASSERT(secondIndex != -1); - Q_ASSERT(firstIndex < secondIndex); + GSVN_ASSERT(firstIndex != -1); + GSVN_ASSERT(secondIndex != -1); + GSVN_ASSERT(firstIndex < secondIndex); pLayout->removeWidget(pSecondWidget); pLayout->insertWidget(firstIndex, pSecondWidget); Modified: trunk/src/settings/userpaths.cpp =================================================================== --- trunk/src/settings/userpaths.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/src/settings/userpaths.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -19,6 +19,7 @@ ***************************************************************************/ #include "settings/userpaths.h" +#include "debug.h" #include <QDir> #include <QSettings> @@ -124,7 +125,7 @@ QString UserPathsModel::getPath(const QModelIndex& rcIndex) const { - Q_ASSERT(rcIndex.isValid() && rcIndex.row() <= mPaths.size()); + GSVN_ASSERT(rcIndex.isValid() && rcIndex.row() <= mWorkingCopies.size()); return mWorkingCopies.at(rcIndex.row()).getPath(); } @@ -137,7 +138,7 @@ emit layoutChanged(); int offset = qBinaryFind(mWorkingCopies.begin(), mWorkingCopies.end(), WorkingCopy(wc)) - mWorkingCopies.begin(); - Q_ASSERT(offset >= 0); - Q_ASSERT(offset < mWorkingCopies.size()); + GSVN_ASSERT(offset >= 0); + GSVN_ASSERT(offset < mWorkingCopies.size()); return index(offset, 0); } Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/src/svn/modification.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -20,6 +20,7 @@ #include <svn/modification.h> #include <svn/server_access.h> +#include "debug.h" #include <apr_pools.h> #include <assert.h> @@ -272,7 +273,7 @@ svn_client_create_context(&mpCtx, mpContext->getAprPool()); QString rIgnoredError; - Q_ASSERT(initAuthProviders(mpCtx, *mpContext, rIgnoredError)); + GSVN_ASSERT(initAuthProviders(mpCtx, *mpContext, rIgnoredError)); } Modified: trunk/src/svn/revision.cpp =================================================================== --- trunk/src/svn/revision.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/src/svn/revision.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -19,6 +19,7 @@ ***************************************************************************/ #include <svn/revision.h> +#include "debug.h" #include <QtDebug> Revision::Revision() @@ -49,7 +50,7 @@ int Revision::getCommittedRevision() { - Q_ASSERT(mIsCommitted); + GSVN_ASSERT(mIsCommitted); return mCommittedRevision; } Modified: trunk/tests/commandlinetest.cpp =================================================================== --- trunk/tests/commandlinetest.cpp 2006-08-09 06:35:51 UTC (rev 13) +++ trunk/tests/commandlinetest.cpp 2006-08-09 14:28:30 UTC (rev 14) @@ -20,6 +20,7 @@ #include "commandlinetest.h" #include "commandline.h" +#include "debug.h" #include <QtTest/QtTest> CommandLineTest::CommandLineTest() @@ -29,7 +30,7 @@ void CommandLineTest::init() { - Q_ASSERT(mpCmd == NULL); + GSVN_ASSERT(mpCmd == NULL); mpCmd = new CommandLine; mpCmd->addAvailableOption('s', NULL, "short parameter (without value)", false); mpCmd->addAvailableOption('S', NULL, "short parameter (with value)", true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-08-10 00:17:22
|
Revision: 16 Author: matthiasmiller Date: 2006-08-09 17:17:12 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=16&view=rev Log Message: ----------- use #ifdef instead of inheritance to handle OS differences Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/commit.h trunk/include/dialogs/move.h trunk/include/dialogs/open.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/move.cpp trunk/src/dialogs/open.cpp Added Paths: ----------- trunk/include/dialogs/util.h trunk/src/dialogs/util.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/grandmas_svn.pro 2006-08-10 00:17:12 UTC (rev 16) @@ -136,10 +136,10 @@ HEADERS += include/commandline.h \ include/debug.h \ include/dialogs/commit.h \ - include/dialogs/core/base.h \ include/dialogs/move.h \ include/dialogs/open.h \ include/dialogs/mainwindow.h \ + include/dialogs/util.h \ include/settings/userpaths.h \ include/svn/server_access.h \ include/svn/modification.h \ @@ -149,10 +149,10 @@ SOURCES += src/commandline.cpp \ src/debug.cpp \ src/dialogs/commit.cpp \ - src/dialogs/core/base.cpp \ src/dialogs/mainwindow.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/dialogs/util.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ src/settings/userpaths.cpp \ Modified: trunk/include/dialogs/commit.h =================================================================== --- trunk/include/dialogs/commit.h 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/include/dialogs/commit.h 2006-08-10 00:17:12 UTC (rev 16) @@ -22,19 +22,16 @@ #ifndef DIALOGS_COMMIT_H_ #define DIALOGS_COMMIT_H_ -#include "dialogs/core/base.h" +#include <QDialog> class Ui_CommitDialog; -class CommitDialog : public BaseDialog +class CommitDialog : public QDialog { public: CommitDialog(QWidget* pParent); ~CommitDialog(); -protected: - virtual void initMac(); - private: Ui_CommitDialog* mpUi; }; Modified: trunk/include/dialogs/move.h =================================================================== --- trunk/include/dialogs/move.h 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/include/dialogs/move.h 2006-08-10 00:17:12 UTC (rev 16) @@ -22,11 +22,11 @@ #ifndef DIALOGS_MOVE_H_ #define DIALOGS_MOVE_H_ -#include "dialogs/core/base.h" +#include <QDialog> class Ui_moveDialog; -class MoveDialog : public BaseDialog +class MoveDialog : public QDialog { Q_OBJECT @@ -35,9 +35,6 @@ ~MoveDialog(); private: - virtual void initMac(); - -private: Ui_moveDialog* mpUi; }; Modified: trunk/include/dialogs/open.h =================================================================== --- trunk/include/dialogs/open.h 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/include/dialogs/open.h 2006-08-10 00:17:12 UTC (rev 16) @@ -22,14 +22,14 @@ #ifndef DIALOGS_OPEN_H_ #define DIALOGS_OPEN_H_ -#include "dialogs/core/base.h" +#include <QDialog> class Ui_OpenDialog; class UserPathsModel; class QKeyEvent; class QSettings; -class OpenDialog : public BaseDialog +class OpenDialog : public QDialog { Q_OBJECT @@ -44,9 +44,6 @@ void accept(); void openOther(); -protected: - virtual void initMac(); - private: Ui_OpenDialog* mpUi; UserPathsModel* mpPathsModel; Copied: trunk/include/dialogs/util.h (from rev 15, trunk/templates/h) =================================================================== --- trunk/include/dialogs/util.h (rev 0) +++ trunk/include/dialogs/util.h 2006-08-10 00:17:12 UTC (rev 16) @@ -0,0 +1,24 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +class QBoxLayout; +class QWidget; + +void exchangeWidgets(QBoxLayout* pLayout, QWidget* pFirstWidget, QWidget* pSecondWidget); Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/src/dialogs/commit.cpp 2006-08-10 00:17:12 UTC (rev 16) @@ -19,14 +19,17 @@ ***************************************************************************/ #include "dialogs/commit.h" +#include "dialogs/util.h" #include "ui_commit.h" -CommitDialog::CommitDialog(QWidget* pParent) : BaseDialog(pParent) +CommitDialog::CommitDialog(QWidget* pParent) : QDialog(pParent) { mpUi = new Ui_CommitDialog(); mpUi->setupUi(this); - init(); +#ifdef Q_WS_MAC + exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); +#endif } CommitDialog::~CommitDialog() @@ -34,8 +37,3 @@ delete mpUi; mpUi = NULL; } - -void CommitDialog::initMac() -{ - exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); -} Modified: trunk/src/dialogs/move.cpp =================================================================== --- trunk/src/dialogs/move.cpp 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/src/dialogs/move.cpp 2006-08-10 00:17:12 UTC (rev 16) @@ -19,13 +19,17 @@ ***************************************************************************/ #include "dialogs/move.h" +#include "dialogs/util.h" #include "ui_move.h" -MoveDialog::MoveDialog(QWidget* pParent) : BaseDialog(pParent) +MoveDialog::MoveDialog(QWidget* pParent) : QDialog(pParent) { mpUi = new Ui_moveDialog(); mpUi->setupUi(this); - init(); + +#ifdef Q_WS_MAC + exchangeWidgets(mpUi->hboxLayout2, mpUi->okButton, mpUi->cancelButton); +#endif } MoveDialog::~MoveDialog() @@ -33,8 +37,3 @@ delete mpUi; mpUi = NULL; } - -void MoveDialog::initMac() -{ - exchangeWidgets(mpUi->hboxLayout2, mpUi->okButton, mpUi->cancelButton); -} Modified: trunk/src/dialogs/open.cpp =================================================================== --- trunk/src/dialogs/open.cpp 2006-08-09 19:21:25 UTC (rev 15) +++ trunk/src/dialogs/open.cpp 2006-08-10 00:17:12 UTC (rev 16) @@ -19,6 +19,7 @@ ***************************************************************************/ #include "dialogs/open.h" +#include "dialogs/util.h" #include "settings/userpaths.h" #include "ui_open.h" #include <QFileDialog> @@ -33,7 +34,9 @@ mpUi->workingCopyListView->setModel(mpPathsModel); connect(mpUi->otherButton, SIGNAL(clicked()), this, SLOT(openOther())); - init(); +#ifdef Q_WS_MAC + exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); +#endif } OpenDialog::~OpenDialog() @@ -66,8 +69,3 @@ mpUi->workingCopyListView->setFocus(); } } - -void OpenDialog::initMac() -{ - exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); -} Copied: trunk/src/dialogs/util.cpp (from rev 15, trunk/templates/cpp) =================================================================== --- trunk/src/dialogs/util.cpp (rev 0) +++ trunk/src/dialogs/util.cpp 2006-08-10 00:17:12 UTC (rev 16) @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2006 by Matthias Miller * + * ad...@gr... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "util.h" +#include "debug.h" +#include <QBoxLayout> +#include <QWidget> + +void exchangeWidgets(QBoxLayout* pLayout, QWidget* pFirstWidget, QWidget* pSecondWidget) +{ + // If both widgets are in the same layout, it's important to move them in the correct order. + int firstIndex = pLayout->indexOf(pFirstWidget); + int secondIndex = pLayout->indexOf(pSecondWidget); + GSVN_ASSERT(firstIndex != -1); + GSVN_ASSERT(secondIndex != -1); + GSVN_ASSERT(firstIndex < secondIndex); + + pLayout->removeWidget(pSecondWidget); + pLayout->insertWidget(firstIndex, pSecondWidget); + + pLayout->removeWidget(pFirstWidget); + pLayout->insertWidget(secondIndex, pFirstWidget); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-08-10 04:20:45
|
Revision: 17 Author: highjinx Date: 2006-08-09 21:20:34 -0700 (Wed, 09 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=17&view=rev Log Message: ----------- More extensive unit testing for Modifications class, as well as fixing several bugs exposed by tests Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/svn/modification.h trunk/include/svn/revision.h trunk/src/dialogs/util.cpp trunk/src/main.cpp trunk/src/svn/modification.cpp trunk/tests/commandlinetest.cpp trunk/tests/tests.cpp Added Paths: ----------- trunk/tests/svn_test.cpp trunk/tests/svn_test.h Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/grandmas_svn.kdevelop 2006-08-10 04:20:34 UTC (rev 17) @@ -10,6 +10,10 @@ <keyword>Qt</keyword> </keywords> <ignoreparts/> + <projectdirectory>.</projectdirectory> + <absoluteprojectpath>false</absoluteprojectpath> + <description></description> + <versioncontrol/> </general> <kdevfileview> <groups> @@ -65,34 +69,52 @@ </kdevdoctreeview> <kdevdebugger> <general> - <dbgshell/> + <dbgshell></dbgshell> <breakpoints/> - <programargs/> + <programargs>-t</programargs> <gdbpath>/usr/bin/</gdbpath> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> + <configGdbScript></configGdbScript> + <runShellScript></runShellScript> + <runGdbScript></runGdbScript> </general> <display> <staticmembers>false</staticmembers> <demanglenames>true</demanglenames> + <outputradix>10</outputradix> </display> <breakpoints/> </kdevdebugger> <kdevtrollproject> <run> - <mainprogram>./bin/grandmas_svn</mainprogram> - <programargs/> - <directoryradio>executable</directoryradio> + <mainprogram>bin/grandmas-svn</mainprogram> + <programargs>-t</programargs> + <directoryradio>build</directoryradio> + <customdirectory>/</customdirectory> + <terminal>false</terminal> + <autocompile>true</autocompile> + <envvars/> </run> <general> <activedir></activedir> </general> + <make> + <abortonerror>true</abortonerror> + <runmultiplejobs>false</runmultiplejobs> + <numberofjobs>1</numberofjobs> + <dontact>false</dontact> + <makebin></makebin> + <prio>0</prio> + <envvars/> + </make> </kdevtrollproject> <workspace> <openfiles/> </workspace> <kdevfilecreate> + <filetypes/> <useglobaltypes> <type ext="ui" /> <type ext="cpp" /> @@ -102,13 +124,14 @@ </kdevfilecreate> <kdevdocumentation> <projectdoc> - <docsystem>Doxygen Documentation Collection</docsystem> - <docurl>grandmas_svn.tag</docurl> + <docsystem/> + <docurl/> + <usermanualurl/> </projectdoc> </kdevdocumentation> <substmap> - <APPNAME>grandmas_svn</APPNAME> - <APPNAMELC>grandmas_svn</APPNAMELC> + <APPNAME>grandmas-svn</APPNAME> + <APPNAMELC>grandmas-svn</APPNAMELC> <APPNAMESC>Grandmas_svn</APPNAMESC> <APPNAMEUC>GRANDMAS_SVN</APPNAMEUC> <AUTHOR>Matthias Miller</AUTHOR> @@ -133,5 +156,28 @@ <argumentsHintDelay>400</argumentsHintDelay> <headerCompletionDelay>250</headerCompletionDelay> </codecompletion> + <qt> + <used>true</used> + <version>4</version> + <root></root> + </qt> + <creategettersetter> + <prefixGet></prefixGet> + <prefixSet>set</prefixSet> + <prefixVariable>m_,_</prefixVariable> + <parameterName>theValue</parameterName> + <inlineGet>true</inlineGet> + <inlineSet>true</inlineSet> + </creategettersetter> </kdevcppsupport> + <cppsupportpart> + <filetemplates> + <interfacesuffix>.h</interfacesuffix> + <implementationsuffix>.cpp</implementationsuffix> + </filetemplates> + </cppsupportpart> + <ctagspart> + <customArguments/> + <customTagfilePath/> + </ctagspart> </kdevelop> Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/grandmas_svn.pro 2006-08-10 04:20:34 UTC (rev 17) @@ -136,14 +136,14 @@ HEADERS += include/commandline.h \ include/debug.h \ include/dialogs/commit.h \ + include/dialogs/mainwindow.h \ include/dialogs/move.h \ include/dialogs/open.h \ - include/dialogs/mainwindow.h \ include/dialogs/util.h \ include/settings/userpaths.h \ - include/svn/server_access.h \ include/svn/modification.h \ include/svn/revision.h \ + include/svn/server_access.h \ src/grandmas_svn.h SOURCES += src/commandline.cpp \ @@ -152,13 +152,13 @@ src/dialogs/mainwindow.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ + src/settings/userpaths.cpp \ + src/svn/modification.cpp \ + src/svn/revision.cpp \ + src/svn/server_access.cpp \ src/dialogs/util.cpp \ src/grandmas_svn.cpp \ src/main.cpp \ - src/settings/userpaths.cpp \ - src/svn/server_access.cpp \ - src/svn/modification.cpp \ - src/svn/revision.cpp # UNIT TESTS @@ -169,8 +169,10 @@ contains(DEFINES, GSVN_TESTS) { CONFIG += qtestlib HEADERS += tests/commandlinetest.h \ + tests/svn_test.h \ tests/tests.h SOURCES += tests/commandlinetest.cpp \ + tests/svn_test.cpp \ tests/tests.cpp LIBS += -lsvn_repos-1 } Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/include/svn/modification.h 2006-08-10 04:20:34 UTC (rev 17) @@ -18,6 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef _MODIFICATION_H_ +#define _MODIFICATION_H_ + #include "revision.h" #include <QList> @@ -46,7 +49,8 @@ Type_Conflicting, }; - QString getFilePath(); + QString getFilePath() { return mFilePath; } + Type getType() { return mType; } // Only use for move and copy mods QString getDestFilePath(); @@ -92,55 +96,4 @@ 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: - virtual ~NoOperationStatus() {} - virtual void update(QString textToAdd) { textToAdd=textToAdd; } - - 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; -}; +#endif Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/include/svn/revision.h 2006-08-10 04:20:34 UTC (rev 17) @@ -18,6 +18,9 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#ifndef _REVISION_H_ +#define _REVISION_H_ + #include <Qt> #include <svn_wc.h> @@ -43,3 +46,4 @@ int mCommittedRevision; }; +#endif Modified: trunk/src/dialogs/util.cpp =================================================================== --- trunk/src/dialogs/util.cpp 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/src/dialogs/util.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "util.h" +#include <dialogs/util.h> #include "debug.h" #include <QBoxLayout> #include <QWidget> Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/src/main.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -59,18 +59,20 @@ int main(int argc, char** argv) { + GrandmasSVNApp app(argc, argv); + // This information is used for the QSettings object. QCoreApplication::setOrganizationName("grandmas-svn.org"); QCoreApplication::setOrganizationDomain("grandmas-svn.org"); QCoreApplication::setApplicationName("Grandma's SVN"); + + apr_status_t rv = apr_initialize(); + if (rv != APR_SUCCESS) + return 1; // BEGIN TEST CODE if (false) { - apr_status_t rv = apr_initialize(); - if (rv != APR_SUCCESS) - return -1; - apr_pool_t* pool; apr_pool_create(&pool, NULL); @@ -92,8 +94,6 @@ apr_pool_destroy(pool); } // END TEST CODE - - GrandmasSVNApp app(argc, argv); CommandLine cmd; #ifdef GSVN_TESTS @@ -101,6 +101,7 @@ #endif QString error; + if (!cmd.parse(argc, argv, error)) { fputs(error.toAscii(), stderr); Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/src/svn/modification.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -77,9 +77,10 @@ bool Modifications::init(SvnOperationContext& rServer, QString path, Revision revision, QString& rError) { + mModifications.clear(); rError = ""; mpContext = &rServer; - mWcPath = path; + mWcPath = svn_path_canonicalize(path.toAscii(), rServer.getAprPool()); svn_client_ctx_t* ctx; svn_client_create_context(&ctx, rServer.getAprPool()); @@ -111,7 +112,8 @@ else { svn_opt_revision_t svnRevision = revision.getSvnRevision(); - pError = svn_client_status2(NULL, path.toAscii(), &svnRevision, + const char* canonPath = svn_path_canonicalize(path.toAscii(), rServer.getAprPool()); + pError = svn_client_status2(NULL, canonPath, &svnRevision, statusCallback, this, true/*recurse*/, @@ -119,7 +121,7 @@ false/*update*/, false /*no_ignore*/, true/*ignore_externals*/, - ctx/*svn_client_ctx_t *ctx*/, + ctx/*svn_client_ctx_t*/, rServer.getAprPool()); } if (pError) @@ -264,78 +266,3 @@ 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; - GSVN_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/tests/commandlinetest.cpp =================================================================== --- trunk/tests/commandlinetest.cpp 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/tests/commandlinetest.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -34,8 +34,8 @@ mpCmd = new CommandLine; mpCmd->addAvailableOption('s', NULL, "short parameter (without value)", false); mpCmd->addAvailableOption('S', NULL, "short parameter (with value)", true); - mpCmd->addAvailableOption(NULL, "long", "long parameter (without value)", false); - mpCmd->addAvailableOption(NULL, "long-value", "long parameter (with value)", true); + mpCmd->addAvailableOption(0, "long", "long parameter (without value)", false); + mpCmd->addAvailableOption(0, "long-value", "long parameter (with value)", true); mpCmd->addAvailableOption('b', "both", "both long and short parameter (without value)", false); mpCmd->addAvailableOption('B', "both-value", "both long and short parameter (with value)", true); } @@ -134,7 +134,7 @@ QVERIFY(error.isNull()); QString value; - QVERIFY(mpCmd->checkOption(NULL, "long-value", value)); + QVERIFY(mpCmd->checkOption(0, "long-value", value)); QCOMPARE(value, QString("value")); } @@ -147,7 +147,7 @@ QString error; QVERIFY(mpCmd->parse(args, error)); QVERIFY(error.isNull()); - QVERIFY(mpCmd->checkOption(NULL, "long")); + QVERIFY(mpCmd->checkOption(0, "long")); } void CommandLineTest::testDuplicateLongWithoutValue1() Added: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp (rev 0) +++ trunk/tests/svn_test.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -0,0 +1,199 @@ +/*************************************************************************** + * 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_test.h" + +#include <svn_client.h> +#include <svn_repos.h> +#include <svn_path.h> +#include <svn_pools.h> + +#include <iostream> + +SvnTester::SvnTester() +{ + 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)); + + mpCtx->log_msg_func = logMsgCallback; + mpCtx->log_msg_baton = this; + +} + +SvnTester::~SvnTester() +{ + apr_pool_destroy(mpContext->getAprPool()); + delete mpContext; +} + +bool SvnTester::commitChanges(QString commitMessage) +{ + mCurrentCommitMsg = commitMessage; + + 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()); + + if (svn_client_commit2(&pCommitInfo, array, true, false, mpCtx, mpContext->getAprPool())) + return false; + + return true; +} + +bool SvnTester::addFile(QString relFilePath) +{ + QString fullPath = QDir::convertSeparators(getWcPath()+relFilePath); + svn_error_t* pError = svn_client_add2(fullPath.toAscii(), true, true, mpCtx, mpContext->getAprPool()); + if (pError) + std::cout << pError->message << "\n"; + return (pError == NULL); +} + +bool SvnTester::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; +} + +bool SvnTester::removeDirectory(QString filePath) +{ + QDir dir(filePath); + QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::Hidden|QDir::System|QDir::AllDirs|QDir::Files); + Q_FOREACH(QFileInfo entry, entries) + { + if (entry.isDir()) + { + if (!removeDirectory(entry.absoluteFilePath())) + return false; + } + else + { + if (!QFile::remove(entry.absoluteFilePath())) + return false; + } + } + if (!dir.rmdir(filePath)) + return false; + + return true; +} + +bool SvnTester::updateWc() +{ + 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; +} + +#define GSVN_VERIFY(command) \ + do { \ + pError = (command); \ + if (pError) {\ + qDebug("Condition failed: " #command "\n");\ + qDebug(pError->message);\ + QVERIFY(false); } \ + } while (0) + +void SvnTester::init() +{ + apr_pool_t* pSubPool = svn_pool_create(mpContext->getAprPool()); + + svn_repos_t* pCreatedRepo; + svn_error_t* pError = NULL; + GSVN_VERIFY(svn_repos_create(&pCreatedRepo, getRepoPath().toAscii(), NULL, NULL, NULL, NULL, pSubPool)); + + apr_pool_destroy(pSubPool); + + svn_opt_revision_t revision; + revision.kind = svn_opt_revision_head; + const char* repoPath = svn_path_canonicalize(QString("file://"+getRepoPath()).toAscii(), mpContext->getAprPool()); + const char* wcPath = svn_path_canonicalize(getWcPath().toAscii(), mpContext->getAprPool()); + GSVN_VERIFY(svn_client_checkout2(NULL, repoPath, wcPath, &revision, &revision, true, false, mpCtx, mpContext->getAprPool())); + + QVERIFY(touchFile("/first.txt", "This is the first file")); + QVERIFY(addFile("/first.txt")); + QVERIFY(commitChanges("First commit")); + QVERIFY(touchFile("/second.txt", "This is the second file")); + QVERIFY(addFile("/second.txt")); + + QVERIFY(updateWc()); +} + +void SvnTester::cleanup() +{ + QVERIFY(removeDirectory(getRepoPath())); + 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*/) +{ + SvnTester* pThis = (SvnTester*)baton; + Q_ASSERT(pThis->mCurrentCommitMsg != ""); + *log_msg = (const char*)pThis->mCurrentCommitMsg.toAscii(); + pThis->mCurrentCommitMsg = ""; + tmp_file = NULL; + return NULL; +} + +void SvnTester::testModifications() +{ + Modifications modifications; + QString rError; + Revision rev; + rev.setCommittedRevision(1); + QVERIFY(modifications.init(*mpContext, getWcPath(), rev, rError)); + + QList<Modification> mods; + modifications.getModifications(mods); + + QCOMPARE(mods.size(), 1); + QCOMPARE(mods[0].getFilePath(), QString("/first.txt")); + QCOMPARE(mods[0].getType(), Modification::Type_Add); + + rev.setUncommittedRevision(); + QVERIFY(modifications.init(*mpContext, getWcPath(), rev, rError)); + + modifications.getModifications(mods); + + QCOMPARE(mods.size(), 1); + QCOMPARE(mods[0].getFilePath(), QString("/second.txt")); + QCOMPARE(mods[0].getType(), Modification::Type_Add); +} + Added: trunk/tests/svn_test.h =================================================================== --- trunk/tests/svn_test.h (rev 0) +++ trunk/tests/svn_test.h 2006-08-10 04:20:34 UTC (rev 17) @@ -0,0 +1,86 @@ +/*************************************************************************** + * 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> +#include <svn/server_access.h> + +#include <svn_repos.h> + +#include <QDir> +#include <QObject> +#include <QtTest/QtTest> + +class SvnOperationContext; +struct svn_wc_status2_t; +struct svn_client_ctx_t; +struct svn_info_t; + +class NoOperationStatus : public SvnOperationStatus +{ +public: + virtual ~NoOperationStatus() {} + virtual void update(QString textToAdd) { textToAdd=textToAdd; } + + virtual bool shouldCancel() { return false; } +}; + +class NoAuthentication : public SvnAuthentication +{ +protected: + virtual bool getAuthentication(QString& /*rUsername*/, QString& /*rPassword*/) { return false; } +}; + +class SvnTester : public QObject, public SvnOperation +{ + Q_OBJECT + +public: + SvnTester(); + ~SvnTester(); + +private: + QString getRepoPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo"); } + QString getWcPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc"); } + + bool createRepos(); + bool commitChanges(QString commitMessage); + bool addFile(QString relFilePath); + bool touchFile(QString relFilePath, QString fileText); // fails if the file exists + bool updateWc(); + + bool removeDirectory(QString filePath); + +private slots: + void init(); + void cleanup(); + + void testModifications(); + +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; + + QString mCurrentCommitMsg; +}; Modified: trunk/tests/tests.cpp =================================================================== --- trunk/tests/tests.cpp 2006-08-10 00:17:12 UTC (rev 16) +++ trunk/tests/tests.cpp 2006-08-10 04:20:34 UTC (rev 17) @@ -20,6 +20,7 @@ #include "tests.h" #include "commandlinetest.h" +#include "svn_test.h" #include <QtTest/QtTest> @@ -36,5 +37,6 @@ { int result = 0; TEST(CommandLineTest); + 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-08-10 13:28:06
|
Revision: 19 Author: matthiasmiller Date: 2006-08-10 06:27:59 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=19&view=rev Log Message: ----------- initial implementation of ModificationsModel Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/mainwindow.h trunk/src/dialogs/mainwindow.cpp trunk/src/grandmas_svn.cpp trunk/src/grandmas_svn.h trunk/src/main.cpp trunk/ui/mainwindow.ui Added Paths: ----------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/grandmas_svn.pro 2006-08-10 13:27:59 UTC (rev 19) @@ -137,6 +137,7 @@ include/debug.h \ include/dialogs/commit.h \ include/dialogs/mainwindow.h \ + include/dialogs/modificationsmodel.h \ include/dialogs/move.h \ include/dialogs/open.h \ include/dialogs/util.h \ @@ -150,6 +151,7 @@ src/debug.cpp \ src/dialogs/commit.cpp \ src/dialogs/mainwindow.cpp \ + src/dialogs/modificationsmodel.cpp \ src/dialogs/move.cpp \ src/dialogs/open.cpp \ src/settings/userpaths.cpp \ Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/include/dialogs/mainwindow.h 2006-08-10 13:27:59 UTC (rev 19) @@ -23,6 +23,8 @@ #include <QMainWindow> +class ModificationsModel; +class SvnOperationContext; class Ui_MainWindow; class MainWindow: public QMainWindow @@ -30,7 +32,7 @@ Q_OBJECT public: - MainWindow(); + MainWindow(SvnOperationContext* pContext, QString path); ~MainWindow(); private slots: @@ -39,6 +41,7 @@ private: Ui_MainWindow* mpUi; + ModificationsModel* mpModificationsModel; }; #endif Copied: trunk/include/dialogs/modificationsmodel.h (from rev 16, trunk/templates/h) =================================================================== --- trunk/include/dialogs/modificationsmodel.h (rev 0) +++ trunk/include/dialogs/modificationsmodel.h 2006-08-10 13:27:59 UTC (rev 19) @@ -0,0 +1,45 @@ +/*************************************************************************** + * 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 Modification; +class Revision; +class SvnOperationContext; + +class ModificationsModel : public QAbstractListModel +{ +public: + ModificationsModel(SvnOperationContext* pContext, QString path); + virtual ~ModificationsModel(); + + void setRevision(Revision revision); + + 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: + SvnOperationContext* mpContext; + QString mPath; + + QString mError; + QList<Modification> mModifications; +}; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/src/dialogs/mainwindow.cpp 2006-08-10 13:27:59 UTC (rev 19) @@ -21,19 +21,25 @@ #include "dialogs/mainwindow.h" #include "dialogs/commit.h" +#include "dialogs/modificationsmodel.h" #include "dialogs/move.h" +#include "svn/revision.h" #include "ui_mainwindow.h" #include <svn_client.h> -MainWindow::MainWindow() +MainWindow::MainWindow(SvnOperationContext* pContext, QString path) { + mpModificationsModel = new ModificationsModel(pContext, path); + mpModificationsModel->setRevision(Revision()); + mpUi = new Ui_MainWindow(); mpUi->setupUi(this); connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); - + mpUi->changesTreeView->setModel(mpModificationsModel); + const svn_version_t* pVersion = svn_client_version(); QString msg; @@ -54,6 +60,9 @@ { delete mpUi; mpUi = NULL; + + delete mpModificationsModel; + mpModificationsModel = NULL; } void MainWindow::commit() Copied: trunk/src/dialogs/modificationsmodel.cpp (from rev 16, trunk/templates/cpp) =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp (rev 0) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-08-10 13:27:59 UTC (rev 19) @@ -0,0 +1,118 @@ +/*************************************************************************** + * 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/modificationsmodel.h" +#include "svn/modification.h" + +ModificationsModel::ModificationsModel(SvnOperationContext* pContext, QString path) +{ + mpContext = pContext; + mPath = path; +} + +ModificationsModel::~ModificationsModel() +{ +} + +void ModificationsModel::setRevision(Revision revision) +{ + mError = QString(); + + Modifications mods; + if (mods.init(*mpContext, mPath, revision, mError)) + mods.getModifications(mModifications); + + emit layoutChanged(); +} + +int ModificationsModel::columnCount(const QModelIndex &rcParent) const +{ + Q_UNUSED(rcParent); + return mError.isEmpty() ? 2 : 1; +} + +int ModificationsModel::rowCount(const QModelIndex& rcParent) const +{ + Q_UNUSED(rcParent); + + if (mError.isEmpty()) + return mModifications.size(); + else + return 1; +} + +QVariant ModificationsModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + Q_UNUSED(orientation); + + if (role != Qt::DisplayRole) + return QVariant(); + + if (!mError.isEmpty()) + return QVariant(); + + switch (section) + { + case 0: return tr("Type"); + case 1: return tr("File"); + default: + Q_ASSERT(false); + return QVariant(); + } +} + +QVariant ModificationsModel::data(const QModelIndex& rcIndex, int role) const +{ + if (!rcIndex.isValid()) + return QVariant(); + + if (role != Qt::DisplayRole) + return QVariant(); + + if (!mError.isEmpty()) + return mError; + + if (rcIndex.row() >= mModifications.size()) + return QVariant(); + + Modification mod = mModifications.at(rcIndex.row()); + switch (rcIndex.column()) + { + case 0: + 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_Move: return tr("Moved"); + case Modification::Type_PropMod: return tr("Property Modified"); + case Modification::Type_Copy: return tr("Copied"); + case Modification::Type_New: return tr("?"); + case Modification::Type_Missing: return tr("!"); + case Modification::Type_Conflicting: return tr("Conflicting"); + } + break; + + case 1: + if (mod.getType() == Modification::Type_Move || mod.getType() == Modification::Type_Copy) + return mod.getFilePath() + "\n" + mod.getDestFilePath(); + else + return mod.getFilePath(); + } +} Modified: trunk/src/grandmas_svn.cpp =================================================================== --- trunk/src/grandmas_svn.cpp 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/src/grandmas_svn.cpp 2006-08-10 13:27:59 UTC (rev 19) @@ -25,8 +25,10 @@ #include <QMenuBar> #include <QSettings> -GrandmasSVNApp::GrandmasSVNApp(int& argc, char** argv) : QApplication(argc, argv) +GrandmasSVNApp::GrandmasSVNApp(int& argc, char** argv, SvnOperationContext* pContext) : QApplication(argc, argv) { + mpContext = pContext; + mpOpenDlg = NULL; mpAppMenu = NULL; @@ -86,9 +88,9 @@ } } -void GrandmasSVNApp::openPath(QString /*path*/) +void GrandmasSVNApp::openPath(QString path) { - MainWindow* pMainWnd = new MainWindow(); + MainWindow* pMainWnd = new MainWindow(mpContext, path); pMainWnd->show(); } Modified: trunk/src/grandmas_svn.h =================================================================== --- trunk/src/grandmas_svn.h 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/src/grandmas_svn.h 2006-08-10 13:27:59 UTC (rev 19) @@ -27,13 +27,14 @@ class OpenDialog; class QMenuBar; class QSettings; +class SvnOperationContext; class GrandmasSVNApp : public QApplication { Q_OBJECT public: - GrandmasSVNApp(int& argc, char** argv); + GrandmasSVNApp(int& argc, char** argv, SvnOperationContext* pContext); ~GrandmasSVNApp(); private: @@ -50,6 +51,8 @@ QMenuBar* mpAppMenu; OpenDialog* mpOpenDlg; QSettings* mpSettings; + + SvnOperationContext* mpContext; }; #endif Modified: trunk/src/main.cpp =================================================================== --- trunk/src/main.cpp 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/src/main.cpp 2006-08-10 13:27:59 UTC (rev 19) @@ -55,53 +55,53 @@ return false; } }; -using namespace std; +class AprPoolWrapper +{ +public: + AprPoolWrapper() + { + apr_pool_create(&mPool, NULL); + } + ~AprPoolWrapper() + { + apr_pool_destroy(mPool); + mPool = NULL; + } + + apr_pool_t* getPool() + { + return mPool; + } + +private: + apr_pool_t* mPool; +}; + int main(int argc, char** argv) { - GrandmasSVNApp app(argc, argv); - - // This information is used for the QSettings object. - QCoreApplication::setOrganizationName("grandmas-svn.org"); - QCoreApplication::setOrganizationDomain("grandmas-svn.org"); - QCoreApplication::setApplicationName("Grandma's SVN"); - - apr_status_t rv = apr_initialize(); - if (rv != APR_SUCCESS) + if (apr_initialize() != APR_SUCCESS) return 1; - // BEGIN TEST CODE - if (false) - { - apr_pool_t* pool; - apr_pool_create(&pool, NULL); + AprPoolWrapper poolWrapper; - QSvnOperationStatus status; - QSvnAuthentication auth; - SvnOperationContext context(pool, status, auth);; + QSvnOperationStatus status; + QSvnAuthentication auth; + SvnOperationContext context(poolWrapper.getPool(), status, auth); - QString error; - Revision revision; - //revision.setUncommittedRevision(); - revision.setCommittedRevision(5); + GrandmasSVNApp app(argc, argv, &context); - Modifications mods; - if (!mods.init(context, "/home/joshn/projects/gsvn", revision, error)) - { - cout << "Error!: " << (const char*)error.toAscii() << "\n"; - } + // This information is used for the QSettings object. + QCoreApplication::setOrganizationName("grandmas-svn.org"); + QCoreApplication::setOrganizationDomain("grandmas-svn.org"); + QCoreApplication::setApplicationName("Grandma's SVN"); - apr_pool_destroy(pool); - } - // END TEST CODE - CommandLine cmd; #ifdef GSVN_TESTS cmd.addAvailableOption('t', "tests", "run unit tests", false); #endif QString error; - if (!cmd.parse(argc, argv, error)) { fputs(error.toAscii(), stderr); Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-08-10 13:26:31 UTC (rev 18) +++ trunk/ui/mainwindow.ui 2006-08-10 13:27:59 UTC (rev 19) @@ -145,7 +145,7 @@ <string>Changes:</string> </property> <property name="buddy" > - <cstring>changesTableView</cstring> + <cstring>changesTreeView</cstring> </property> </widget> </item> @@ -158,11 +158,7 @@ <number>6</number> </property> <item> - <widget class="QTableView" name="changesTableView" > - <property name="tabKeyNavigation" > - <bool>false</bool> - </property> - </widget> + <widget class="QTreeView" name="changesTreeView" /> </item> <item> <layout class="QVBoxLayout" > @@ -304,20 +300,11 @@ <x>0</x> <y>0</y> <width>639</width> - <height>21</height> + <height>22</height> </rect> </property> </widget> - <widget class="QStatusBar" name="statusbar" > - <property name="geometry" > - <rect> - <x>0</x> - <y>433</y> - <width>639</width> - <height>19</height> - </rect> - </property> - </widget> + <widget class="QStatusBar" name="statusbar" /> <action name="action_Close" > <property name="text" > <string>&Close</string> @@ -327,7 +314,7 @@ <pixmapfunction></pixmapfunction> <tabstops> <tabstop>logEdit</tabstop> - <tabstop>changesTableView</tabstop> + <tabstop>changesTreeView</tabstop> <tabstop>diffButton</tabstop> <tabstop>revertButton</tabstop> <tabstop>addButton</tabstop> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-08-11 01:04:54
|
Revision: 20 Author: highjinx Date: 2006-08-10 18:04:46 -0700 (Thu, 10 Aug 2006) ViewCVS: http://svn.sourceforge.net/grandmas-svn/?rev=20&view=rev Log Message: ----------- Implementing functionality to retrieve historical files (to be used for diffing) Modified Paths: -------------- trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/svn/file_access.h trunk/include/svn/modification.h trunk/tests/svn_test.cpp trunk/tests/svn_test.h Modified: trunk/grandmas_svn.kdevelop =================================================================== --- trunk/grandmas_svn.kdevelop 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/grandmas_svn.kdevelop 2006-08-11 01:04:46 UTC (rev 20) @@ -12,7 +12,7 @@ <ignoreparts/> <projectdirectory>.</projectdirectory> <absoluteprojectpath>false</absoluteprojectpath> - <description></description> + <description/> <versioncontrol/> </general> <kdevfileview> @@ -69,16 +69,16 @@ </kdevdoctreeview> <kdevdebugger> <general> - <dbgshell></dbgshell> + <dbgshell/> <breakpoints/> <programargs>-t</programargs> <gdbpath>/usr/bin/</gdbpath> <breakonloadinglibs>true</breakonloadinglibs> <separatetty>false</separatetty> <floatingtoolbar>false</floatingtoolbar> - <configGdbScript></configGdbScript> - <runShellScript></runShellScript> - <runGdbScript></runGdbScript> + <configGdbScript/> + <runShellScript/> + <runGdbScript/> </general> <display> <staticmembers>false</staticmembers> @@ -105,7 +105,7 @@ <runmultiplejobs>false</runmultiplejobs> <numberofjobs>1</numberofjobs> <dontact>false</dontact> - <makebin></makebin> + <makebin/> <prio>0</prio> <envvars/> </make> @@ -159,10 +159,10 @@ <qt> <used>true</used> <version>4</version> - <root></root> + <root/> </qt> <creategettersetter> - <prefixGet></prefixGet> + <prefixGet/> <prefixSet>set</prefixSet> <prefixVariable>m_,_</prefixVariable> <parameterName>theValue</parameterName> Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/grandmas_svn.pro 2006-08-11 01:04:46 UTC (rev 20) @@ -142,6 +142,7 @@ include/dialogs/open.h \ include/dialogs/util.h \ include/settings/userpaths.h \ + include/svn/file_access.h \ include/svn/modification.h \ include/svn/revision.h \ include/svn/server_access.h \ @@ -155,6 +156,7 @@ src/dialogs/move.cpp \ src/dialogs/open.cpp \ src/settings/userpaths.cpp \ + src/svn/file_access.cpp \ src/svn/modification.cpp \ src/svn/revision.cpp \ src/svn/server_access.cpp \ Modified: trunk/include/svn/file_access.h =================================================================== --- trunk/include/svn/file_access.h 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/include/svn/file_access.h 2006-08-11 01:04:46 UTC (rev 20) @@ -18,16 +18,16 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <svn/modification.h> #include <svn/revision.h> #include <svn/server_access.h> -#include <Qt> +#include <QString> -class RepoFileAccess +class RepoFileAccess : public SvnOperation { public: - bool init(QString fullRepoPath, Revision oldRevision, Revision newRevision, QString& rError); - bool getOldFile(ServerAccess& rAccess, QString relFilePath, QString& rCreatedFilePath, QString& rError); - bool getNewFile(ServerAccess& rAccess, QString relFilePath, QString& rCreatedFilePath, QString& rError); - bool getDiff(ServerAccess& rAccess, QString relLeftFilePath, QString relRightFilePath, QString& rDiff, QString& rError); + static bool getFile(SvnOperationContext& rContext, QString fullRepoPath, Revision rev, QString& rCreatedFilePath, QString& rError); + static bool getDiffFiles(SvnOperationContext& rContext, QString fullRepoPath, Revision leftRevision, Revision rightRevision, QString& rLeftFilePath, QString& rRightFilePath, QString& rError); }; + Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/include/svn/modification.h 2006-08-11 01:04:46 UTC (rev 20) @@ -72,7 +72,7 @@ class SvnOperation { public: - bool initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& rError); + static bool initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& rError); }; class Modifications : public SvnOperation Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/tests/svn_test.cpp 2006-08-11 01:04:46 UTC (rev 20) @@ -20,6 +20,8 @@ #include "svn_test.h" +#include <svn/file_access.h> + #include <svn_client.h> #include <svn_repos.h> #include <svn_path.h> @@ -90,7 +92,7 @@ { QDir dir(filePath); QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot|QDir::Hidden|QDir::System|QDir::AllDirs|QDir::Files); - Q_FOREACH(QFileInfo entry, entries) + foreach(QFileInfo entry, entries) { if (entry.isDir()) { @@ -108,7 +110,21 @@ return true; } + +QString SvnTester::getFileContents(QString filePath) +{ + QFile file(filePath); + Q_ASSERT(file.open(QIODevice::ReadOnly | QIODevice::Text)); + QTextStream in(&file); + QString fileText; + while (!in.atEnd()) + { + fileText += in.readLine(); + } + return fileText; +} + bool SvnTester::updateWc() { apr_array_header_t *array = apr_array_make(mpContext->getAprPool(), 1, sizeof(const char*)); @@ -197,3 +213,20 @@ QCOMPARE(mods[0].getType(), Modification::Type_Add); } +void SvnTester::testRepoFileAccess() +{ + QString rError; + QString filePath; + Revision rev; + rev.setCommittedRevision(1); + QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/first.txt"), rev, filePath, rError)); + QCOMPARE(getFileContents(filePath), QString("This is the first file")); + + rev.setUncommittedRevision(); + QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/second.txt"), rev, filePath, rError)); + QCOMPARE(getFileContents(filePath), QString("This is the second file")); +} + + + + Modified: trunk/tests/svn_test.h =================================================================== --- trunk/tests/svn_test.h 2006-08-10 13:27:59 UTC (rev 19) +++ trunk/tests/svn_test.h 2006-08-11 01:04:46 UTC (rev 20) @@ -59,19 +59,21 @@ QString getRepoPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_repo"); } QString getWcPath() { return QDir::convertSeparators(QDir::tempPath()+"/gsvn_wc"); } - bool createRepos(); bool commitChanges(QString commitMessage); bool addFile(QString relFilePath); bool touchFile(QString relFilePath, QString fileText); // fails if the file exists bool updateWc(); bool removeDirectory(QString filePath); + QString getFileContents(QString filePath); private slots: void init(); void cleanup(); void testModifications(); + + void testRepoFileAccess(); private: // Callbacks This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-09-28 02:04:59
|
Revision: 29 http://svn.sourceforge.net/grandmas-svn/?rev=29&view=rev Author: matthiasmiller Date: 2006-09-27 19:04:44 -0700 (Wed, 27 Sep 2006) Log Message: ----------- refactor ModificationsModel for commit dialog Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/include/dialogs/modificationsmodel.h trunk/include/svn/modification.h trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/modification.cpp Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/include/dialogs/mainwindow.h 2006-09-28 02:04:44 UTC (rev 29) @@ -45,6 +45,8 @@ private: Ui_MainWindow* mpUi; + SvnOperationContext* mpContext; + QString mPath; ModificationsModel* mpModificationsModel; Revision mDisplayedRevision; }; Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/include/dialogs/modificationsmodel.h 2006-09-28 02:04:44 UTC (rev 29) @@ -26,16 +26,21 @@ class ModificationsModel : public QAbstractListModel { public: - ModificationsModel(SvnOperationContext* pContext, QString path); + ModificationsModel(); virtual ~ModificationsModel(); - void loadRevision(Revision revision); + void loadFromRevision(SvnOperationContext* pContext, QString path, Revision revision); + void showError(QString error); + void showModifications(const QList<Modification>& rcModifications); + 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; + void setAllowSelections(bool allowSelections); + private: SvnOperationContext* mpContext; QString mPath; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/include/svn/modification.h 2006-09-28 02:04:44 UTC (rev 29) @@ -81,7 +81,7 @@ // Public, interfaced functions bool init(SvnOperationContext& rContext, QString path, Revision revision, QString& rError); - void getModifications(QList<Modification>& rModifications); + const QList<Modification>& modifications() const; protected: bool getRelativeRepoUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rError); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/src/dialogs/mainwindow.cpp 2006-09-28 02:04:44 UTC (rev 29) @@ -31,9 +31,12 @@ MainWindow::MainWindow(SvnOperationContext* pContext, QString path) : mpModificationsModel(NULL) { - mpModificationsModel = new ModificationsModel(pContext, path); - mpModificationsModel->loadRevision(mDisplayedRevision); + mpContext = pContext; + mPath = path; + mpModificationsModel = new ModificationsModel(); + mpModificationsModel->loadFromRevision(mpContext, mPath, mDisplayedRevision); + mpUi = new Ui_MainWindow(); mpUi->setupUi(this); connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); @@ -64,6 +67,8 @@ mpUi->changesTreeView->setModel(NULL); delete mpModificationsModel; mpModificationsModel = NULL; + + mpContext = NULL; } void MainWindow::changeEvent(QEvent* pEvent) @@ -74,13 +79,13 @@ { // Refresh the modifications if it doesn't require server access. if (mpModificationsModel && !mDisplayedRevision.isCommittedRevision()) - mpModificationsModel->loadRevision(mDisplayedRevision); + mpModificationsModel->loadFromRevision(mpContext, mPath, mDisplayedRevision); } } void MainWindow::commit() { - CommitDialog dlg(this); + CommitDialog dlg(mpContext, mPath, this); dlg.exec(); } Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-09-28 02:04:44 UTC (rev 29) @@ -18,29 +18,43 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "dialogs/modificationsmodel.h" +#include "debug.h" #include "svn/modification.h" +#include "svn/revision.h" -ModificationsModel::ModificationsModel(SvnOperationContext* pContext, QString path) +ModificationsModel::ModificationsModel() { - mpContext = pContext; - mPath = path; } ModificationsModel::~ModificationsModel() { } -void ModificationsModel::loadRevision(Revision revision) +void ModificationsModel::loadFromRevision(SvnOperationContext* pContext, QString path, Revision revision) { - mError = QString(); + Modifications mods; + QString error; + if (mods.init(*mpContext, mPath, revision, error)) + showModifications(mods.modifications()); + else + showError(error); +} - Modifications mods; - if (mods.init(*mpContext, mPath, revision, mError)) - mods.getModifications(mModifications); - +void ModificationsModel::showError(QString error) +{ + GSVN_ASSERT(!error.isNull()); + mError = error; + mModifications.clear(); emit layoutChanged(); } +void ModificationsModel::showModifications(const QList<Modification>& rcModifications) +{ + mError = QString(); + mModifications = rcModifications; + emit layoutChanged(); +} + int ModificationsModel::columnCount(const QModelIndex &rcParent) const { Q_UNUSED(rcParent); Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-09-22 05:09:01 UTC (rev 28) +++ trunk/src/svn/modification.cpp 2006-09-28 02:04:44 UTC (rev 29) @@ -132,9 +132,9 @@ return true; } -void Modifications::getModifications(QList<Modification>& rModifications) +const QList<Modification>& Modifications::modifications() const { - rModifications = mModifications; + return mModifications; } void Modifications::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <hig...@us...> - 2006-10-06 14:54:09
|
Revision: 35 http://svn.sourceforge.net/grandmas-svn/?rev=35&view=rev Author: highjinx Date: 2006-10-06 07:53:39 -0700 (Fri, 06 Oct 2006) Log Message: ----------- Heavily rework svn wrapper code. Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/svn/commit_summary.h trunk/include/svn/file_access.h trunk/include/svn/modification.h trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/file_access.cpp trunk/src/svn/modification.cpp trunk/tests/svn_test.cpp trunk/tests/svn_test.h Added Paths: ----------- trunk/include/svn/operation.h trunk/include/svn/operation_internal.h trunk/src/svn/commit_summary.cpp trunk/src/svn/operation.cpp trunk/src/svn/operation_internal.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/grandmas_svn.pro 2006-10-06 14:53:39 UTC (rev 35) @@ -116,8 +116,11 @@ include/dialogs/open.h \ include/dialogs/util.h \ include/settings/userpaths.h \ + include/svn/commit_summary.h \ include/svn/file_access.h \ include/svn/modification.h \ + include/svn/operation.h \ + include/svn/operation_internal.h \ include/svn/revision.h \ include/svn/server_access.h \ src/grandmas_svn.h @@ -130,8 +133,11 @@ src/dialogs/move.cpp \ src/dialogs/open.cpp \ src/settings/userpaths.cpp \ + src/svn/commit_summary.cpp \ src/svn/file_access.cpp \ src/svn/modification.cpp \ + src/svn/operation.cpp \ + src/svn/operation_internal.cpp \ src/svn/revision.cpp \ src/svn/server_access.cpp \ src/dialogs/util.cpp \ Modified: trunk/include/svn/commit_summary.h =================================================================== --- trunk/include/svn/commit_summary.h 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/include/svn/commit_summary.h 2006-10-06 14:53:39 UTC (rev 35) @@ -18,19 +18,42 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include <svn/modification.h> #include <svn/revision.h> #include <svn/server_access.h> #include <Qt> #include <QList> +#include <QDateTime> +struct svn_error_t; +struct apr_hash_t; +struct svn_wc_status2_t; + class CommitSummary { public: - bool init(QString fullRepoPath, QString revision); + bool init(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, QString& rError); - bool getCommitAuthor(QString& rAuthor, QString& rError); - bool getCommitDate(QDateTime& rDate, QString& rError); - bool getCommitLogMessage(QString& rCommitLog, QString& rError); - bool getCommitModifications(QList<ModificationSummary>& rModifications, 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; } + + // This function may be called for working copy revision + const QList<Modification>& modifications() const { return mModifications; } + +protected: + QString mAuthor; + QDateTime mDate; + QString mLogMessage; + QList<Modification> mModifications; + Revision mRevision; + +private: + QString mWcPath; + +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); + static void statusCallback(void *baton, const char *path, svn_wc_status2_t *status); }; Modified: trunk/include/svn/file_access.h =================================================================== --- trunk/include/svn/file_access.h 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/include/svn/file_access.h 2006-10-06 14:53:39 UTC (rev 35) @@ -24,7 +24,7 @@ #include <QString> -class RepoFileAccess : public SvnOperation +class RepoFileAccess { public: static bool getFile(SvnOperationContext& rContext, QString fullRepoPath, Revision rev, QString& rCreatedFilePath, QString& rError); Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/include/svn/modification.h 2006-10-06 14:53:39 UTC (rev 35) @@ -21,15 +21,12 @@ #ifndef _MODIFICATION_H_ #define _MODIFICATION_H_ -#include "revision.h" +#include <svn/revision.h> -#include <QList> #include <QString> class SvnOperationContext; -struct svn_wc_status2_t; -struct svn_client_ctx_t; -struct svn_info_t; +class CommitSummary; class Modification { @@ -60,7 +57,7 @@ } private: - friend class Modifications; + friend class CommitSummary; Type mType; QString mFilePath; @@ -69,35 +66,4 @@ Revision newRevision; }; -class SvnOperation -{ -public: - static bool initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& rError); -}; - -class Modifications : public SvnOperation -{ -public: - // Public, interfaced functions - bool init(SvnOperationContext& rContext, QString path, Revision revision, QString& rError); - - const QList<Modification>& modifications() const; - -protected: - bool getRelativeRepoUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString& rError); - - QString mWcPath; - Revision mRevision; - SvnOperationContext* mpContext; - - QString mRelativeRepoUrl; - QList<Modification> mModifications; - -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); -}; - #endif Added: trunk/include/svn/operation.h =================================================================== --- trunk/include/svn/operation.h (rev 0) +++ trunk/include/svn/operation.h 2006-10-06 14:53:39 UTC (rev 35) @@ -0,0 +1,34 @@ +/*************************************************************************** + * 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. * + ***************************************************************************/ + +struct svn_client_ctx_t; +struct svn_error_t; +struct svn_info_t; +struct apr_pool_t; + +class SvnOperationContext; +class QString; + +namespace Operation +{ + bool initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& rError); + + bool getRelativeRepoUrl(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelPath, QString& rError); +}; Added: trunk/include/svn/operation_internal.h =================================================================== --- trunk/include/svn/operation_internal.h (rev 0) +++ trunk/include/svn/operation_internal.h 2006-10-06 14:53:39 UTC (rev 35) @@ -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 <QString> + +class SvnOperationContext; +struct svn_client_ctx_t; +struct svn_error_t; +struct svn_info_t; +struct apr_pool_t; + +class RelativeRepoRetriever +{ +public: + bool getRelativeRepoUrl(SvnOperationContext& rContext, svn_client_ctx_t* ctx, QString fullRepoUrl, QString& rRelRepoUrl, QString& rError); + +protected: + static svn_error_t* infoCallback(void *baton, const char *path, const svn_info_t *info, apr_pool_t *pool); + +private: + QString mRelPath; +}; + Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -32,12 +32,12 @@ void ModificationsModel::loadFromRevision(SvnOperationContext* pContext, QString path, Revision revision) { - Modifications mods; - QString error; - if (mods.init(*pContext, path, revision, error)) - showModifications(mods.modifications()); - else - showError(error); +// Modifications mods; +// QString error; +// if (mods.init(*pContext, path, revision, error)) +// showModifications(mods.modifications()); +// else +// showError(error); } void ModificationsModel::showError(QString error) Added: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp (rev 0) +++ trunk/src/svn/commit_summary.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -0,0 +1,191 @@ +/*************************************************************************** + * 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/commit_summary.h" +#include "svn/operation.h" + +#include <svn_client.h> +#include <svn_path.h> + +bool CommitSummary::init(SvnOperationContext& rContext, QString fullRepoPath, Revision revision, QString& rError) +{ + mModifications.clear(); + rError = ""; + mRevision = revision; + //mpContext = &rServer; + mWcPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); + + svn_client_ctx_t* ctx; + svn_client_create_context(&ctx, rContext.getAprPool()); + if (!Operation::initAuthProviders(ctx, rContext, rError)) + return false; + + if (!Operation::getRelativeRepoUrl(rContext, fullRepoPath, ctx, mWcPath, rError)) + return false; + + svn_error_t* pError = NULL; + if (revision.isCommittedRevision()) + { + svn_opt_revision_t startRev = revision.getSvnRevision(); + svn_opt_revision_t endRev = revision.getSvnRevision(); + apr_array_header_t *array = apr_array_make(rContext.getAprPool(), 1, sizeof(const char*)); + APR_ARRAY_PUSH(array, const char*) = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); + + pError = svn_client_log2(array, + &startRev, + &endRev, + 0/*limit*/, + true/*discover_changed_paths*/, + false/*strict_node_history*/, + logCallback, + this, + ctx, + rContext.getAprPool()); + } + else + { + svn_opt_revision_t svnRevision = revision.getSvnRevision(); + const char* canonPath = svn_path_canonicalize(fullRepoPath.toAscii(), rContext.getAprPool()); + pError = svn_client_status2(NULL, canonPath, &svnRevision, + statusCallback, + this, + true/*recurse*/, + false/*get_all*/, + false/*update*/, + false /*no_ignore*/, + true/*ignore_externals*/, + ctx/*svn_client_ctx_t*/, + rContext.getAprPool()); + } + if (pError) + { + rError = pError->message; + return false; + } + 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) +{ + CommitSummary* pThis = (CommitSummary*)baton; + for (apr_hash_index_t* pKey = apr_hash_first(pool, changed_paths); pKey; pKey = apr_hash_next(pKey)) + { + char *path; + void *val; + apr_hash_this(pKey, (const void **)&path, NULL, &val); + + 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); + switch (log_item->action) + { + case 'A': + mod.mType = Modification::Type_Add; + break; + case 'D': + mod.mType = Modification::Type_Delete; + break; + case 'R': + // TODO: handle "replace" + mod.mType = Modification::Type_Add; + break; + case 'M': + mod.mType = Modification::Type_TextMod; + break; + default: + // TODO: return error + break; + } + pThis->mModifications.append(mod); + } + + return NULL; + + pThis->mAuthor = author; + //pThis->mDate = date; + pThis->mLogMessage = message; + + return NULL; +} + +void CommitSummary::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) +{ + CommitSummary* pThis = (CommitSummary*)baton; + + Modification mod; + mod.newRevision = pThis->mRevision; + + // Set old revision to base, if the file is already under version control + if (status->entry) + mod.oldRevision.setCommittedRevision(status->entry->revision); + + switch (status->text_status) + { + // cases we care about + case svn_wc_status_unversioned: + mod.mType = Modification::Type_New; + break; + case svn_wc_status_added: + mod.mFilePath = path; + mod.mType = Modification::Type_Add; + break; + + case svn_wc_status_missing: + mod.mType = Modification::Type_Missing; + break; + + case svn_wc_status_deleted: + mod.mType = Modification::Type_Delete; + break; + + case svn_wc_status_modified: + mod.mType = Modification::Type_TextMod; + break; + + case svn_wc_status_conflicted: + mod.mType = Modification::Type_Conflicting; + break; + + // cases we can ignore + case svn_wc_status_ignored: + case svn_wc_status_obstructed: + case svn_wc_status_merged: + case svn_wc_status_normal: + case svn_wc_status_none: + return; + + // cases we need to learn how to handle + case svn_wc_status_replaced: + case svn_wc_status_incomplete: + case svn_wc_status_external: + assert(false); + break; + + } + mod.mFilePath = path; + if (mod.mFilePath.startsWith(pThis->mWcPath)) + mod.mFilePath.remove(0, pThis->mWcPath.length()); + + pThis->mModifications.append(mod); +} Modified: trunk/src/svn/file_access.cpp =================================================================== --- trunk/src/svn/file_access.cpp 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/src/svn/file_access.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -18,7 +18,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include <svn/file_access.h> +#include "svn/file_access.h" +#include "svn/operation.h" #include <svn_client.h> @@ -69,7 +70,7 @@ svn_client_ctx_t* pCtx = NULL; svn_client_create_context(&pCtx, rContext.getAprPool()); - if (!initAuthProviders(pCtx, rContext, rError)) + if (!Operation::initAuthProviders(pCtx, rContext, rError)) return false; svn_opt_revision_t svnRev = rev.getSvnRevision(); @@ -88,6 +89,6 @@ bool RepoFileAccess::getDiffFiles(SvnOperationContext& rContext, QString fullRepoPath, Revision leftRevision, Revision rightRevision, QString& rLeftFilePath, QString& rRightFilePath, QString& rError) { - return getFile(rContext, fullRepoPath, leftRevision, rLeftFilePath, rError) && !getFile(rContext, fullRepoPath, rightRevision, rRightFilePath, rError); + return getFile(rContext, fullRepoPath, leftRevision, rLeftFilePath, rError) && getFile(rContext, fullRepoPath, rightRevision, rRightFilePath, rError); } Modified: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/src/svn/modification.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -17,252 +17,3 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - -#include <svn/modification.h> -#include <svn/server_access.h> -#include "debug.h" - -#include <apr_pools.h> -#include <assert.h> -#include <iostream> -#include <svn_client.h> -#include <svn_path.h> -#include <svn_pools.h> - -using namespace std; - -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; - SvnAuthentication* pAuth = ((SvnAuthentication*)baton); - if (!pAuth->getAuthentication(promptUsername)) - 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(); - lcred->password = pAuth->getPassword(); - - // tell svn if the credentials need to be saved - lcred->may_save = true; - *cred = lcred; - - return SVN_NO_ERROR; - } - - -bool SvnOperation::initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& /*rError*/) -{ - apr_array_header_t *providers = apr_array_make(rContext.getAprPool(), 3, sizeof(svn_auth_provider_object_t *)); - - svn_auth_provider_object_t *provider; - - svn_client_get_simple_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - - svn_client_get_username_provider(&provider, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - - svn_client_get_simple_prompt_provider(&provider, simpleAuthPrompt, rContext.getAuthenticationCallback(), 100000000, rContext.getAprPool()); - APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; - - // TODO: add ssl providers - - svn_auth_baton_t *authBaton; - svn_auth_open(&authBaton, providers, rContext.getAprPool()); - - context->auth_baton = authBaton; - return true; -} - -bool Modifications::init(SvnOperationContext& rServer, QString path, Revision revision, QString& rError) -{ - mModifications.clear(); - rError = ""; - mpContext = &rServer; - mWcPath = svn_path_canonicalize(path.toAscii(), rServer.getAprPool()); - - svn_client_ctx_t* ctx; - svn_client_create_context(&ctx, rServer.getAprPool()); - if (!initAuthProviders(ctx, rServer, rError)) - return false; - - if (!getRelativeRepoUrl(rServer, ctx, rError)) - return false; - - svn_error_t* pError = NULL; - if (revision.isCommittedRevision()) - { - 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()); - - pError = svn_client_log2(array, - &startRev, - &endRev, - 0/*limit*/, - true/*discover_changed_paths*/, - false/*strict_node_history*/, - logCallback, - this, - ctx, - rServer.getAprPool()); - } - else - { - svn_opt_revision_t svnRevision = revision.getSvnRevision(); - const char* canonPath = svn_path_canonicalize(path.toAscii(), rServer.getAprPool()); - pError = svn_client_status2(NULL, canonPath, &svnRevision, - statusCallback, - this, - true/*recurse*/, - false/*get_all*/, - false/*update*/, - false /*no_ignore*/, - true/*ignore_externals*/, - ctx/*svn_client_ctx_t*/, - rServer.getAprPool()); - } - if (pError) - { - rError = pError->message; - return false; - } - return true; -} - -const QList<Modification>& Modifications::modifications() const -{ - return mModifications; -} - -void Modifications::statusCallback(void *baton, const char *path, svn_wc_status2_t *status) -{ - Modifications* pThis = (Modifications*)baton; - - Modification mod; - mod.newRevision = pThis->mRevision; - - // Set old revision to base, if the file is already under version control - if (status->entry) - mod.oldRevision.setCommittedRevision(status->entry->revision); - - switch (status->text_status) - { - // cases we care about - case svn_wc_status_unversioned: - mod.mType = Modification::Type_New; - break; - case svn_wc_status_added: - mod.mFilePath = path; - mod.mType = Modification::Type_Add; - break; - - case svn_wc_status_missing: - mod.mType = Modification::Type_Missing; - break; - - case svn_wc_status_deleted: - mod.mType = Modification::Type_Delete; - break; - - case svn_wc_status_modified: - mod.mType = Modification::Type_TextMod; - break; - - case svn_wc_status_conflicted: - mod.mType = Modification::Type_Conflicting; - break; - - // cases we can ignore - case svn_wc_status_ignored: - case svn_wc_status_obstructed: - case svn_wc_status_merged: - case svn_wc_status_normal: - case svn_wc_status_none: - return; - - // cases we need to learn how to handle - case svn_wc_status_replaced: - case svn_wc_status_incomplete: - case svn_wc_status_external: - assert(false); - break; - - } - 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) -{ - Modifications* pThis = (Modifications*)baton; - for (apr_hash_index_t* pKey = apr_hash_first(pool, changed_paths); pKey; pKey = apr_hash_next(pKey)) - { - char *path; - void *val; - apr_hash_this(pKey, (const void **)&path, NULL, &val); - - 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); - switch (log_item->action) - { - case 'A': - mod.mType = Modification::Type_Add; - break; - case 'D': - mod.mType = Modification::Type_Delete; - break; - case 'R': - // TODO: handle "replace" - mod.mType = Modification::Type_Add; - break; - case 'M': - mod.mType = Modification::Type_TextMod; - break; - default: - // TODO: return error - break; - } - 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; -} - Added: trunk/src/svn/operation.cpp =================================================================== --- trunk/src/svn/operation.cpp (rev 0) +++ trunk/src/svn/operation.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -0,0 +1,113 @@ +/*************************************************************************** + * 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/operation.h" +#include "svn/server_access.h" + +#include <apr_pools.h> +#include <svn_client.h> + +#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) +{ + QString promptUsername = username; + QString promptPassword; + SvnAuthentication* pAuth = ((SvnAuthentication*)baton); + if (!pAuth->getAuthentication(promptUsername)) + 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(); + lcred->password = pAuth->getPassword(); + + // tell svn if the credentials need to be saved + lcred->may_save = true; + *cred = lcred; + + return SVN_NO_ERROR; + } + + +bool Operation::initAuthProviders(svn_client_ctx_t* context, SvnOperationContext& rContext, QString& /*rError*/) +{ + apr_array_header_t *providers = apr_array_make(rContext.getAprPool(), 3, sizeof(svn_auth_provider_object_t *)); + + svn_auth_provider_object_t *provider; + + svn_client_get_simple_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + svn_client_get_username_provider(&provider, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + svn_client_get_simple_prompt_provider(&provider, simpleAuthPrompt, rContext.getAuthenticationCallback(), 100000000, rContext.getAprPool()); + APR_ARRAY_PUSH(providers,svn_auth_provider_object_t*) = provider; + + // TODO: add ssl providers + + svn_auth_baton_t *authBaton; + svn_auth_open(&authBaton, providers, rContext.getAprPool()); + + context->auth_baton = authBaton; + return true; +} + +class SvnInfo +{ +public: + bool getRelativeRepoUrl(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelPath, QString& rError) + { + svn_error_t* pError = svn_client_info(fullRepoPath.toAscii(), NULL, NULL, infoCallback, this, false, ctx, rContext.getAprPool()); + if (pError) + { + rError = pError->message; + return false; + } + rRelPath = mRelativeRepoUrl; + return true; + } + +protected: + static svn_error_t* infoCallback(void *baton, const char */*path*/, const svn_info_t *info, apr_pool_t */*pool*/) + { + SvnInfo* pThis = (SvnInfo*)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; + } + + QString mRelativeRepoUrl; +}; + + +bool Operation::getRelativeRepoUrl(SvnOperationContext& rContext, QString fullRepoPath, svn_client_ctx_t* ctx, QString& rRelPath, QString& rError) +{ + SvnInfo info; + return info.getRelativeRepoUrl(rContext, fullRepoPath, ctx, rRelPath, rError); +} + Added: trunk/src/svn/operation_internal.cpp =================================================================== --- trunk/src/svn/operation_internal.cpp (rev 0) +++ trunk/src/svn/operation_internal.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -0,0 +1,21 @@ +/*************************************************************************** + * 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/operation_internal.h> Modified: trunk/tests/svn_test.cpp =================================================================== --- trunk/tests/svn_test.cpp 2006-10-06 05:51:36 UTC (rev 34) +++ trunk/tests/svn_test.cpp 2006-10-06 14:53:39 UTC (rev 35) @@ -20,7 +20,10 @@ #include "svn_test.h" +#include <svn/commit_summary.h> #include <svn/file_access.h> +#include <svn/modification.h> +#include "svn/operation.h" #include <svn_client.h> #include <svn_repos.h> @@ -38,7 +41,7 @@ svn_client_create_context(&mpCtx, mpContext->getAprPool()); QString rIgnoredError; - Q_ASSERT(initAuthProviders(mpCtx, *mpContext, rIgnoredError)); + Q_ASSERT(Operation::initAuthProviders(mpCtx, *mpContext, rIgnoredError)); mpCtx->log_msg_func = logMsgCallback; mpCtx->log_msg_baton = this; @@ -164,7 +167,7 @@ QVERIFY(touchFile("/first.txt", "This is the first file")); QVERIFY(addFile("/first.txt")); - QVERIFY(commitChanges("First commit")); + QVERIFY(commitChanges("first commit")); QVERIFY(touchFile("/second.txt", "This is the second file")); QVERIFY(addFile("/second.txt")); @@ -190,23 +193,20 @@ void SvnTester::testModifications() { - Modifications modifications; + CommitSummary summary; QString rError; Revision rev; rev.setCommittedRevision(1); - QVERIFY(modifications.init(*mpContext, getWcPath(), rev, rError)); + QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); - QList<Modification> mods; - mods = modifications.modifications(); + const QList<Modification>& mods = summary.modifications(); QCOMPARE(mods.size(), 1); QCOMPARE(mods[0].getFilePath(), QString("/first.txt")); QCOMPARE(mods[0].getType(), Modification::Type_Add); rev.setUncommittedRevision(); - QVERIFY(modifications.init(*mpContext, getWcPath(), rev, rError)); - - mods = modifications.modifications(); + QVERIFY(summary.init(*mpContext, getWcPath(), rev, rError)); QCOMPARE(mods.size(), 1); QCOMPARE(mods[0].getFilePath(), QString("/second.txt")); @@ -217,16 +217,40 @@ { QString rError; QString filePath; - Revision rev; - rev.setCommittedRevision(1); - QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/first.txt"), rev, filePath, rError)); + Revision oldRev; + oldRev.setCommittedRevision(1); + QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/first.txt"), oldRev, filePath, rError)); QCOMPARE(getFileContents(filePath), QString("This is the first file")); + QVERIFY(filePath != getWcPath()+"/first.txt"); // We should not overwrite the WC copy! - rev.setUncommittedRevision(); - QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/second.txt"), rev, filePath, rError)); + Revision newRev; + newRev.setUncommittedRevision(); + QVERIFY(RepoFileAccess::getFile(*mpContext, QDir::convertSeparators(getWcPath()+"/second.txt"), newRev, filePath, rError)); + + 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")); + + QString oldFilePath, newFilePath; + QVERIFY(RepoFileAccess::getDiffFiles(*mpContext, getWcPath()+"/first.txt", oldRev, newRev, oldFilePath, newFilePath, rError)); + 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.setCommittedRevision(1); + + CommitSummary summary; + QVERIFY(summary.init(*mpContext, getRepoPath(), rev, rError)); + + QCOMPARE(summary.getCommitAuthor(), QString("billfrank")); + //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 05:51:36 UTC (rev 34) +++ trunk/tests/svn_test.h 2006-10-06 14:53:39 UTC (rev 35) @@ -47,7 +47,7 @@ virtual bool getAuthentication(QString& /*rUsername*/, QString& /*rPassword*/) { return false; } }; -class SvnTester : public QObject, public SvnOperation +class SvnTester : public QObject { Q_OBJECT @@ -75,6 +75,8 @@ 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); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-06 17:50:59
|
Revision: 36 http://svn.sourceforge.net/grandmas-svn/?rev=36&view=rev Author: matthiasmiller Date: 2006-10-06 10:50:54 -0700 (Fri, 06 Oct 2006) Log Message: ----------- start showing modifications in MainWindow and CommitDialog Modified Paths: -------------- trunk/grandmas_svn.pro trunk/include/dialogs/commit.h trunk/include/dialogs/mainwindow.h trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp Removed Paths: ------------- trunk/src/svn/modification.cpp Modified: trunk/grandmas_svn.pro =================================================================== --- trunk/grandmas_svn.pro 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/grandmas_svn.pro 2006-10-06 17:50:54 UTC (rev 36) @@ -135,7 +135,6 @@ src/settings/userpaths.cpp \ src/svn/commit_summary.cpp \ src/svn/file_access.cpp \ - src/svn/modification.cpp \ src/svn/operation.cpp \ src/svn/operation_internal.cpp \ src/svn/revision.cpp \ Modified: trunk/include/dialogs/commit.h =================================================================== --- trunk/include/dialogs/commit.h 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/include/dialogs/commit.h 2006-10-06 17:50:54 UTC (rev 36) @@ -24,16 +24,27 @@ #include <QDialog> +class ModificationsModel; +class SvnOperationContext; class Ui_CommitDialog; class CommitDialog : public QDialog { public: - CommitDialog(QWidget* pParent); + CommitDialog(SvnOperationContext* pContext, QString path, QWidget* pParent); ~CommitDialog(); +protected: + virtual void changeEvent(QEvent* pEvent); + private: + void reload(); + Ui_CommitDialog* mpUi; + + SvnOperationContext* mpContext; + QString mPath; + ModificationsModel* mpModificationsModel; }; #endif Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/include/dialogs/mainwindow.h 2006-10-06 17:50:54 UTC (rev 36) @@ -44,6 +44,8 @@ void move(); private: + void reload(); + Ui_MainWindow* mpUi; SvnOperationContext* mpContext; QString mPath; Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-06 17:50:54 UTC (rev 36) @@ -29,8 +29,6 @@ ModificationsModel(); virtual ~ModificationsModel(); - void loadFromRevision(SvnOperationContext* pContext, QString path, Revision revision); - void showError(QString error); void showModifications(const QList<Modification>& rcModifications); Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/src/dialogs/commit.cpp 2006-10-06 17:50:54 UTC (rev 36) @@ -19,14 +19,25 @@ ***************************************************************************/ #include "dialogs/commit.h" +#include "dialogs/modificationsmodel.h" #include "dialogs/util.h" +#include "svn/commit_summary.h" +#include "svn/revision.h" #include "ui_commit.h" -CommitDialog::CommitDialog(QWidget* pParent) : QDialog(pParent) +CommitDialog::CommitDialog(SvnOperationContext* pContext, QString path, QWidget* pParent) : QDialog(pParent) { + mpContext = pContext; + mPath = path; + mpUi = new Ui_CommitDialog(); mpUi->setupUi(this); + mpModificationsModel = new ModificationsModel(); + mpUi->changesTreeView->setModel(mpModificationsModel); + + reload(); + #ifdef Q_WS_MAC exchangeWidgets(mpUi->hboxLayout, mpUi->okButton, mpUi->cancelButton); #endif @@ -34,6 +45,31 @@ CommitDialog::~CommitDialog() { + mpUi->changesTreeView->setModel(NULL); + delete mpModificationsModel; + mpModificationsModel = NULL; + delete mpUi; mpUi = NULL; } + +void CommitDialog::changeEvent(QEvent* pEvent) +{ + QDialog::changeEvent(pEvent); + + if (pEvent->type() == QEvent::ActivationChange && isActiveWindow()) + { + if (mpModificationsModel) + reload(); + } +} + +void CommitDialog::reload() +{ + CommitSummary summary; + QString error; + if (summary.init(*mpContext, mPath, Revision(), error)) + mpModificationsModel->showModifications(summary.modifications()); + else + mpModificationsModel->showError(error); +} \ No newline at end of file Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-06 17:50:54 UTC (rev 36) @@ -23,6 +23,7 @@ #include "dialogs/commit.h" #include "dialogs/modificationsmodel.h" #include "dialogs/move.h" +#include "svn/commit_summary.h" #include "svn/revision.h" #include "ui_mainwindow.h" @@ -34,15 +35,16 @@ mpContext = pContext; mPath = path; - mpModificationsModel = new ModificationsModel(); - mpModificationsModel->loadFromRevision(mpContext, mPath, mDisplayedRevision); - mpUi = new Ui_MainWindow(); mpUi->setupUi(this); connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); + + mpModificationsModel = new ModificationsModel(); mpUi->changesTreeView->setModel(mpModificationsModel); + reload(); + const svn_version_t* pVersion = svn_client_version(); QString msg; @@ -79,13 +81,13 @@ { // Refresh the modifications if it doesn't require server access. if (mpModificationsModel && !mDisplayedRevision.isCommittedRevision()) - mpModificationsModel->loadFromRevision(mpContext, mPath, mDisplayedRevision); + reload(); } } void MainWindow::commit() { - CommitDialog dlg(this); + CommitDialog dlg(mpContext, mPath, this); dlg.exec(); } @@ -94,3 +96,13 @@ MoveDialog dlg(this); dlg.exec(); } + +void MainWindow::reload() +{ + CommitSummary summary; + QString error; + if (summary.init(*mpContext, mPath, mDisplayedRevision, error)) + mpModificationsModel->showModifications(summary.modifications()); + else + mpModificationsModel->showError(error); +} \ No newline at end of file Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 17:50:54 UTC (rev 36) @@ -30,16 +30,6 @@ { } -void ModificationsModel::loadFromRevision(SvnOperationContext* pContext, QString path, Revision revision) -{ -// Modifications mods; -// QString error; -// if (mods.init(*pContext, path, revision, error)) -// showModifications(mods.modifications()); -// else -// showError(error); -} - void ModificationsModel::showError(QString error) { GSVN_ASSERT(!error.isNull()); Deleted: trunk/src/svn/modification.cpp =================================================================== --- trunk/src/svn/modification.cpp 2006-10-06 14:53:39 UTC (rev 35) +++ trunk/src/svn/modification.cpp 2006-10-06 17:50:54 UTC (rev 36) @@ -1,19 +0,0 @@ -/*************************************************************************** - * 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. * - ***************************************************************************/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-06 22:36:39
|
Revision: 39 http://svn.sourceforge.net/grandmas-svn/?rev=39&view=rev Author: matthiasmiller Date: 2006-10-06 15:36:36 -0700 (Fri, 06 Oct 2006) Log Message: ----------- show read-only checkboxes in commit dialog Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-06 19:20:47 UTC (rev 38) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-06 22:36:36 UTC (rev 39) @@ -39,7 +39,16 @@ void setAllowSelections(bool allowSelections); + bool hasCheckboxColumn() const; + int getCheckboxColumn() const; + private: + bool isErrorColumn(int col) const; + bool isCheckboxColumn(int col) const; + bool isTypeColumn(int col) const; + bool isPathColumn(int col) const; + QString mError; QList<Modification> mModifications; + bool mAllowSelections; }; Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-06 19:20:47 UTC (rev 38) +++ trunk/src/dialogs/commit.cpp 2006-10-06 22:36:36 UTC (rev 39) @@ -34,6 +34,7 @@ mpUi->setupUi(this); mpModificationsModel = new ModificationsModel(); + mpModificationsModel->setAllowSelections(true); mpUi->changesTreeView->setModel(mpModificationsModel); reload(); @@ -71,5 +72,8 @@ if (summary.init(*mpContext, mPath, Revision(), error)) mpModificationsModel->showModifications(summary.modifications()); else - mpModificationsModel->showError(error); + mpModificationsModel->showError(error); + + if (mpModificationsModel->hasCheckboxColumn()) + mpUi->changesTreeView->resizeColumnToContents(mpModificationsModel->getCheckboxColumn()); } \ No newline at end of file Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 19:20:47 UTC (rev 38) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 22:36:36 UTC (rev 39) @@ -22,7 +22,9 @@ #include "svn/modification.h" #include "svn/revision.h" -ModificationsModel::ModificationsModel() +#include <QSize> + +ModificationsModel::ModificationsModel() : mAllowSelections(false) { } @@ -48,81 +50,133 @@ int ModificationsModel::columnCount(const QModelIndex &rcParent) const { Q_UNUSED(rcParent); - return mError.isEmpty() ? 2 : 1; + + if (!mError.isEmpty()) + return 1; + return mAllowSelections ? 3 : 2; } int ModificationsModel::rowCount(const QModelIndex& rcParent) const { Q_UNUSED(rcParent); - if (mError.isEmpty()) - return mModifications.size(); - else + if (!mError.isEmpty()) return 1; + + return mModifications.size(); } QVariant ModificationsModel::headerData(int section, Qt::Orientation orientation, int role) const { - Q_UNUSED(orientation); - - if (role != Qt::DisplayRole) - return QVariant(); - - if (!mError.isEmpty()) - return QVariant(); - - switch (section) + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { - case 0: return tr("Type"); - case 1: return tr("File"); - default: - Q_ASSERT(false); + // Top headings + if (isTypeColumn(section)) + return tr("Type"); + else if (isPathColumn(section)) + return tr("File"); + else return QVariant(); } + else + return QVariant(); } QVariant ModificationsModel::data(const QModelIndex& rcIndex, int role) const { - if (!rcIndex.isValid()) - return QVariant(); - - if (role != Qt::DisplayRole) - return QVariant(); + if (role == Qt::DisplayRole) + { + if (isErrorColumn(rcIndex.column())) + return mError; - if (!mError.isEmpty()) - return mError; + if (!rcIndex.isValid()) + return QVariant(); + + if (rcIndex.row() >= mModifications.size()) + return QVariant(); + + Modification mod = mModifications.at(rcIndex.row()); + if (isCheckboxColumn(rcIndex.column())) + { + return QVariant(); + } + else if (isTypeColumn(rcIndex.column())) + { + 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_Move: return tr("Moved"); + case Modification::Type_PropMod: return tr("Property Modified"); + case Modification::Type_Copy: return tr("Copied"); + case Modification::Type_New: return tr("?"); + case Modification::Type_Missing: return tr("!"); + case Modification::Type_Conflicting: return tr("Conflicting"); + } - if (rcIndex.row() >= mModifications.size()) - return QVariant(); - - Modification mod = mModifications.at(rcIndex.row()); - switch (rcIndex.column()) - { - case 0: - switch (mod.getType()) + Q_ASSERT(false); + return QVariant(); + } + else if (isPathColumn(rcIndex.column())) { - case Modification::Type_TextMod: return tr("Modified"); - case Modification::Type_Add: return tr("Added"); - case Modification::Type_Delete: return tr("Deleted"); - case Modification::Type_Move: return tr("Moved"); - case Modification::Type_PropMod: return tr("Property Modified"); - case Modification::Type_Copy: return tr("Copied"); - case Modification::Type_New: return tr("?"); - case Modification::Type_Missing: return tr("!"); - case Modification::Type_Conflicting: return tr("Conflicting"); + if (mod.getType() == Modification::Type_Move || mod.getType() == Modification::Type_Copy) + return mod.getFilePath() + "\n" + mod.getDestFilePath(); + else + return mod.getFilePath(); } - - Q_ASSERT(false); - return QVariant(); - - case 1: - if (mod.getType() == Modification::Type_Move || mod.getType() == Modification::Type_Copy) - return mod.getFilePath() + "\n" + mod.getDestFilePath(); else - return mod.getFilePath(); + return QVariant(); + } + else if (role == Qt::CheckStateRole) + { + if (isCheckboxColumn(rcIndex.column())) + return Qt::Checked; - default: - Q_ASSERT(false); return QVariant(); } + else + return QVariant(); } + +void ModificationsModel::setAllowSelections(bool allowSelections) +{ + mAllowSelections = allowSelections; +} + +bool ModificationsModel::hasCheckboxColumn() const +{ + return mError.isEmpty() && mAllowSelections; +} + +int ModificationsModel::getCheckboxColumn() const +{ + GSVN_ASSERT(hasCheckboxColumn()); + return 0; +} + +bool ModificationsModel::isErrorColumn(int col) const +{ + if (mError.isEmpty()) + return false; + return col == 0; +} + +bool ModificationsModel::isCheckboxColumn(int col) const +{ + return hasCheckboxColumn() && getCheckboxColumn() == col; +} + +bool ModificationsModel::isTypeColumn(int col) const +{ + if (!mError.isEmpty()) + return false; + return col == (mAllowSelections ? 1 : 0); +} + +bool ModificationsModel::isPathColumn(int col) const +{ + if (!mError.isEmpty()) + return false; + return col == (mAllowSelections ? 2 : 1); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-06 23:27:30
|
Revision: 40 http://svn.sourceforge.net/grandmas-svn/?rev=40&view=rev Author: matthiasmiller Date: 2006-10-06 16:27:23 -0700 (Fri, 06 Oct 2006) Log Message: ----------- allow modifications to be checked/unchecked in commit dialog Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/include/svn/modification.h trunk/include/svn/revision.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/commit_summary.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-06 23:27:23 UTC (rev 40) @@ -36,6 +36,9 @@ 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; + + virtual bool setData(const QModelIndex& rcIndex, const QVariant& rcValue, int role); + virtual Qt::ItemFlags flags(const QModelIndex& rcIndex) const; void setAllowSelections(bool allowSelections); @@ -49,6 +52,6 @@ bool isPathColumn(int col) const; QString mError; - QList<Modification> mModifications; + QList<Modification> mAllModifications, mDeclinedModifications; bool mAllowSelections; }; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/include/svn/modification.h 2006-10-06 23:27:23 UTC (rev 40) @@ -46,6 +46,21 @@ Type_Conflicting, }; + bool operator==(const Modification& rcOther) const + { + if (mType != rcOther.mType) return false; + if (mFilePath != rcOther.mFilePath) return false; + if (mDestFilePath != rcOther.mDestFilePath) return false; + if (mOldRevision != rcOther.mOldRevision) return false; + if (mNewRevision != rcOther.mNewRevision) return false; + + return true; + } + bool operator!=(const Modification& rcOther) const + { + return !(*this == rcOther); + } + QString getFilePath() const { return mFilePath; } Type getType() const { return mType; } @@ -62,8 +77,8 @@ Type mType; QString mFilePath; QString mDestFilePath; - Revision oldRevision; - Revision newRevision; + Revision mOldRevision; + Revision mNewRevision; }; #endif Modified: trunk/include/svn/revision.h =================================================================== --- trunk/include/svn/revision.h 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/include/svn/revision.h 2006-10-06 23:27:23 UTC (rev 40) @@ -31,6 +31,20 @@ Revision(); ~Revision(); + bool operator==(const Revision& rcOther) const + { + if (mIsCommitted != rcOther.mIsCommitted) + return false; + if (mIsCommitted && mCommittedRevision != rcOther.mCommittedRevision) + return false; + + return true; + } + bool operator!=(const Revision& rcOther) const + { + return !(*this == rcOther); + } + void setUncommittedRevision(); void setCommittedRevision(int revision); Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/src/dialogs/commit.cpp 2006-10-06 23:27:23 UTC (rev 40) @@ -76,4 +76,5 @@ if (mpModificationsModel->hasCheckboxColumn()) mpUi->changesTreeView->resizeColumnToContents(mpModificationsModel->getCheckboxColumn()); -} \ No newline at end of file +} + Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 23:27:23 UTC (rev 40) @@ -36,14 +36,14 @@ { GSVN_ASSERT(!error.isNull()); mError = error; - mModifications.clear(); + mAllModifications.clear(); emit layoutChanged(); } void ModificationsModel::showModifications(const QList<Modification>& rcModifications) { mError = QString(); - mModifications = rcModifications; + mAllModifications = rcModifications; emit layoutChanged(); } @@ -63,7 +63,7 @@ if (!mError.isEmpty()) return 1; - return mModifications.size(); + return mAllModifications.size(); } QVariant ModificationsModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -84,18 +84,22 @@ QVariant ModificationsModel::data(const QModelIndex& rcIndex, int role) const { - if (role == Qt::DisplayRole) + if (!mError.isEmpty()) { - if (isErrorColumn(rcIndex.column())) + // show error? + if (role == Qt::DisplayRole && isErrorColumn(rcIndex.column())) return mError; - - if (!rcIndex.isValid()) - return QVariant(); - if (rcIndex.row() >= mModifications.size()) - return QVariant(); - - Modification mod = mModifications.at(rcIndex.row()); + return QVariant(); + } + + // require a valid modification + if (!rcIndex.isValid() || rcIndex.row() >= mAllModifications.size()) + return QVariant(); + + Modification mod = mAllModifications.at(rcIndex.row()); + if (role == Qt::DisplayRole) + { if (isCheckboxColumn(rcIndex.column())) { return QVariant(); @@ -131,7 +135,12 @@ else if (role == Qt::CheckStateRole) { if (isCheckboxColumn(rcIndex.column())) - return Qt::Checked; + { + if (mDeclinedModifications.contains(mod)) + return Qt::Unchecked; + else + return Qt::Checked; + } return QVariant(); } @@ -139,6 +148,43 @@ return QVariant(); } +bool ModificationsModel::setData(const QModelIndex& rcIndex, const QVariant& rcValue, int role) +{ + if (isCheckboxColumn(rcIndex.column()) && rcValue.canConvert(QVariant::Bool) && + rcIndex.isValid() && rcIndex.row() < mAllModifications.size()) + { + Modification mod = mAllModifications.at(rcIndex.row()); + if (rcValue.toBool()) + { + // remove from list of declined mods + mDeclinedModifications.removeAll(mod); + } + else + { + // add to the list of declined modifications + if (!mDeclinedModifications.contains(mod)) + mDeclinedModifications.push_back(mod); + } + + return true; + } + else + return QAbstractListModel::setData(rcIndex, rcValue, role); +} + +Qt::ItemFlags ModificationsModel::flags(const QModelIndex& rcIndex) const +{ + Qt::ItemFlags flags = QAbstractListModel::flags(rcIndex); + + if (isCheckboxColumn(rcIndex.column())) + { + // Enable checkboxes + if (rcIndex.isValid() && rcIndex.row() < mAllModifications.size()) + flags |= Qt::ItemIsUserCheckable; + } + return flags; +} + void ModificationsModel::setAllowSelections(bool allowSelections) { mAllowSelections = allowSelections; Modified: trunk/src/svn/commit_summary.cpp =================================================================== --- trunk/src/svn/commit_summary.cpp 2006-10-06 22:36:36 UTC (rev 39) +++ trunk/src/svn/commit_summary.cpp 2006-10-06 23:27:23 UTC (rev 40) @@ -96,8 +96,8 @@ mod.mFilePath = path; - mod.newRevision.setCommittedRevision(revision); - mod.oldRevision.setCommittedRevision(revision-1); + mod.mNewRevision.setCommittedRevision(revision); + mod.mOldRevision.setCommittedRevision(revision-1); svn_log_changed_path_t *log_item = reinterpret_cast<svn_log_changed_path_t *>(val); switch (log_item->action) { @@ -133,11 +133,11 @@ CommitSummary* pThis = (CommitSummary*)baton; Modification mod; - mod.newRevision = pThis->mRevision; + mod.mNewRevision = pThis->mRevision; // Set old revision to base, if the file is already under version control if (status->entry) - mod.oldRevision.setCommittedRevision(status->entry->revision); + mod.mOldRevision.setCommittedRevision(status->entry->revision); switch (status->text_status) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-13 16:41:18
|
Revision: 41 http://svn.sourceforge.net/grandmas-svn/?rev=41&view=rev Author: matthiasmiller Date: 2006-10-13 09:40:55 -0700 (Fri, 13 Oct 2006) Log Message: ----------- -bracket allColumnsShowFocus setting to allow building with Qt 4.1 -rename "Type" column to "Status" Modified Paths: -------------- trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/dialogs/open.cpp trunk/ui/commit.ui trunk/ui/mainwindow.ui Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/src/dialogs/commit.cpp 2006-10-13 16:40:55 UTC (rev 41) @@ -32,6 +32,9 @@ mpUi = new Ui_CommitDialog(); mpUi->setupUi(this); +#if QT_VERSION >= 0x040200 + mpUi->changesTreeView->setAllColumnsShowFocus(true); +#endif mpModificationsModel = new ModificationsModel(); mpModificationsModel->setAllowSelections(true); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-13 16:40:55 UTC (rev 41) @@ -37,6 +37,10 @@ mpUi = new Ui_MainWindow(); mpUi->setupUi(this); +#if QT_VERSION >= 0x040200 + mpUi->changesTreeView->setAllColumnsShowFocus(true); +#endif + connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); @@ -105,4 +109,4 @@ mpModificationsModel->showModifications(summary.modifications()); else mpModificationsModel->showError(error); -} \ No newline at end of file +} Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-13 16:40:55 UTC (rev 41) @@ -72,7 +72,7 @@ { // Top headings if (isTypeColumn(section)) - return tr("Type"); + return tr("Status"); else if (isPathColumn(section)) return tr("File"); else Modified: trunk/src/dialogs/open.cpp =================================================================== --- trunk/src/dialogs/open.cpp 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/src/dialogs/open.cpp 2006-10-13 16:40:55 UTC (rev 41) @@ -60,8 +60,8 @@ void OpenDialog::openOther() { - QString other = QFileDialog::getExistingDirectory(this); - if (!other.isNull()) + QString other = QFileDialog::getExistingDirectory(this); + if (!other.isNull()) { // TODO: give an error if this is not a valid working copy QModelIndex index = mpPathsModel->addPath(other); Modified: trunk/ui/commit.ui =================================================================== --- trunk/ui/commit.ui 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/ui/commit.ui 2006-10-13 16:40:55 UTC (rev 41) @@ -71,9 +71,6 @@ <property name="itemsExpandable" > <bool>false</bool> </property> - <property name="allColumnsShowFocus" > - <bool>true</bool> - </property> </widget> </item> <item> Modified: trunk/ui/mainwindow.ui =================================================================== --- trunk/ui/mainwindow.ui 2006-10-06 23:27:23 UTC (rev 40) +++ trunk/ui/mainwindow.ui 2006-10-13 16:40:55 UTC (rev 41) @@ -162,9 +162,6 @@ <property name="itemsExpandable" > <bool>false</bool> </property> - <property name="allColumnsShowFocus" > - <bool>true</bool> - </property> </widget> </item> <item> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-23 23:40:01
|
Revision: 42 http://svn.sourceforge.net/grandmas-svn/?rev=42&view=rev Author: matthiasmiller Date: 2006-10-23 16:39:57 -0700 (Mon, 23 Oct 2006) Log Message: ----------- remove destination file path for copies Modified Paths: -------------- trunk/include/svn/modification.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-13 16:40:55 UTC (rev 41) +++ trunk/include/svn/modification.h 2006-10-23 23:39:57 UTC (rev 42) @@ -64,10 +64,10 @@ QString getFilePath() const { return mFilePath; } Type getType() const { return mType; } - // Only use for move and copy mods - QString getDestFilePath() const + // Only use for move mods + QString getMoveDestFilePath() const { - Q_ASSERT(mType == Type_Move || mType == Type_Copy); + Q_ASSERT(mType == Type_Move); return mDestFilePath; } Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-13 16:40:55 UTC (rev 41) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-23 23:39:57 UTC (rev 42) @@ -124,8 +124,8 @@ } else if (isPathColumn(rcIndex.column())) { - if (mod.getType() == Modification::Type_Move || mod.getType() == Modification::Type_Copy) - return mod.getFilePath() + "\n" + mod.getDestFilePath(); + if (mod.getType() == Modification::Type_Move) + return mod.getFilePath() + "\n" + mod.getMoveDestFilePath(); else return mod.getFilePath(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-23 23:52:25
|
Revision: 43 http://svn.sourceforge.net/grandmas-svn/?rev=43&view=rev Author: matthiasmiller Date: 2006-10-23 16:52:21 -0700 (Mon, 23 Oct 2006) Log Message: ----------- selections in commit dialog should be maintained even if the modification type changes Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/include/svn/modification.h trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-23 23:39:57 UTC (rev 42) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-23 23:52:21 UTC (rev 43) @@ -50,8 +50,11 @@ bool isCheckboxColumn(int col) const; bool isTypeColumn(int col) const; bool isPathColumn(int col) const; - + + struct DeclinedMod; + QString mError; - QList<Modification> mAllModifications, mDeclinedModifications; + QList<Modification> mAllModifications; + QList<DeclinedMod> mDeclinedModifications; bool mAllowSelections; }; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-23 23:39:57 UTC (rev 42) +++ trunk/include/svn/modification.h 2006-10-23 23:52:21 UTC (rev 43) @@ -46,21 +46,6 @@ Type_Conflicting, }; - bool operator==(const Modification& rcOther) const - { - if (mType != rcOther.mType) return false; - if (mFilePath != rcOther.mFilePath) return false; - if (mDestFilePath != rcOther.mDestFilePath) return false; - if (mOldRevision != rcOther.mOldRevision) return false; - if (mNewRevision != rcOther.mNewRevision) return false; - - return true; - } - bool operator!=(const Modification& rcOther) const - { - return !(*this == rcOther); - } - QString getFilePath() const { return mFilePath; } Type getType() const { return mType; } Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-23 23:39:57 UTC (rev 42) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-23 23:52:21 UTC (rev 43) @@ -24,6 +24,28 @@ #include <QSize> + +struct ModificationsModel::DeclinedMod +{ + QString mPath, mMoveDestPath; + + bool operator==(const DeclinedMod& other) + { + return mPath == other.mPath && mMoveDestPath == other.mMoveDestPath; + } + bool operator!=(const DeclinedMod& other) + { + return !(*this == other); + } + + static DeclinedMod fromSvnMod(const Modification& mod) + { + DeclinedMod declinedMod = { mod.getFilePath(), mod.getType() == Modification::Type_Move ? mod.getMoveDestFilePath() : QString() }; + return declinedMod; + } +}; + + ModificationsModel::ModificationsModel() : mAllowSelections(false) { } @@ -136,7 +158,7 @@ { if (isCheckboxColumn(rcIndex.column())) { - if (mDeclinedModifications.contains(mod)) + if (mDeclinedModifications.contains(DeclinedMod::fromSvnMod(mod))) return Qt::Unchecked; else return Qt::Checked; @@ -153,7 +175,7 @@ if (isCheckboxColumn(rcIndex.column()) && rcValue.canConvert(QVariant::Bool) && rcIndex.isValid() && rcIndex.row() < mAllModifications.size()) { - Modification mod = mAllModifications.at(rcIndex.row()); + DeclinedMod mod = DeclinedMod::fromSvnMod(mAllModifications.at(rcIndex.row())); if (rcValue.toBool()) { // remove from list of declined mods @@ -165,7 +187,7 @@ if (!mDeclinedModifications.contains(mod)) mDeclinedModifications.push_back(mod); } - + return true; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-24 00:08:13
|
Revision: 44 http://svn.sourceforge.net/grandmas-svn/?rev=44&view=rev Author: matthiasmiller Date: 2006-10-23 17:08:09 -0700 (Mon, 23 Oct 2006) Log Message: ----------- don't show unversioned modifications in the commit dialog Modified Paths: -------------- trunk/include/dialogs/modificationsmodel.h trunk/include/svn/modification.h trunk/src/dialogs/commit.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-23 23:52:21 UTC (rev 43) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-24 00:08:09 UTC (rev 44) @@ -30,7 +30,7 @@ virtual ~ModificationsModel(); void showError(QString error); - void showModifications(const QList<Modification>& rcModifications); + void showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods); virtual int columnCount(const QModelIndex &rcParent = QModelIndex()) const; virtual int rowCount(const QModelIndex& rcParent = QModelIndex()) const; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-23 23:52:21 UTC (rev 43) +++ trunk/include/svn/modification.h 2006-10-24 00:08:09 UTC (rev 44) @@ -46,6 +46,26 @@ Type_Conflicting, }; + static bool isVersionedType(Type type) + { + switch (type) + { + case Type_TextMod: + case Type_Add: + case Type_Delete: + case Type_Move: + case Type_PropMod: + case Type_Copy: + return true; + case Type_New: + case Type_Missing: + case Type_Conflicting: + return false; + default: + return false; + } + } + QString getFilePath() const { return mFilePath; } Type getType() const { return mType; } Modified: trunk/src/dialogs/commit.cpp =================================================================== --- trunk/src/dialogs/commit.cpp 2006-10-23 23:52:21 UTC (rev 43) +++ trunk/src/dialogs/commit.cpp 2006-10-24 00:08:09 UTC (rev 44) @@ -73,7 +73,7 @@ CommitSummary summary; QString error; if (summary.init(*mpContext, mPath, Revision(), error)) - mpModificationsModel->showModifications(summary.modifications()); + mpModificationsModel->showModifications(summary.modifications(), false); else mpModificationsModel->showError(error); Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-23 23:52:21 UTC (rev 43) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-24 00:08:09 UTC (rev 44) @@ -106,7 +106,7 @@ CommitSummary summary; QString error; if (summary.init(*mpContext, mPath, mDisplayedRevision, error)) - mpModificationsModel->showModifications(summary.modifications()); + mpModificationsModel->showModifications(summary.modifications(), true); else mpModificationsModel->showError(error); } Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-23 23:52:21 UTC (rev 43) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-24 00:08:09 UTC (rev 44) @@ -29,11 +29,11 @@ { QString mPath, mMoveDestPath; - bool operator==(const DeclinedMod& other) + bool operator==(const DeclinedMod& other) const { return mPath == other.mPath && mMoveDestPath == other.mMoveDestPath; } - bool operator!=(const DeclinedMod& other) + bool operator!=(const DeclinedMod& other) const { return !(*this == other); } @@ -62,10 +62,22 @@ emit layoutChanged(); } -void ModificationsModel::showModifications(const QList<Modification>& rcModifications) +void ModificationsModel::showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods) { mError = QString(); mAllModifications = rcModifications; + + // filter unversioned modifications + if (!includeUnversionedMods) + { + QMutableListIterator<Modification> i(mAllModifications); + while (i.hasNext()) + { + if (!Modification::isVersionedType(i.next().getType())) + i.remove(); + } + } + emit layoutChanged(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-25 03:04:51
|
Revision: 46 http://svn.sourceforge.net/grandmas-svn/?rev=46&view=rev Author: matthiasmiller Date: 2006-10-24 20:04:43 -0700 (Tue, 24 Oct 2006) Log Message: ----------- integrate diff into the UI Modified Paths: -------------- trunk/include/dialogs/mainwindow.h trunk/include/dialogs/modificationsmodel.h trunk/include/svn/file_access.h trunk/include/svn/modification.h trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/svn/file_access.cpp Modified: trunk/include/dialogs/mainwindow.h =================================================================== --- trunk/include/dialogs/mainwindow.h 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/include/dialogs/mainwindow.h 2006-10-25 03:04:43 UTC (rev 46) @@ -27,6 +27,7 @@ class ModificationsModel; class SvnOperationContext; class Ui_MainWindow; +class QModelIndex; class MainWindow: public QMainWindow { @@ -41,10 +42,13 @@ private slots: void commit(); + void diff(); + void diff(const QModelIndex& rcIndex); void move(); private: void reload(); + bool diffFiles(QString left, QString right); Ui_MainWindow* mpUi; SvnOperationContext* mpContext; Modified: trunk/include/dialogs/modificationsmodel.h =================================================================== --- trunk/include/dialogs/modificationsmodel.h 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/include/dialogs/modificationsmodel.h 2006-10-25 03:04:43 UTC (rev 46) @@ -32,6 +32,8 @@ void showError(QString error); void showModifications(const QList<Modification>& rcModifications, bool includeUnversionedMods); + Modification getModificationFromIndex(const QModelIndex& rcIndex) const; + virtual int columnCount(const QModelIndex &rcParent = QModelIndex()) const; virtual int rowCount(const QModelIndex& rcParent = QModelIndex()) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; Modified: trunk/include/svn/file_access.h =================================================================== --- trunk/include/svn/file_access.h 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/include/svn/file_access.h 2006-10-25 03:04:43 UTC (rev 46) @@ -27,6 +27,7 @@ class RepoFileAccess { public: + static QString getCanonicalPath(SvnOperationContext& rContext, QString workingCopy, QString filePath); static bool getFile(SvnOperationContext& rContext, QString fullRepoPath, Revision rev, QString& rCreatedFilePath, QString& rError); static bool getDiffFiles(SvnOperationContext& rContext, QString fullRepoPath, Revision leftRevision, Revision rightRevision, QString& rLeftFilePath, QString& rRightFilePath, QString& rError); }; Modified: trunk/include/svn/modification.h =================================================================== --- trunk/include/svn/modification.h 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/include/svn/modification.h 2006-10-25 03:04:43 UTC (rev 46) @@ -75,6 +75,9 @@ Q_ASSERT(mType == Type_Move); return mDestFilePath; } + + Revision getOldRevision() const { return mOldRevision; } + Revision getNewRevision() const { return mNewRevision; } private: friend class CommitSummary; Modified: trunk/src/dialogs/mainwindow.cpp =================================================================== --- trunk/src/dialogs/mainwindow.cpp 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/src/dialogs/mainwindow.cpp 2006-10-25 03:04:43 UTC (rev 46) @@ -24,9 +24,12 @@ #include "dialogs/modificationsmodel.h" #include "dialogs/move.h" #include "svn/commit_summary.h" +#include "svn/file_access.h" #include "svn/revision.h" #include "ui_mainwindow.h" +#include <QMessageBox> +#include <QProcess> #include <svn_client.h> @@ -42,6 +45,8 @@ #endif connect(mpUi->commitButton, SIGNAL(clicked()), this, SLOT(commit())); + connect(mpUi->changesTreeView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(diff(const QModelIndex&))); + connect(mpUi->diffButton, SIGNAL(clicked()), this, SLOT(diff())); connect(mpUi->moveButton, SIGNAL(clicked()), this, SLOT(move())); mpModificationsModel = new ModificationsModel(); @@ -95,6 +100,35 @@ dlg.exec(); } +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)) + { + 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::move() { MoveDialog dlg(this); @@ -110,3 +144,21 @@ else mpModificationsModel->showError(error); } + +bool MainWindow::diffFiles(QString left, QString right) +{ + // TODO: This should be configurable. + QString app; +#if defined(Q_WS_WIN) + app = "winmerge"; +#elif defined(Q_WS_MAC) + app = "opendiff"; +#else + return false; +#endif + + QStringList args; + args.push_back(left); + args.push_back(right); + return QProcess::execute(app, args) == 0; +} Modified: trunk/src/dialogs/modificationsmodel.cpp =================================================================== --- trunk/src/dialogs/modificationsmodel.cpp 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/src/dialogs/modificationsmodel.cpp 2006-10-25 03:04:43 UTC (rev 46) @@ -81,6 +81,23 @@ emit layoutChanged(); } +Modification ModificationsModel::getModificationFromIndex(const QModelIndex& rcIndex) const +{ + if (!rcIndex.isValid()) + { + GSVN_ASSERT(false); + return Modification(); + } + + if (rcIndex.row() < 0 || rcIndex.row() >= mAllModifications.count()) + { + GSVN_ASSERT(false); + return Modification(); + } + + return mAllModifications.at(rcIndex.row()); +} + int ModificationsModel::columnCount(const QModelIndex &rcParent) const { Q_UNUSED(rcParent); Modified: trunk/src/svn/file_access.cpp =================================================================== --- trunk/src/svn/file_access.cpp 2006-10-24 01:39:08 UTC (rev 45) +++ trunk/src/svn/file_access.cpp 2006-10-25 03:04:43 UTC (rev 46) @@ -22,6 +22,7 @@ #include "svn/operation.h" #include <svn_client.h> +#include <svn_path.h> #include <QDir> @@ -46,6 +47,12 @@ } } +QString RepoFileAccess::getCanonicalPath(SvnOperationContext& rContext, QString workingCopy, QString filePath) +{ + QString path = workingCopy + QDir::separator() + filePath; + return svn_path_canonicalize(path.toAscii(), rContext.getAprPool()); +} + bool RepoFileAccess::getFile(SvnOperationContext& rContext, QString fullRepoPath, Revision rev, QString& rCreatedFilePath, QString& rError) { if (!rev.isCommittedRevision()) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mat...@us...> - 2006-10-25 15:21:19
|
Revision: 50 http://svn.sourceforge.net/grandmas-svn/?rev=50&view=rev Author: matthiasmiller Date: 2006-10-25 08:20:18 -0700 (Wed, 25 Oct 2006) Log Message: ----------- set svn:eol-style to native Modified Paths: -------------- trunk/mingw-install.sh Property Changed: ---------------- trunk/COPYING trunk/Doxyfile trunk/grandmas_svn.kdevelop trunk/grandmas_svn.pro trunk/include/commandline.h trunk/include/debug.h trunk/include/dialogs/commit.h trunk/include/dialogs/core/base.h trunk/include/dialogs/mainwindow.h trunk/include/dialogs/modificationsmodel.h trunk/include/dialogs/move.h trunk/include/dialogs/open.h trunk/include/dialogs/util.h trunk/include/settings/userpaths.h trunk/include/svn/commit_summary.h trunk/include/svn/file_access.h trunk/include/svn/modification.h trunk/include/svn/operation.h trunk/include/svn/operation_internal.h trunk/include/svn/revision.h trunk/include/svn/server_access.h trunk/mingw-install.sh trunk/src/commandline.cpp trunk/src/debug.cpp trunk/src/dialogs/commit.cpp trunk/src/dialogs/core/base.cpp trunk/src/dialogs/mainwindow.cpp trunk/src/dialogs/modificationsmodel.cpp trunk/src/dialogs/move.cpp trunk/src/dialogs/open.cpp trunk/src/dialogs/util.cpp trunk/src/grandmas_svn.cpp trunk/src/grandmas_svn.h trunk/src/main.cpp trunk/src/settings/userpaths.cpp trunk/src/svn/commit_summary.cpp trunk/src/svn/file_access.cpp trunk/src/svn/operation.cpp trunk/src/svn/operation_internal.cpp trunk/src/svn/revision.cpp trunk/src/svn/server_access.cpp trunk/templates/cpp trunk/templates/h trunk/tests/commandlinetest.cpp trunk/tests/commandlinetest.h trunk/tests/svn_test.cpp trunk/tests/svn_test.h trunk/tests/tests.cpp trunk/tests/tests.h trunk/ui/commit.ui trunk/ui/grandmas-svn.qrc trunk/ui/icons/win32.rc trunk/ui/logo/logo-large.svg trunk/ui/logo/logo-small.svg trunk/ui/mainwindow.ui trunk/ui/move.ui trunk/ui/open.ui Property changes on: trunk/COPYING ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/Doxyfile ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/grandmas_svn.kdevelop ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/grandmas_svn.pro ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/commandline.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/debug.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/commit.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/core/base.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/mainwindow.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/modificationsmodel.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/move.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/open.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/dialogs/util.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/settings/userpaths.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/commit_summary.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/file_access.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/modification.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/operation.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/operation_internal.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/revision.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/include/svn/server_access.h ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/mingw-install.sh =================================================================== --- trunk/mingw-install.sh 2006-10-25 13:56:57 UTC (rev 49) +++ trunk/mingw-install.sh 2006-10-25 15:20:18 UTC (rev 50) @@ -1,5 +1,5 @@ -#!/bin/sh - +#!/bin/sh + # This script is used to create a MinGW build environment for the Subversion libraries. DOWNLOAD_DIR="/tmp/svn-mingw-installer" Property changes on: trunk/mingw-install.sh ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/commandline.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/debug.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/commit.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/core/base.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/mainwindow.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/modificationsmodel.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/move.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/open.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/dialogs/util.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/grandmas_svn.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/grandmas_svn.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/main.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/settings/userpaths.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/commit_summary.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/file_access.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/operation.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/operation_internal.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/revision.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/src/svn/server_access.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/templates/cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/templates/h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/commandlinetest.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/commandlinetest.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/svn_test.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/svn_test.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/tests.cpp ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/tests/tests.h ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/commit.ui ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/grandmas-svn.qrc ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/icons/win32.rc ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/logo/logo-large.svg ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/logo/logo-small.svg ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/mainwindow.ui ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/move.ui ___________________________________________________________________ Name: svn:eol-style + native Property changes on: trunk/ui/open.ui ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |