KDevelop::VcsEvent BazaarUtils::parseBzrLogPart(const QString& output) { const QStringList outputLines = output.split('\n'); KDevelop::VcsEvent commitInfo; bool atMessage = false; QString message; bool afterMessage = false; QHash<QString, KDevelop::VcsItemEvent::Actions> fileToActionsMapping; KDevelop::VcsItemEvent::Action currentAction; for (const QString &line : outputLines) { if (!atMessage) { if (line.startsWith(QStringLiteral("revno"))) { QString revno = line.mid(QStringLiteral("revno: ").length()); revno = revno.left(revno.indexOf(' ')); KDevelop::VcsRevision revision; revision.setRevisionValue(revno.toLongLong(), KDevelop::VcsRevision::GlobalNumber); commitInfo.setRevision(revision); } else if (line.startsWith(QStringLiteral("committer: "))) { QString commiter = line.mid(QStringLiteral("committer: ").length()); commitInfo.setAuthor(commiter); // Author goes after commiter, but only if is different } else if (line.startsWith(QStringLiteral("author"))) { QString author = line.mid(QStringLiteral("author: ").length()); commitInfo.setAuthor(author); // It may override commiter (In fact commiter is not supported by VcsEvent) } else if (line.startsWith(QStringLiteral("timestamp"))) { const QString formatString = QStringLiteral("yyyy-MM-dd hh:mm:ss"); QString timestamp = line.mid(QStringLiteral("timestamp: ddd ").length(), formatString.length()); commitInfo.setDate(QDateTime::fromString(timestamp, formatString)); } else if (line.startsWith(QStringLiteral("message"))) { atMessage = true; } } else if (atMessage && !afterMessage) { if (!line.isEmpty() && line[0].isSpace()) { message += line.trimmed() + "\n"; } else if (!line.isEmpty()) { afterMessage = true; // leave atMessage = true currentAction = BazaarUtils::parseActionDescription(line); } // if line is empty - ignore and get next } else if (afterMessage) { if (!line.isEmpty() && !line[0].isSpace()) { currentAction = BazaarUtils::parseActionDescription(line); } else if (!line.isEmpty()) { fileToActionsMapping[line.trimmed()] |= currentAction; } // if line is empty - ignore and get next } } if (atMessage) commitInfo.setMessage(message.trimmed()); for (auto i = fileToActionsMapping.begin(); i != fileToActionsMapping.end(); ++i) { KDevelop::VcsItemEvent itemEvent; itemEvent.setRepositoryLocation(i.key()); itemEvent.setActions(i.value()); commitInfo.addItem(itemEvent); } return commitInfo; }
void CvsLogJob::parseOutput(const QString& jobOutput, QList<QVariant>& events) { static QRegExp rx_sep( "[-=]+" ); static QRegExp rx_rev( "revision ((\\d+\\.?)+)" ); static QRegExp rx_branch( "branches:\\s+(.*)" ); static QRegExp rx_date( "date:\\s+([^;]*);\\s+author:\\s+([^;]*).*" ); QStringList lines = jobOutput.split('\n'); KDevelop::VcsEvent item; bool firstSeperatorReached = false; QString log; for (int i=0; i<lines.count(); ++i) { QString s = lines[i]; // qCDebug(PLUGIN_CVS) << "line:" << s ; if (rx_rev.exactMatch(s)) { // qCDebug(PLUGIN_CVS) << "MATCH REVISION" ; KDevelop::VcsRevision rev; rev.setRevisionValue( rx_rev.cap(1), KDevelop::VcsRevision::FileNumber ); item.setRevision( rev ); } else if (rx_branch.exactMatch(s)) { // qCDebug(PLUGIN_CVS) << "MATCH BRANCH" ; } else if (rx_date.exactMatch(s)) { // qCDebug(PLUGIN_CVS) << "MATCH DATE" ; QString date = rx_date.cap(1); // cut out the part that matches the Qt::ISODate format date.truncate(19); item.setDate( QDateTime::fromString( date, Qt::ISODate ) ); item.setAuthor( rx_date.cap(2) ); } else if (rx_sep.exactMatch(s)) { // qCDebug(PLUGIN_CVS) << "MATCH SEPARATOR" ; if (firstSeperatorReached) { item.setMessage( log ); log.clear(); events.append( qVariantFromValue( item ) ); KDevelop::VcsEvent empty; item = empty; } else { firstSeperatorReached = true; } } else { if (firstSeperatorReached) { // qCDebug(PLUGIN_CVS) << "ADDING LOG" ; log += s+'\n'; } } } }
void BranchesListModel::createBranch(const QString& baseBranch, const QString& newBranch) { qCDebug(VCS) << "Creating " << baseBranch << " based on " << newBranch; KDevelop::VcsRevision rev; rev.setRevisionValue(baseBranch, KDevelop::VcsRevision::GlobalNumber); KDevelop::VcsJob* branchJob = d->dvcsplugin->branch(d->repo, rev, newBranch); qCDebug(VCS) << "Adding new branch"; if (branchJob->exec()) appendRow(new BranchItem(newBranch)); }
void SvnInternalBlameJob::run() { initBeforeRun(); QByteArray ba = location().toLocalFile( KUrl::RemoveTrailingSlash ).toUtf8(); svn::Client cli(m_ctxt); svn::AnnotatedFile* file; try { file = cli.annotate( ba.data(), createSvnCppRevisionFromVcsRevision( startRevision() ), createSvnCppRevisionFromVcsRevision( endRevision() ) ); }catch( svn::ClientException ce ) { kDebug(9510) << "Exception while blaming file: " << location() << QString::fromUtf8( ce.message() ); setErrorMessage( QString::fromUtf8( ce.message() ) ); m_success = false; return; } svn_revnum_t minrev = -1, maxrev = -1; for( svn::AnnotatedFile::const_iterator it = file->begin(); it != file->end(); it++ ) { if( (*it).revision() < minrev || minrev == -1 ) { minrev = (*it).revision(); } if( (*it).revision() > maxrev || maxrev == -1 ) { maxrev = (*it).revision(); } } QHash<svn_revnum_t,QString> commitMessages; try { const svn::LogEntries* entries = cli.log( ba.data(), svn::Revision(minrev), svn::Revision(maxrev), false, false ); for( svn::LogEntries::const_iterator it = entries->begin(); it != entries->end(); it++ ) { commitMessages[(*it).revision] = QString::fromUtf8( (*it).message.c_str() ); } }catch( svn::ClientException ce ) { kDebug(9510) << "Exception while fetching log messages for blame: " << location() << QString::fromUtf8( ce.message() ); setErrorMessage( QString::fromUtf8( ce.message() ) ); m_success = false; } for( svn::AnnotatedFile::const_iterator it = file->begin(); it != file->end(); it++ ) { KDevelop::VcsAnnotationLine line; line.setAuthor( QString::fromUtf8( it->author().c_str() ) ); line.setDate( QDateTime::fromString( QString::fromUtf8( it->date().c_str() ), Qt::ISODate ) ); line.setText( QString::fromUtf8( it->line().c_str() ) ); KDevelop::VcsRevision rev; rev.setRevisionValue( QVariant( qlonglong( it->revision() ) ), KDevelop::VcsRevision::GlobalNumber ); line.setRevision( rev ); line.setLineNumber( it->lineNumber() ); line.setCommitMessage( commitMessages[it->revision()] ); emit blameLine( line ); } }