#ifndef SVN_H #define SVN_H #include #include #include //See http://svnbook.red-bean.com/nightly/fr/svn.ref.html for command line help class Svn : public QObject { Q_OBJECT /// User name property. Used only if useDefaultCredential is disabled. Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged) /// Password property. Used only if useDefaultCredential is disabled. Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged) /// Use default credential means that if svn is already used on the computer and credentials are already registered /// there is no need to provide credentials again. Q_PROPERTY(bool useDefaultCredential READ useDefaultCredential WRITE setUseDefaultCredential NOTIFY useDefaultCredentialChanged) /// Path to svn binary. Q_PROPERTY(QString svnPath READ svnPath WRITE setSvnPath NOTIFY svnPathChanged) Q_PROPERTY(QStringList currentPaths READ currentPaths WRITE setCurrentPaths NOTIFY currentPathChanged) Q_PROPERTY(bool isRunning READ isRunning NOTIFY isRunningChanged) Q_PROPERTY(bool verbose READ verbose WRITE setVerbose NOTIFY verboseChanged) QString m_password; QString m_userName; QFileInfo m_svnPath; bool m_useDefaultCredential; QStringList m_currentPaths; bool m_verbose; public: explicit Svn(QObject *parent = 0); explicit Svn(const QString &svnPath, QObject *parent = 0); explicit Svn(const QString &svnPath, const QString &userName, const QString &password, QObject *parent = 0); explicit Svn(const QString &userName, const QString &password, QObject *parent = 0); ~Svn(); Q_INVOKABLE QString password() const; Q_INVOKABLE QString userName() const; Q_INVOKABLE bool useDefaultCredential() const; Q_INVOKABLE QString svnPath() const; // Q_INVOKABLE int timeout() const; QStringList currentPaths() const; bool isRunning() const; bool verbose() const; protected: bool checkIsRunning(); bool checkSvnPath(); void init(); bool process(const QString &cmd, const QStringList &paths); QString getPath(const QStringList &paths); signals: void passwordChanged(const QString &password); void userNameChanged(const QString &userName); void useDefaultCredentialChanged(bool enable); void svnPathChanged(const QString &arg); void currentPathChanged(const QStringList ¤tPaths); void started(); void finished(bool status); void error(const QString &throwError); void message(const QString &message); void isRunningChanged(bool arg); void verboseChanged(bool arg); public slots: void setPassword(const QString &password); void setUserName(const QString &userName); void setUseDefaultCredential(bool enable); void setSvnPath(const QString &path); // void setTimeout(int timeout); /// /// \brief getLock /// \param path /// bool lock(const QStringList &paths = QStringList(), const QString &logMessage = QString(), bool force = false); /// /// \brief releaseLock /// \param path /// bool unlock(const QStringList &paths = QStringList()); /// /// \brief commit /// \param logMessage /// \param path /// bool commit(const QString &logMessage, const QStringList &paths = QStringList()); /// /// \brief checkout Extract a working copy from a repository /// \param svnUrls Url(s) of repository(ies) to checkout /// \param path Path of the folder where to extract the repository(ies). /// If empty, the current path (see currentPath() ) will be used. /// bool checkout(const QStringList &svnUrls, const QStringList &paths = QStringList()); bool add(const QStringList &paths, bool recursive = false, bool emptyFolder = false); bool info(const QStringList &paths); /// /// \brief reverse /// \param path /// bool revert(const QStringList &paths = QStringList()); /// /// \brief update /// \param path /// bool update(const QStringList &paths = QStringList(), int revision = -1); /// /// \brief cleanUp Clean recursively the working copy /// \param path Path to clean. If empty, the current path /// (see currentPath() ) will be used. /// bool cleanUp(const QStringList &paths = QStringList()); /// /// \brief login /// \param user /// \param password /// bool log(const QStringList &paths); /// /// \brief setCurrentPath /// \param currentPath /// void setCurrentPaths(const QStringList ¤tPaths); void setVerbose(bool verbose); private slots: void processError(QProcess::ProcessError e); void finished(int exitCode, QProcess::ExitStatus exitStatus); void processStateChanged(QProcess::ProcessState state); void processReadyReadStandardError(); void processReadyReadStandardOutput(); bool throwError(const QString &e); private: QProcess svnProcess; QString m_lastError; int m_timeout; QProcess::ProcessState m_svnProcessState; QStringList m_errorsDuringProcess; QStringList m_outputDuringProcess; }; #endif // SVN_H