File indexing completed on 2024-05-12 17:16:17
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 #ifndef SVNACTIONS_H 0021 #define SVNACTIONS_H 0022 0023 #include "svnqt/client.h" 0024 #include "svnqt/revision.h" 0025 #include "svnqt/svnqttypes.h" 0026 0027 #include "simple_logcb.h" 0028 #include "frontendtypes.h" 0029 0030 #include <QObject> 0031 #include <QScopedPointer> 0032 #include <QStringList> 0033 0034 class ItemDisplay; 0035 class SvnItem; 0036 class QDialog; 0037 class CContextListener; 0038 class SvnActionsData; 0039 class CheckModifiedThread; 0040 class CheckUpdatesThread; 0041 class FillCacheThread; 0042 class WatchedProcess; 0043 0044 namespace svn 0045 { 0046 class LogEntry; 0047 class InfoEntry; 0048 } 0049 0050 namespace KIO 0051 { 0052 class Job; 0053 } 0054 0055 /** 0056 @author Rajko Albrecht 0057 */ 0058 class SvnActions : public QObject, public SimpleLogCb 0059 { 0060 Q_OBJECT 0061 public: 0062 enum ThreadType { 0063 checkupdatethread, 0064 fillcachethread, 0065 checkmodifiedthread 0066 }; 0067 0068 explicit SvnActions(ItemDisplay *parent, bool processes_blocked = false); 0069 ~SvnActions(); 0070 void reInitClient(); 0071 svn::ClientP svnclient(); 0072 void prepareUpdate(bool ask); 0073 0074 bool makeGet(const svn::Revision &start, const QString &what, const QString &target, 0075 const svn::Revision &peg = svn::Revision::UNDEFINED, QWidget *dlgparent = nullptr); 0076 0077 bool addItems(const svn::Paths &items, svn::Depth depth = svn::DepthEmpty); 0078 void checkAddItems(const QString &path, bool print_error_box = true); 0079 0080 bool makeDelete(const svn::Targets &target, bool keep_local = true, bool force = false); 0081 bool makeDelete(const QStringList &); 0082 void makeLock(const QStringList &, const QString &, bool); 0083 void makeUnlock(const QStringList &, bool); 0084 0085 bool makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec = false, bool all = true); 0086 bool makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec, bool all, bool display_ignored, bool updates = false); 0087 bool makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, svn::Depth depth, bool all, bool display_ignored, bool updates = false); 0088 0089 bool makeList(const QString &url, svn::DirEntries &dlist, const svn::Revision &where, svn::Depth depth = svn::DepthInfinity); 0090 0091 bool createModifiedCache(const QString &base); 0092 bool checkModifiedCache(const QString &path) const; 0093 bool checkConflictedCache(const QString &path) const; 0094 bool checkReposLockCache(const QString &path) const; 0095 bool checkReposLockCache(const QString &path, svn::StatusPtr &t) const; 0096 void addModifiedCache(const svn::StatusPtr &what); 0097 void deleteFromModifiedCache(const QString &what); 0098 0099 bool makeIgnoreEntry(SvnItem *which, bool unignore); 0100 bool makeIgnoreEntry(const svn::Path &item, const QStringList &ignorePattern, bool unignore); 0101 0102 bool isLockNeeded(SvnItem *which, const svn::Revision &where); 0103 QString searchProperty(QString &store, const QString &property, const QString &start, const svn::Revision &where, bool up = false); 0104 svn::PathPropertiesMapListPtr propList(const QString &which, const svn::Revision &where, bool cacheOnly); 0105 0106 bool changeProperties(const svn::PropertiesMap &setList, const QStringList &, const QString &path, const svn::Depth &depth = svn::DepthEmpty); 0107 0108 //! generate and displays a revision tree 0109 /*! 0110 * the parameter @a what must prepared, eg, if it comes from working copy 0111 * it must not contain a "file://" inside. 0112 * \param what item to display 0113 * \param rev Revision the item-path is available, intersting only when @a what is a repository item 0114 * \param startr startrevision for log 0115 * \param endr endrevision for log 0116 */ 0117 void makeTree(const QString &what, const svn::Revision &rev, 0118 const svn::Revision &startr = svn::Revision(1), 0119 const svn::Revision &endr = svn::Revision::HEAD); 0120 void makeLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &, bool follow, bool list_files = false, int limit = 0); 0121 svn::LogEntriesMapPtr getLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &, bool list_files, int limit, QWidget *parent = nullptr); 0122 svn::LogEntriesMapPtr getLog(const svn::Revision &start, const svn::Revision &end, const svn::Revision &peg, const QString &, bool list_files, int limit, bool follow_nodes, QWidget *parent = nullptr); 0123 bool getSingleLog(svn::LogEntry &, const svn::Revision &, const QString &, const svn::Revision &, QString &root) override; 0124 0125 void makeBlame(const svn::Revision &start, const svn::Revision &end, SvnItem *k); 0126 void makeBlame(const svn::Revision &start, const svn::Revision &end, const QString &, QWidget *parent = nullptr, const svn::Revision &peg = svn::Revision::UNDEFINED, SimpleLogCb *_acb = nullptr); 0127 void makeUpdate(const svn::Targets &targets, const svn::Revision &rev, svn::Depth depth); 0128 bool makeSwitch(const QUrl &rUrl, const QString &tPath, const svn::Revision &r, svn::Depth depth, const svn::Revision &peg, bool stickydepth, bool ignore_externals, bool allow_unversioned); 0129 bool makeSwitch(const QString &path, const QUrl &what); 0130 bool makeRelocate(const QUrl &fUrl, const QUrl &tUrl, const QString &path, bool recursive, bool ignore_externals); 0131 bool makeCheckout(const QString &, const QString &, const svn::Revision &, const svn::Revision &, svn::Depth, bool isExport, bool openit, bool ignore_externals, bool overwrite, bool ignoreKeywords, QWidget *p); 0132 void makeInfo(const SvnItemList &lst, const svn::Revision &, const svn::Revision &, bool recursive = true); 0133 void makeInfo(const QStringList &lst, const svn::Revision &, const svn::Revision &, bool recursive = true); 0134 bool makeCommit(const svn::Targets &); 0135 void CheckoutExport(const QUrl &what, bool _exp, bool urlisTarget = false); 0136 0137 QString getInfo(const SvnItemList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all = true); 0138 QString getInfo(const QString &_what, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all = true); 0139 QString getInfo(const svn::InfoEntries &entries, const QString &what, bool all); 0140 0141 0142 QString makeMkdir(const QString &); 0143 bool makeMkdir(const svn::Targets &which, const QString &logMessage); 0144 bool isLocalWorkingCopy(const QString &path, QUrl &repoUrl); 0145 bool createUpdateCache(const QString &what); 0146 bool checkUpdateCache(const QString &path)const; 0147 bool isUpdated(const QString &path)const; 0148 bool getUpdated(const QString &path, svn::StatusPtr &d)const; 0149 void clearUpdateCache(); 0150 void removeFromUpdateCache(const QStringList &what, bool exact_only); 0151 void stopCheckModifiedThread(); 0152 void stopCheckUpdateThread(); 0153 void startFillCache(const QString &path, bool startup = false); 0154 void stopMain(); 0155 void killallThreads(); 0156 0157 bool checkUpdatesRunning(); 0158 void getaddedItems(const QString &path, svn::StatusEntries &target); 0159 0160 bool makeCopy(const QString &, const QString &, const svn::Revision &rev); 0161 bool makeCopy(const QList<QUrl> &, const QString &, const svn::Revision &rev); 0162 0163 bool makeMove(const QString &, const QString &); 0164 bool makeMove(const QList<QUrl> &, const QString &); 0165 0166 virtual bool makeCleanup(const QString &); 0167 0168 bool get(const QString &what, const QString &to, const svn::Revision &rev, const svn::Revision &peg, QWidget *p); 0169 bool singleInfo(const QString &what, const svn::Revision &rev, svn::InfoEntry &target, const svn::Revision &_peg = svn::Revision::UNDEFINED); 0170 bool hasMergeInfo(const QString &originpath); 0171 0172 void setContextData(const QString &, const QString &); 0173 void clearContextData(); 0174 QString getContextData(const QString &)const; 0175 0176 bool threadRunning(ThreadType which) const; 0177 0178 bool doNetworking(); 0179 virtual void doCommit(const SvnItemList &); 0180 virtual void editProperties(SvnItem *k, const svn::Revision &rev); 0181 0182 protected: 0183 QScopedPointer<SvnActionsData> m_Data; 0184 0185 void showInfo(const QStringList &infoList); 0186 void CheckoutExportCurrent(bool _exp); 0187 void makeAdd(bool rec); 0188 CheckModifiedThread *m_CThread, *m_UThread; 0189 FillCacheThread *m_FCThread; 0190 void makeDiffinternal(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *, const svn::Revision &peg = svn::Revision::UNDEFINED); 0191 void makeDiffExternal(const QString &p1, const svn::Revision &start, const QString &p2, const svn::Revision &end, const svn::Revision &_peg, bool isDir, QWidget *p, bool rec = true); 0192 0193 public Q_SLOTS: 0194 virtual void dispDiff(const QByteArray &); 0195 virtual void slotNotifyMessage(const QString &); 0196 virtual void slotUpdateHeadRec(); 0197 virtual void slotUpdateTo(); 0198 virtual void slotAdd(); 0199 virtual void slotAddRec(); 0200 virtual void slotCheckoutCurrent(); 0201 virtual void slotExportCurrent(); 0202 virtual void slotCheckout(); 0203 virtual void slotExport(); 0204 virtual void slotRevert(); 0205 virtual void slotRevertItems(const QStringList &); 0206 virtual void slotSwitch(); 0207 virtual void slotResolved(const QString &); 0208 virtual void slotResolve(const QString &); 0209 virtual void makeDiff(const QString &, const svn::Revision &, const svn::Revision &, const svn::Revision &_peg, bool isDir); 0210 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &); 0211 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, const svn::Revision &, bool, QWidget *p); 0212 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *); 0213 virtual void makeNorecDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *); 0214 virtual void slotImport(const QString &, const QUrl &, const QString &, svn::Depth, bool noIgnore, bool noUnknown); 0215 virtual void slotMergeWcRevisions(const QString &, const svn::Revision &, const svn::Revision &, bool, bool, bool, bool, bool); 0216 virtual void slotMerge(const QString &, const QString &, const QString &, 0217 const svn::Revision &, const svn::Revision &, const svn::Revision &, 0218 bool, bool, bool, bool, bool, bool, bool); 0219 virtual void slotMergeExternal(const QString &src1, const QString &src2, const QString &target, 0220 const svn::Revision &rev1, const svn::Revision &rev2, const svn::Revision &_peg, bool); 0221 virtual void slotExtraLogMsg(const QString &); 0222 virtual void slotMakeCat(const svn::Revision &start, const QString &what, const QString &disp, const svn::Revision &peg, QWidget *dlgparent); 0223 0224 virtual void slotCancel(bool); 0225 virtual void stopFillCache(); 0226 0227 Q_SIGNALS: 0228 void clientException(const QString &); 0229 void sendNotify(const QString &); 0230 void reinitItem(SvnItem *); 0231 void sigRefreshAll(); 0232 void sigThreadsChanged(); 0233 void sigRefreshCurrent(SvnItem *); 0234 void sigExtraLogMsg(const QString &); 0235 void sigGotourl(const QUrl &); 0236 void sigCacheStatus(qlonglong, qlonglong); 0237 void sigCacheDataChanged(); 0238 void sigItemsReverted(const QStringList &); 0239 void sigExtraStatusMessage(const QString &); 0240 void sigRefreshItem(const QString &path); 0241 0242 protected Q_SLOTS: 0243 virtual void checkModifiedThread(); 0244 virtual void checkUpdateThread(); 0245 virtual void slotProcessDataRead(const QByteArray &, WatchedProcess *); 0246 }; 0247 0248 #endif