juraj@home:~$

KDevelop AppWizard - DVCS fix for empty project

Backstory #

Few days ago I wanted to play with Falkon and create some basic Qml plugin. (What else to do to play, Python support is broken and C++ is for built-in plugins).

I started KDevelop (the big IDE I use) and went to create new Empty project because as I am not big Qml lover I did not create template for it yet. But I was met with errors which made me change my focus and fix the tool I use (KDevelop) before playing with Qml and Falkon.

Man must shape his tools lest they shape him. - Arthur Miller

Problem #

During the project creation AppWizard is trying add files and than commit changes into new DVCS (Decentralized Version Control System) repository. When there are no files to add there will naturally be nothing to commit which results in error message from DVCS and the project creation is stopped and project removed.

Solution #

Lets dive into KDevelop code and check what can be done about it. My humble solution relays on checking the state of the DVCS repository before commit. To achieve this I am trying to get actual status of the repository from VCS (Version Control System) and then checking if the result contains some items.

The KDevPlatform provides nice API to work with VCSs and thus I only need to call few method to get all the data.

Actual code is truly simple and works for me. (only my changes)

qCDebug(PLUGIN_APPWIZARD) << "Checking for valid files in the DVCS repository:" << dest;
job = dvcs->status({dest}, KDevelop::IBasicVersionControl::Recursive);
if (!job || !job->exec() || job->status() != VcsJob::JobSucceeded)
{
    vcsError(i18n("Could not check status of the DVCS repository"), scratchArea, dest);
    return false;
}

if (job->fetchResults().toList().isEmpty())
{
    qCDebug(PLUGIN_APPWIZARD) << "No files to add, skipping commit in the DVCS repository:" << dest;
    return true;
}

Brief description #

  • Print notice into debug output
  • Prepare job with status command to run
  • Execute the job and check for failure
    • If failed put notice in debug output
  • Check if the response contains some items
    • If not put notice in debug output
    • Skip add files & commit by returning true
  • Test many times and done.

Results #

KDevelop is able to create Empty project from template with initialized DVCS repository which is really helpful when one wish to start a project from scratch.

Git #

Works just fine.

Bazaar #

The world is never perfect and there is always a room for improvements.

The merge request is waiting for review at invent.kde.org !73.