| 599 | } |
| 600 | |
| 601 | void 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 |
nothing calls this directly
no test coverage detected