File indexing completed on 2024-04-28 05:42:05
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 "frontendtypes.h" 0028 #include "simple_logcb.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 { checkupdatethread, fillcachethread, checkmodifiedthread }; 0063 0064 explicit SvnActions(ItemDisplay *parent, bool processes_blocked = false); 0065 ~SvnActions() override; 0066 void reInitClient(); 0067 svn::ClientP svnclient(); 0068 void prepareUpdate(bool ask); 0069 0070 bool makeGet(const svn::Revision &start, 0071 const QString &what, 0072 const QString &target, 0073 const svn::Revision &peg = svn::Revision::UNDEFINED, 0074 QWidget *dlgparent = nullptr); 0075 0076 bool addItems(const svn::Paths &items, svn::Depth depth = svn::DepthEmpty); 0077 void checkAddItems(const QString &path, bool print_error_box = true); 0078 0079 bool makeDelete(const svn::Targets &target, bool keep_local = true, bool force = false); 0080 bool makeDelete(const QStringList &); 0081 void makeLock(const QStringList &, const QString &, bool); 0082 void makeUnlock(const QStringList &, bool); 0083 0084 bool makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec = false, bool all = true); 0085 bool makeStatus(const QString &what, svn::StatusEntries &dlist, const svn::Revision &where, bool rec, bool all, bool display_ignored, bool updates = false); 0086 bool makeStatus(const QString &what, 0087 svn::StatusEntries &dlist, 0088 const svn::Revision &where, 0089 svn::Depth depth, 0090 bool all, 0091 bool display_ignored, 0092 bool updates = false); 0093 0094 bool makeList(const QString &url, svn::DirEntries &dlist, const svn::Revision &where, svn::Depth depth = svn::DepthInfinity); 0095 0096 bool createModifiedCache(const QString &base); 0097 bool checkModifiedCache(const QString &path) const; 0098 bool checkConflictedCache(const QString &path) const; 0099 bool checkReposLockCache(const QString &path) const; 0100 bool checkReposLockCache(const QString &path, svn::StatusPtr &t) const; 0101 void addModifiedCache(const svn::StatusPtr &what); 0102 void deleteFromModifiedCache(const QString &what); 0103 0104 bool makeIgnoreEntry(SvnItem *which, bool unignore); 0105 bool makeIgnoreEntry(const svn::Path &item, const QStringList &ignorePattern, bool unignore); 0106 0107 bool isLockNeeded(SvnItem *which, const svn::Revision &where); 0108 QString searchProperty(QString &store, const QString &property, const QString &start, const svn::Revision &where, bool up = false); 0109 svn::PathPropertiesMapListPtr propList(const QString &which, const svn::Revision &where, bool cacheOnly); 0110 0111 bool changeProperties(const svn::PropertiesMap &setList, const QStringList &, const QString &path, const svn::Depth &depth = svn::DepthEmpty); 0112 0113 //! generate and displays a revision tree 0114 /*! 0115 * the parameter @a what must prepared, eg, if it comes from working copy 0116 * it must not contain a "file://" inside. 0117 * \param what item to display 0118 * \param rev Revision the item-path is available, intersting only when @a what is a repository item 0119 * \param startr startrevision for log 0120 * \param endr endrevision for log 0121 */ 0122 void 0123 makeTree(const QString &what, const svn::Revision &rev, const svn::Revision &startr = svn::Revision(1), const svn::Revision &endr = svn::Revision::HEAD); 0124 void makeLog(const svn::Revision &start, 0125 const svn::Revision &end, 0126 const svn::Revision &peg, 0127 const QString &, 0128 bool follow, 0129 bool list_files = false, 0130 int limit = 0); 0131 svn::LogEntriesMapPtr getLog(const svn::Revision &start, 0132 const svn::Revision &end, 0133 const svn::Revision &peg, 0134 const QString &, 0135 bool list_files, 0136 int limit, 0137 QWidget *parent = nullptr); 0138 svn::LogEntriesMapPtr getLog(const svn::Revision &start, 0139 const svn::Revision &end, 0140 const svn::Revision &peg, 0141 const QString &, 0142 bool list_files, 0143 int limit, 0144 bool follow_nodes, 0145 QWidget *parent = nullptr); 0146 bool getSingleLog(svn::LogEntry &, const svn::Revision &, const QString &, const svn::Revision &, QString &root) override; 0147 0148 void makeBlame(const svn::Revision &start, const svn::Revision &end, SvnItem *k); 0149 void makeBlame(const svn::Revision &start, 0150 const svn::Revision &end, 0151 const QString &, 0152 QWidget *parent = nullptr, 0153 const svn::Revision &peg = svn::Revision::UNDEFINED, 0154 SimpleLogCb *_acb = nullptr); 0155 void makeUpdate(const svn::Targets &targets, const svn::Revision &rev, svn::Depth depth); 0156 bool makeSwitch(const QUrl &rUrl, 0157 const QString &tPath, 0158 const svn::Revision &r, 0159 svn::Depth depth, 0160 const svn::Revision &peg, 0161 bool stickydepth, 0162 bool ignore_externals, 0163 bool allow_unversioned); 0164 bool makeSwitch(const QString &path, const QUrl &what); 0165 bool makeRelocate(const QUrl &fUrl, const QUrl &tUrl, const QString &path, bool recursive, bool ignore_externals); 0166 bool makeCheckout(const QString &, 0167 const QString &, 0168 const svn::Revision &, 0169 const svn::Revision &, 0170 svn::Depth, 0171 bool isExport, 0172 bool openit, 0173 bool ignore_externals, 0174 bool overwrite, 0175 bool ignoreKeywords, 0176 QWidget *p); 0177 void makeInfo(const SvnItemList &lst, const svn::Revision &, const svn::Revision &, bool recursive = true); 0178 void makeInfo(const QStringList &lst, const svn::Revision &, const svn::Revision &, bool recursive = true); 0179 bool makeCommit(const svn::Targets &); 0180 void CheckoutExport(const QUrl &what, bool _exp, bool urlisTarget = false); 0181 0182 QString getInfo(const SvnItemList &lst, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all = true); 0183 QString getInfo(const QString &_what, const svn::Revision &rev, const svn::Revision &peg, bool recursive, bool all = true); 0184 QString getInfo(const svn::InfoEntries &entries, const QString &what, bool all); 0185 0186 QString makeMkdir(const QString &); 0187 bool makeMkdir(const svn::Targets &which, const QString &logMessage); 0188 bool isLocalWorkingCopy(const QString &path, QUrl &repoUrl); 0189 bool createUpdateCache(const QString &what); 0190 bool checkUpdateCache(const QString &path) const; 0191 bool isUpdated(const QString &path) const; 0192 bool getUpdated(const QString &path, svn::StatusPtr &d) const; 0193 void clearUpdateCache(); 0194 void removeFromUpdateCache(const QStringList &what, bool exact_only); 0195 void stopCheckModifiedThread(); 0196 void stopCheckUpdateThread(); 0197 void startFillCache(const QString &path, bool startup = false); 0198 void stopMain(); 0199 void killallThreads(); 0200 0201 bool checkUpdatesRunning(); 0202 void getaddedItems(const QString &path, svn::StatusEntries &target); 0203 0204 bool makeCopy(const QString &, const QString &, const svn::Revision &rev); 0205 bool makeCopy(const QList<QUrl> &, const QString &, const svn::Revision &rev); 0206 0207 bool makeMove(const QString &, const QString &); 0208 bool makeMove(const QList<QUrl> &, const QString &); 0209 0210 virtual bool makeCleanup(const QString &); 0211 0212 bool get(const QString &what, const QString &to, const svn::Revision &rev, const svn::Revision &peg, QWidget *p); 0213 bool singleInfo(const QString &what, const svn::Revision &rev, svn::InfoEntry &target, const svn::Revision &_peg = svn::Revision::UNDEFINED); 0214 bool hasMergeInfo(const QString &originpath); 0215 0216 void setContextData(const QString &, const QString &); 0217 void clearContextData(); 0218 QString getContextData(const QString &) const; 0219 0220 bool threadRunning(ThreadType which) const; 0221 0222 bool doNetworking(); 0223 virtual void doCommit(const SvnItemList &); 0224 virtual void editProperties(SvnItem *k, const svn::Revision &rev); 0225 0226 protected: 0227 QScopedPointer<SvnActionsData> m_Data; 0228 0229 void showInfo(const QStringList &infoList); 0230 void CheckoutExportCurrent(bool _exp); 0231 void makeAdd(bool rec); 0232 CheckModifiedThread *m_CThread, *m_UThread; 0233 FillCacheThread *m_FCThread; 0234 void makeDiffinternal(const QString &, 0235 const svn::Revision &, 0236 const QString &, 0237 const svn::Revision &, 0238 QWidget *, 0239 const svn::Revision &peg = svn::Revision::UNDEFINED); 0240 void makeDiffExternal(const QString &p1, 0241 const svn::Revision &start, 0242 const QString &p2, 0243 const svn::Revision &end, 0244 const svn::Revision &_peg, 0245 bool isDir, 0246 QWidget *p, 0247 bool rec = true); 0248 0249 public Q_SLOTS: 0250 virtual void dispDiff(const QByteArray &); 0251 virtual void slotNotifyMessage(const QString &); 0252 virtual void slotUpdateHeadRec(); 0253 virtual void slotUpdateTo(); 0254 virtual void slotAdd(); 0255 virtual void slotAddRec(); 0256 virtual void slotCheckoutCurrent(); 0257 virtual void slotExportCurrent(); 0258 virtual void slotCheckout(); 0259 virtual void slotExport(); 0260 virtual void slotRevert(); 0261 virtual void slotRevertItems(const QStringList &); 0262 virtual void slotSwitch(); 0263 virtual void slotResolved(const QString &); 0264 virtual void slotResolve(const QString &); 0265 virtual void makeDiff(const QString &, const svn::Revision &, const svn::Revision &, const svn::Revision &_peg, bool isDir); 0266 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &); 0267 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, const svn::Revision &, bool, QWidget *p); 0268 virtual void makeDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *); 0269 virtual void makeNorecDiff(const QString &, const svn::Revision &, const QString &, const svn::Revision &, QWidget *); 0270 virtual void slotImport(const QString &, const QUrl &, const QString &, svn::Depth, bool noIgnore, bool noUnknown); 0271 virtual void slotMergeWcRevisions(const QString &, const svn::Revision &, const svn::Revision &, bool, bool, bool, bool, bool); 0272 virtual void slotMerge(const QString &, 0273 const QString &, 0274 const QString &, 0275 const svn::Revision &, 0276 const svn::Revision &, 0277 const svn::Revision &, 0278 bool, 0279 bool, 0280 bool, 0281 bool, 0282 bool, 0283 bool, 0284 bool); 0285 virtual void slotMergeExternal(const QString &src1, 0286 const QString &src2, 0287 const QString &target, 0288 const svn::Revision &rev1, 0289 const svn::Revision &rev2, 0290 const svn::Revision &_peg, 0291 bool); 0292 virtual void slotExtraLogMsg(const QString &); 0293 virtual void slotMakeCat(const svn::Revision &start, const QString &what, const QString &disp, const svn::Revision &peg, QWidget *dlgparent); 0294 0295 virtual void slotCancel(bool); 0296 virtual void stopFillCache(); 0297 0298 Q_SIGNALS: 0299 void clientException(const QString &); 0300 void sendNotify(const QString &); 0301 void reinitItem(SvnItem *); 0302 void sigRefreshAll(); 0303 void sigThreadsChanged(); 0304 void sigRefreshCurrent(SvnItem *); 0305 void sigExtraLogMsg(const QString &); 0306 void sigGotourl(const QUrl &); 0307 void sigCacheStatus(qlonglong, qlonglong); 0308 void sigCacheDataChanged(); 0309 void sigItemsReverted(const QStringList &); 0310 void sigExtraStatusMessage(const QString &); 0311 void sigRefreshItem(const QString &path); 0312 0313 protected Q_SLOTS: 0314 virtual void checkModifiedThread(); 0315 virtual void checkUpdateThread(); 0316 virtual void slotProcessDataRead(const QByteArray &, WatchedProcess *); 0317 }; 0318 0319 #endif