tahoma2d/toonz/sources/toonz/versioncontrol.h

193 lines
5.6 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef VERSION_CONTROL_H
#define VERSION_CONTROL_H
#include <QObject>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QProcess>
#include "versioncontrolxmlreader.h"
// Forward Declarations
class TXshSimpleLevel;
class ToonzScene;
class TLevelSet;
//-----------------------------------------------------------------------------
class VersionControlThread final : public QThread {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_abort;
bool m_restart;
bool m_getStatus;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_readOutputOnDone;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString m_workingDir;
QString m_binary;
QStringList m_args;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QWaitCondition m_condition;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QProcess *m_process;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
QMutex m_mutex;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
VersionControlThread(QObject *parent = 0);
~VersionControlThread();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void executeCommand(const QString &workingDir, const QString &binary,
const QStringList &args, bool readOutputOnDone = true);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void getSVNStatus(const QString &path, bool showUpdates = false,
bool nonRecursive = false, bool depthInfinity = false);
void getSVNStatus(const QString &path, const QStringList &files,
bool showUpdates = false, bool nonRecursive = false,
bool depthInfinity = false);
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void run() override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onStandardOutputReady();
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void error(const QString &errorString);
void done(const QString &response);
void outputRetrieved(const QString &text);
void statusRetrieved(const QString &xmlResponse);
2016-03-19 06:57:51 +13:00
};
//-----------------------------------------------------------------------------
class VersionControlManager final : public QObject {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
VersionControlThread m_thread;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
VersionControlManager();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
//! For set Frame Range
ToonzScene *m_scene;
TLevelSet *m_levelSet;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_isRunning;
bool m_deleteLater;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
static VersionControlManager *instance();
void setFrameRange(TLevelSet *levelSet, bool deleteLater = false);
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onFrameRangeDone(const QString &text);
void onError(const QString &text);
2016-03-19 06:57:51 +13:00
};
//-----------------------------------------------------------------------------
class VersionControl final : public QObject {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString m_userName;
QString m_password;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
VersionControl();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QList<SVNRepository> m_repositories;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString m_executablePath;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
static VersionControl *instance();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// Read Version Control repositories from config files
void init();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// Check version control version and config file data, return false if there
// is some setup issue
bool testSetup();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool isFolderUnderVersionControl(const QString &folderPath);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setUserName(const QString &userName) { m_userName = userName; }
QString getUserName() const { return m_userName; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setPassword(const QString &password) { m_password = password; }
QString getPassword() const { return m_password; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// filesToCommit must have relative path to the working dir
// Convert QStringList to TFilePath
void commit(QWidget *parent, const QString &workingDir,
const QStringList &filesToCommit, bool folderOnly,
int sceneIconAdded = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void update(QWidget *parent, const QString &workingDir,
const QStringList &filesToUpdate, int sceneIconsCounts,
bool folderOnly = true, bool updateToRevision = false,
bool nonRecursive = false);
void updateAndLock(QWidget *parent, const QString &workingDir,
const QStringList &files, int workingRevision,
int sceneIconAdded);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void revert(QWidget *parent, const QString &workingDir,
const QStringList &filesToRevert, bool folderOnly,
int sceneIconAdded = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void lock(QWidget *parent, const QString &workingDir,
const QStringList &filesToLock, int sceneIconAdded);
void unlock(QWidget *parent, const QString &workingDir,
const QStringList &filesToUnlock, int sceneIconAdded);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void lockFrameRange(QWidget *parent, const QString &workingDir,
const QString &file, int frameCount);
void lockFrameRange(QWidget *parent, const QString &workingDir,
const QStringList &files);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void unlockFrameRange(QWidget *parent, const QString &workingDir,
const QString &file);
void unlockFrameRange(QWidget *parent, const QString &workingDir,
const QStringList &files);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void showFrameRangeLockInfo(QWidget *parent, const QString &workingDir,
const QString &file);
void showFrameRangeLockInfo(QWidget *parent, const QString &workingDir,
const QStringList &files);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void commitFrameRange(QWidget *parent, const QString &workingDir,
const QString &file);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void revertFrameRange(QWidget *parent, const QString &workingDir,
const QString &file, const QString &tempFileName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void deleteFiles(QWidget *parent, const QString &workingDir,
const QStringList &filesToDelete, int sceneIconAdded = 0);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void deleteFolder(QWidget *parent, const QString &workingDir,
const QString &folderName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void cleanupFolder(QWidget *parent, const QString &workingDir);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void purgeFolder(QWidget *parent, const QString &workingDir);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// Utility methods
QStringList getSceneContents(const QString &wokingDir,
const QString &sceneFileName);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QStringList getCurrentSceneContents() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QList<SVNRepository> getRepositories() const { return m_repositories; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString getExecutablePath() const { return m_executablePath; }
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void commandDone(const QStringList &files);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // VERSION_CONTROL_H