MCPcopy Create free account
hub / github.com/KDE/kdevelop / parseP4AnnotateOutput

Method parseP4AnnotateOutput

plugins/perforce/perforceplugin.cpp:601–664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

599}
600
601void PerforcePlugin::parseP4AnnotateOutput(DVcsJob *job)
602{
603 QVariantList results;
604 /// First get the changelists for this file
605 QStringList strList(job->dvcsCommand());
606 QString localLocation(strList.last()); /// ASSUMPTION WARNING - localLocation is the last in the annotate command
607 KDevelop::VcsRevision dummyRev;
608 QScopedPointer<DVcsJob> logJob(new DVcsJob(job->directory(), this, OutputJob::Silent));
609 QFileInfo curFile(localLocation);
610 setEnvironmentForJob(logJob.data(), curFile);
611 *logJob << m_perforceExecutable << "filelog" << "-lit" << localLocation;
612
613 QList<QVariant> commits;
614 if (logJob->exec() && logJob->status() == KDevelop::VcsJob::JobSucceeded) {
615 if (!job->output().isEmpty()) {
616 commits = getQvariantFromLogOutput(logJob->output().split(QLatin1Char('\n'), Qt::SkipEmptyParts));
617 }
618 }
619
620 VcsEvent item;
621 QMap<qlonglong, VcsEvent> globalCommits;
622 /// Move the VcsEvents to a more suitable data structure
623 for (auto& commit : std::as_const(commits)) {
624 if (commit.canConvert<VcsEvent>()) {
625 item = commit.value<VcsEvent>();
626 }
627 globalCommits.insert(item.revision().revisionValue().toLongLong(), item);
628 }
629
630 const QStringList lines = job->output().split(QLatin1Char('\n'));
631
632 int lineNumber = 0;
633 QMap<qlonglong, VcsEvent>::iterator currentEvent;
634 bool convertToIntOk(false);
635 int globalRevisionInt(0);
636 QString globalRevision;
637 for (auto& line : lines) {
638 if (line.isEmpty()) {
639 continue;
640 }
641
642 globalRevision = line.left(line.indexOf(QLatin1Char(':')));
643
644 VcsAnnotationLine annotation;
645 annotation.setLineNumber(lineNumber);
646 VcsRevision rev;
647 rev.setRevisionValue(globalRevision, KDevelop::VcsRevision::GlobalNumber);
648 annotation.setRevision(rev);
649 // Find the other info in the commits list
650 globalRevisionInt = globalRevision.toLongLong(&convertToIntOk);
651 if(convertToIntOk)
652 {
653 currentEvent = globalCommits.find(globalRevisionInt);
654 annotation.setAuthor(currentEvent->author());
655 annotation.setCommitMessage(currentEvent->message());
656 annotation.setDate(currentEvent->date());
657 }
658

Callers

nothing calls this directly

Calls 15

dvcsCommandMethod · 0.80
execMethod · 0.80
outputMethod · 0.80
revisionValueMethod · 0.80
setLineNumberMethod · 0.80
setRevisionValueMethod · 0.80
setResultsMethod · 0.80
lastMethod · 0.45
directoryMethod · 0.45
dataMethod · 0.45
statusMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected