Commit 2e93fa89 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Remove synchronous versions of the API

It makes little sense, specially for how it's exposed. We already moved
out the branches manager from using this API and now we can safely remove
it.
parent 9e403ee4
......@@ -59,6 +59,16 @@ K_EXPORT_PLUGIN(KDevGitFactory(KAboutData("kdevgit","kdevgit",ki18n("Git"),"0.1"
using namespace KDevelop;
QVariant runSynchronously(KDevelop::VcsJob* job)
{
QVariant ret;
if(job->exec() && job->status()==KDevelop::VcsJob::JobSucceeded) {
ret = job->fetchResults();
}
delete job;
return ret;
}
namespace
{
......@@ -866,11 +876,11 @@ QList<DVcsEvent> GitPlugin::getAllCommits(const QString &repo)
void GitPlugin::initBranchHash(const QString &repo)
{
QStringList branches = listBranches(KUrl(repo));
kDebug() << "BRANCHES: " << branches;
QStringList gitBranches = runSynchronously(branches(KUrl(repo))).toStringList();
kDebug() << "BRANCHES: " << gitBranches;
//Now root branch is the current branch. In future it should be the longest branch
//other commitLists are got with git-rev-lits branch ^br1 ^ br2
QString root = GitPlugin::curBranch(repo);
QString root = runSynchronously(currentBranch(repo)).toString();
QScopedPointer<DVcsJob> job(gitRevList(repo, QStringList(root)));
bool ret = job->exec();
Q_ASSERT(ret && job->status()==VcsJob::JobSucceeded && "TODO: provide a fall back in case of failing");
......@@ -878,12 +888,12 @@ void GitPlugin::initBranchHash(const QString &repo)
QStringList commits = job->output().split('\n', QString::SkipEmptyParts);
// kDebug() << "\n\n\n commits" << commits << "\n\n\n";
branchesShas.append(commits);
foreach(const QString &branch, branches)
foreach(const QString &branch, gitBranches)
{
if (branch == root)
continue;
QStringList args(branch);
foreach(const QString &branch_arg, branches)
foreach(const QString &branch_arg, gitBranches)
{
if (branch_arg != branch)
//man gitRevList for '^'
......
......@@ -191,4 +191,6 @@ private:
QString m_errorDescription;
};
QVariant runSynchronously(KDevelop::VcsJob* job);
#endif
......@@ -286,7 +286,7 @@ void GitInitTest::testBranching()
VcsJob* j = m_plugin->branches(KUrl(gitTest_BaseDir));
VERIFYJOB(j);
QString curBranch = m_plugin->curBranch(gitTest_BaseDir);
QString curBranch = runSynchronously(m_plugin->currentBranch(gitTest_BaseDir)).toString();
QCOMPARE(curBranch, QString("master"));
QString newBranch("new");
......@@ -294,15 +294,15 @@ void GitInitTest::testBranching()
rev.setRevisionValue("master", KDevelop::VcsRevision::GlobalNumber);
j = m_plugin->branch(KUrl(gitTest_BaseDir), rev, newBranch);
VERIFYJOB(j);
QVERIFY(m_plugin->listBranches(KUrl(gitTest_BaseDir)).contains(newBranch));
QVERIFY(runSynchronously(m_plugin->branches(KUrl(gitTest_BaseDir))).toStringList().contains(newBranch));
j = m_plugin->switchBranch(KUrl(gitTest_BaseDir), newBranch);
VERIFYJOB(j);
QCOMPARE(m_plugin->curBranch(KUrl(gitTest_BaseDir)), newBranch);
QCOMPARE(runSynchronously(m_plugin->currentBranch(gitTest_BaseDir)).toString(), newBranch);
j = m_plugin->deleteBranch(KUrl(gitTest_BaseDir), "master");
VERIFYJOB(j);
QVERIFY(!m_plugin->listBranches(KUrl(gitTest_BaseDir)).contains("master"));
QVERIFY(!runSynchronously(m_plugin->branches(KUrl(gitTest_BaseDir))).toStringList().contains("master"));
}
void GitInitTest::revHistory()
......
......@@ -219,26 +219,6 @@ KDevelop::DVcsJob* DistributedVersionControlPlugin::empty_cmd(KDevelop::OutputJo
return j;
}
QString DistributedVersionControlPlugin::curBranch(const KUrl& repo)
{
QString name;
QScopedPointer<VcsJob> job(currentBranch(repo));
if(job->exec() && job->status()==VcsJob::JobSucceeded) {
name = job->fetchResults().toString();
}
return name;
}
QStringList DistributedVersionControlPlugin::listBranches(const KUrl& repo)
{
QStringList branchlist;
QScopedPointer<VcsJob> job(branches(repo));
if(job->exec() && job->status()==VcsJob::JobSucceeded) {
branchlist = job->fetchResults().toStringList();
}
return branchlist;
}
}
//-----------------------------------------------------------------------------------
......
......@@ -104,12 +104,6 @@ public Q_SLOTS:
// slots for menu
void slotInit();
///synchronous currentBranch call
QString curBranch(const KUrl& repo);
///synchronous listBranches call
QStringList listBranches(const KUrl& repo);
Q_SIGNALS:
/**
......
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