/*************************************************************************** * Copyright 2008 Robert Gruber * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "cvsstatusjob.h" #include #include #include #include #include CvsStatusJob::CvsStatusJob(KDevelop::IPlugin* parent, KDevelop::OutputJob::OutputJobVerbosity verbosity) : CvsJob(parent, verbosity) { } CvsStatusJob::~CvsStatusJob() { } QVariant CvsStatusJob::fetchResults() { // Convert job's output into KDevelop::VcsStatusInfo QList infos; parseOutput(output(), infos); return infos; } void CvsStatusJob::addInfoToList(QList& infos, const QString& currentDir, const QString& filename, const QString& statusString) { KDevelop::VcsStatusInfo::State cvsState = String2EnumState( statusString ); QString correctedFilename = filename; if (cvsState == KDevelop::VcsStatusInfo::ItemDeleted) { // cvs status writes "no file" in front of the filename // in case the file was locally removed correctedFilename.remove("no file "); } // join the current directory (if any) and the found filename ... // note: current directy is always relative to the directory where the // cvs command was executed QString file = currentDir; if (file.length() > 0) { file += QDir::separator(); } file += correctedFilename; // ... and create a VcsFileInfo entry KDevelop::VcsStatusInfo info; info.setUrl(QString(getDirectory() + QDir::separator() + file)); info.setState(cvsState); kDebug(9500) << "Added status of: " << info.url() << endl; infos << qVariantFromValue( info ); } void CvsStatusJob::parseOutput(const QString& jobOutput, QList& infos) { QString filename; QString status; QString reporev; QString workrev; static QRegExp re_start("^=+$"); static QRegExp re_file("File:\\s+(.*)\\s+Status:\\s+(.*)"); static QRegExp re_workrev("\\s+Working revision:\\s+([\\d\\.]*).*"); static QRegExp re_reporev("\\s+Repository revision:\\s+([\\d\\.]*).*"); static QRegExp re_dirchange("cvs status: Examining\\s+(.*)"); QString currentDir; QStringList lines = jobOutput.split('\n'); for (int i=0; i