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)); }
QString BazaarUtils::getRevisionSpec(const KDevelop::VcsRevision& revision) { if (revision.revisionType() == KDevelop::VcsRevision::Special) { if (revision.specialType() == KDevelop::VcsRevision::Head) return QStringLiteral("-rlast:1"); else if (revision.specialType() == KDevelop::VcsRevision::Base) return QString(); // Workaround strange KDevelop behaviour else if (revision.specialType() == KDevelop::VcsRevision::Working) return QString(); else if (revision.specialType() == KDevelop::VcsRevision::Start) return QStringLiteral("-r1"); else return QString(); // Don't know how to handle this situation } else if (revision.revisionType() == KDevelop::VcsRevision::GlobalNumber) return QStringLiteral("-r") + QString::number(revision.revisionValue().toLongLong()); else return QString(); // Don't know how to handle this situation }
QString BazaarUtils::getRevisionSpecRange(const KDevelop::VcsRevision& end) { if (end.revisionType() == KDevelop::VcsRevision::Special) { if (end.specialType() == KDevelop::VcsRevision::Head) { return QStringLiteral("-r..last:1"); } else if (end.specialType() == KDevelop::VcsRevision::Base) { return QStringLiteral("-r..last:1"); // Workaround strange KDevelop behaviour } else if (end.specialType() == KDevelop::VcsRevision::Working) { return QString(); } else if (end.specialType() == KDevelop::VcsRevision::Start) { return QStringLiteral("-..r1"); } else { return QString(); // Don't know how to handle this situation } } else if (end.revisionType() == KDevelop::VcsRevision::GlobalNumber) { return QStringLiteral("-r") + QString::number(end.revisionValue().toLongLong()); } return QString(); // Don't know how to handle this situation }
QString BazaarUtils::getRevisionSpecRange(const KDevelop::VcsRevision& begin, const KDevelop::VcsRevision& end) { if (begin.revisionType() == KDevelop::VcsRevision::Special) { if (begin.specialType() == KDevelop::VcsRevision::Previous) { if (end.revisionType() == KDevelop::VcsRevision::Special) { if (end.specialType() == KDevelop::VcsRevision::Base || end.specialType() == KDevelop::VcsRevision::Head) return QStringLiteral("-rlast:2..last:1"); else if (end.specialType() == KDevelop::VcsRevision::Working) return QString(); else if (end.specialType() == KDevelop::VcsRevision::Start) return QStringLiteral("-r0..1"); // That's wrong revision range } else if (end.revisionType() == KDevelop::VcsRevision::GlobalNumber) return QStringLiteral("-r") + QString::number(end.revisionValue().toLongLong() - 1) + ".." + QString::number(end.revisionValue().toLongLong()); else return QString(); // Don't know how to handle this situation } else if (begin.specialType() == KDevelop::VcsRevision::Base || begin.specialType() == KDevelop::VcsRevision::Head) { // Only one possibility: comparing working copy to last commit return QString(); } } else if (begin.revisionType() == KDevelop::VcsRevision::GlobalNumber) { if (end.revisionType() == KDevelop::VcsRevision::Special) { // Assuming working copy return QStringLiteral("-r") + QString::number(begin.revisionValue().toLongLong()); } else { return QStringLiteral("-r") + QString::number(begin.revisionValue().toLongLong()) + ".." + QString::number(end.revisionValue().toLongLong()); } } return QString(); // Don't know how to handle this situation }
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 ); } }