File indexing completed on 2024-05-05 04:39:01

0001 /*
0002     SPDX-FileCopyrightText: 2013-2014 Maciej Poleski
0003 
0004     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005 */
0006 
0007 #ifndef BAZAAR_BAZAARUTILS_H
0008 #define BAZAAR_BAZAARUTILS_H
0009 
0010 #include <QDir>
0011 #include <QUrl>
0012 
0013 #include <vcs/vcsevent.h>
0014 #include <vcs/interfaces/ibasicversioncontrol.h>
0015 
0016 namespace KDevelop
0017 {
0018 class VcsRevision;
0019 class VcsStatusInfo;
0020 class VcsEvent;
0021 }
0022 
0023 namespace BazaarUtils
0024 {
0025 
0026 /**
0027  * Converts @p url to QDir instance assuming file is local
0028  */
0029 QDir toQDir(const QUrl& url);
0030 
0031 /**
0032  * @return working copy location of working copy which contains @p path.
0033  */
0034 QDir workingCopy(const QUrl& path);
0035 
0036 /**
0037  * Translate VcsRevision into Revision Identifier accepted by Bazaar. This
0038  * function is designed for translating single revision ids.
0039  */
0040 QString getRevisionSpec(const KDevelop::VcsRevision& revision);
0041 
0042 /**
0043  * Translate VcsRevision into revision range option accepted by Bazaar. This
0044  * function is designed for translating end point into range from begin to
0045  * given end point.
0046  */
0047 QString getRevisionSpecRange(const KDevelop::VcsRevision& end);
0048 
0049 /**
0050  * Translate VcsRevision range into revision range option accepted by Bazaar.
0051  * This function translates VcsRevision range into best possible approximation
0052  * of revision range accepted by Bazaar.
0053  */
0054 QString getRevisionSpecRange(const KDevelop::VcsRevision& begin,
0055                              const KDevelop::VcsRevision& end);
0056 
0057 /**
0058  * Checks if @p dirPath is valid working directory location.
0059  * @return true if @p dirPath is valid working directory location, false
0060  * otherwise.
0061  */
0062 bool isValidDirectory(const QUrl& dirPath);
0063 
0064 /**
0065  * Parses single status info line to KDevelop::VcsStatusInfo.
0066  */
0067 KDevelop::VcsStatusInfo parseVcsStatusInfoLine(const QString& line);
0068 
0069 /**
0070  * Concatenates path of working copy location and relative file in working copy
0071  * location (@p pathInWorkingCopy) and returns absolute path of this file.
0072  * @return Absolute path of file designated by @p pathInWorkingCopy relative to
0073  * @p workingCopy.
0074  */
0075 QString concatenatePath(const QDir& workingCopy, const QUrl& pathInWorkingCopy);
0076 
0077 /**
0078  * Parses information about single commit from @p output (which is single part
0079  * of @c bzr @c log output).
0080  * @return Information about single commit in instance of
0081  * KDevelop::VcsEvent class.
0082  */
0083 KDevelop::VcsEvent parseBzrLogPart(const QString& output);
0084 
0085 /**
0086  * Parses information about single action on single file in some
0087  * @c bzr @c log output.
0088  */
0089 KDevelop::VcsItemEvent::Action parseActionDescription(const QString& action);
0090 
0091 /**
0092  * Some methods in interface provides @p recursion parameter. In general
0093  * Bazaar don't support this (only part of interface has native recursion
0094  * handling support). This function removes directories from list if
0095  * we are in NonRecursive mode (as directory for self is not versioned).
0096  */
0097 QList<QUrl> handleRecursion(const QList<QUrl>& listOfUrls, KDevelop::IBasicVersionControl::RecursionMode recursion);
0098 
0099 }
0100 
0101 
0102 #endif // BAZAAR_BAZAARUTILS_H