Commit 2a000a38 authored by Evgeniy Ivanov's avatar Evgeniy Ivanov
Browse files

DVCS is a part of libkdevplatformvcs now;

Added some very basic branching support (to DVCSplugin and Git);
Fixed executor bugs (repository should be a directory, but not a file);
Fixed Git and Bzr tests;
Some minor changes in the idvcsexecutor;
Other minor changes and refacoting;
parent aa5ebb3c
......@@ -14,27 +14,10 @@ include_directories( ${KDE4_INCLUDES}
########### next target ###############
set(kdevgit_PART_SRCS
${CMAKE_SOURCE_DIR}/vcs/dvcs/dvcsjob.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/commitdialog.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/dvcsplugin.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/dvcsmainview.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/dvcsgenericoutputview.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/importdialog.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/importmetadatawidget.cpp
${CMAKE_SOURCE_DIR}/vcs/dvcs/logview.cpp
gitplugin.cpp
gitexecutor.cpp
)
set(kdevgit_PART_UI
${CMAKE_SOURCE_DIR}/vcs/dvcs/commitdialog.ui
${CMAKE_SOURCE_DIR}/vcs/dvcs/cvsgenericoutputview.ui
${CMAKE_SOURCE_DIR}/vcs/dvcs/cvsmainview.ui
${CMAKE_SOURCE_DIR}/vcs/dvcs/importmetadatawidget.ui
${CMAKE_SOURCE_DIR}/vcs/dvcs/logview.ui
)
kde4_add_ui_files(kdevgit_PART_SRCS ${kdevgit_PART_UI})
kde4_add_plugin(kdevgit ${kdevgit_PART_SRCS})
......
......@@ -24,16 +24,12 @@
#include "gitexecutor.h"
#include <QFileInfo>
#include <QDir>
#include <QFileInfo>
#include <QString>
#include <QDateTime>
#include <KLocale>
#include <KUrl>
#include <KMessageBox>
#include <kshell.h>
#include <KShell>
#include <KDebug>
#include <dvcsjob.h>
......@@ -60,14 +56,15 @@ bool GitExecutor::isValidDirectory(const KUrl & dirPath)
DVCSjob* job = new DVCSjob(vcsplugin);
if (job)
{
job->clear();
*job << "git-rev-parse";
*job << "--is-inside-work-tree";
QString path = dirPath.path();
QFileInfo fsObject(path);
if (fsObject.isFile())
path = fsObject.path();
job->clear();
job->setDirectory(path);
*job << "git-rev-parse";
*job << "--is-inside-work-tree";
job->exec();
if (job->status() == KDevelop::VcsJob::JobSucceeded)
{
......@@ -79,70 +76,6 @@ bool GitExecutor::isValidDirectory(const KUrl & dirPath)
return false;
}
bool GitExecutor::prepareJob(DVCSjob* job, const QString& repository, enum RequestedOperation op)
{
// Only do this check if it's a normal operation like diff, log ...
// For other operations like "git clone" isValidDirectory() would fail as the
// directory is not yet under git control
if (op == GitExecutor::NormalOperation &&
!isValidDirectory(repository)) {
kDebug(9500) << repository << " is not a valid git repository";
return false;
}
// clear commands and args from a possible previous run
job->clear();
// setup the working directory for the new job
job->setDirectory(repository);
return true;
}
bool GitExecutor::addFileList(DVCSjob* job, const QString& repository, const KUrl::List& urls)
{
QStringList args;
foreach(KUrl url, urls) {
///@todo this is ok for now, but what if some of the urls are not
/// to the given repository
QString file = KUrl::relativeUrl(repository + QDir::separator(), url);
args << KShell::quoteArg( file );
}
*job << args;
return true;
}
// QString GitExecutor::convertVcsRevisionToString(const KDevelop::VcsRevision & rev)
// {
// QString str;
//
// switch (rev.revisionType())
// {
// case KDevelop::VcsRevision::Special:
// break;
//
// case KDevelop::VcsRevision::FileNumber:
// if (rev.revisionValue().isValid())
// str = "-r"+rev.revisionValue().toString();
// break;
//
// case KDevelop::VcsRevision::Date:
// if (rev.revisionValue().isValid())
// str = "-D"+rev.revisionValue().toString();
// break;
//
// case KDevelop::VcsRevision::GlobalNumber: // !! NOT SUPPORTED BY CVS !!
// default:
// break;
// }
//
// return str;
// }
DVCSjob* GitExecutor::init(const KUrl &directory)
{
DVCSjob* job = new DVCSjob(vcsplugin);
......@@ -173,8 +106,7 @@ DVCSjob* GitExecutor::add(const QString& repository, const KUrl::List &files)
if (prepareJob(job, repository) ) {
*job << "git";
*job << "add";
addFileList(job, repository, files);
addFileList(job, files);
return job;
}
......@@ -191,8 +123,9 @@ DVCSjob* GitExecutor::commit(const QString& repository,
DVCSjob* job = new DVCSjob(vcsplugin);
if (prepareJob(job, repository) ) {
*job << "git-commit";
foreach(KUrl arg, args)
*job<<arg.path(); //TODO much better to use QStringlist, but IBasicVS...
///In args you may find url, not only comd-line args in this case.
/* foreach(KUrl arg, args)
*job<<KUrl::relativeUrl(repository + QDir::separator(), arg);*/
*job << "-m";
*job << KShell::quoteArg( message );
return job;
......@@ -206,7 +139,7 @@ DVCSjob* GitExecutor::remove(const QString& repository, const KUrl::List &files)
DVCSjob* job = new DVCSjob(vcsplugin);
if (prepareJob(job, repository) ) {
*job << "git-rm";
addFileList(job, repository, files);
addFileList(job, files);
return job;
}
if (job) delete job;
......@@ -246,12 +179,6 @@ DVCSjob* GitExecutor::log(const KUrl& url)
return NULL;
}
// DVCSjob* GitExecutor::is_inside_work_tree(const QString& repository)
// {
//
// return NULL;
// }
DVCSjob* GitExecutor::var(const QString & repository)
{
DVCSjob* job = new DVCSjob(vcsplugin);
......@@ -273,6 +200,19 @@ DVCSjob* GitExecutor::empty_cmd() const
return job;
}
DVCSjob* GitExecutor::checkout(const QString &repository, const QString &branch)
{
///TODO Check if the branch exists. or send only existed branch names here!
DVCSjob* job = new DVCSjob(vcsplugin);
if (prepareJob(job, repository) ) {
*job << "git-checkout";
*job << branch;
return job;
}
if (job) delete job;
return NULL;
}
//Actually we can just copy the outpuc without parsing. So it's a kind of draft for future
void GitExecutor::parseOutput(const QString& jobOutput, QList<DVCScommit>& commits) const
{
......
......@@ -66,40 +66,32 @@ namespace KDevelop
class GitExecutor : public QObject, public KDevelop::IDVCSexecutor
{
Q_OBJECT
public:
GitExecutor(KDevelop::IPlugin* parent = 0);
~GitExecutor();
public:
GitExecutor(KDevelop::IPlugin* parent = 0);
~GitExecutor();
bool isValidDirectory(const KUrl &dirPath);
QString name() const;
bool isValidDirectory(const KUrl &dirPath);
QString name() const;
DVCSjob* init(const KUrl & directory);
DVCSjob* clone(const KUrl &directory, const KUrl repository);
DVCSjob* add(const QString& repository, const KUrl::List &files);
DVCSjob* commit(const QString& repository,
const QString& message = "KDevelop didn't provide any message, it may be a bug",
const KUrl::List& args = QStringList());
DVCSjob* remove(const QString& repository, const KUrl::List& files);
DVCSjob* status(const QString & repo, const KUrl::List & files,
bool recursive=false, bool taginfo=false);
DVCSjob* log(const KUrl& url);
/* DVCSjob* is_inside_work_tree(const QString& repository);*/
DVCSjob* var(const QString &directory);
DVCSjob* empty_cmd() const;
DVCSjob* init(const KUrl & directory);
DVCSjob* clone(const KUrl &directory, const KUrl repository);
DVCSjob* add(const QString& repository, const KUrl::List &files);
DVCSjob* commit(const QString& repository,
const QString& message = "KDevelop didn't provide any message, it may be a bug",
const KUrl::List& args = QStringList());
DVCSjob* remove(const QString& repository, const KUrl::List& files);
DVCSjob* status(const QString & repo, const KUrl::List & files,
bool recursive=false, bool taginfo=false);
DVCSjob* log(const KUrl& url);
DVCSjob* var(const QString &directory);
DVCSjob* empty_cmd() const;
void parseOutput(const QString& jobOutput, QList<DVCScommit>& commits) const;
DVCSjob* checkout(const QString &repository, const QString &branch);
private:
bool addFileList(DVCSjob* job, const QString& repository, const KUrl::List& urls);
// QString convertVcsRevisionToString(const KDevelop::VcsRevision& rev);
void parseOutput(const QString& jobOutput, QList<DVCScommit>& commits) const;
enum RequestedOperation {
NormalOperation,
Init
};
bool prepareJob(DVCSjob* job, const QString& repository,
enum RequestedOperation op = GitExecutor::NormalOperation);
KDevelop::IPlugin* vcsplugin;
private:
KDevelop::IPlugin* vcsplugin;
};
......
......@@ -74,4 +74,12 @@ KDevelop::VcsJob*
return log(localLocation, rev, 0);
}
KDevelop::VcsJob*
GitPlugin::checkout(const QString &localLocation,
const QString &repo)
{
DVCSjob* job = d->m_exec->checkout(localLocation, repo);
return job;
}
// #include "gitplugin.moc"
......@@ -57,6 +57,9 @@ public:
KDevelop::VcsJob* log(const KUrl& localLocation,
const KDevelop::VcsRevision& rev,
const KDevelop::VcsRevision& limit);
//TODO: use KUrl for location!
KDevelop::VcsJob* checkout(const QString &localLocation,
const QString &repo);
};
......
......@@ -152,8 +152,14 @@ void GitInitTest::commitFiles()
}
f.flush();
//Since KJob uses delete later we don't care about deleting pld *j
j = m_proxy->commit(QString(GITTEST_BASEDIR), QString("KDevelop's Test commit2"),KUrl::List(QStringList("-a")));
//add changes
j = m_proxy->add(QString(GITTEST_BASEDIR), KUrl::List(QStringList(GIT_TESTFILE_NAME)));
QVERIFY( j );
// try to start the job
QVERIFY( j->exec() );
j = m_proxy->commit(QString(GITTEST_BASEDIR), QString("KDevelop's Test commit2"));
QVERIFY( j );
// try to start the job
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment