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

Method parseBzrLog

plugins/bazaar/bzrannotatejob.cpp:127–175  ·  view source on GitHub ↗

* This is slightly different from BazaarUtils::parseBzrLogPart(...). * This function parses only commit general info. It does not parse single * actions. In fact output parsed by this function is slightly different * from output parsed by BazaarUtils. As a result parsing this output using * BazaarUtils would yield different results. * NOTE: This is all about parsing 'message'. */

Source from the content-addressed store, hash-verified

125 * NOTE: This is all about parsing 'message'.
126 */
127void BzrAnnotateJob::parseBzrLog(KDevelop::DVcsJob* job)
128{
129 const QStringList outputLines = job->output().split(QLatin1Char('\n'));
130 KDevelop::VcsEvent commitInfo;
131 int revision=-1;
132 bool atMessage = false;
133 QString message;
134 for (const QString& line : outputLines) {
135 if (!atMessage) {
136 if (line.startsWith(QLatin1String("revno"))) {
137 QString revno = line.mid(QStringLiteral("revno: ").length());
138 // In future there is possibility that "revno: " will change to
139 // "revno??". If that's all, then we recover matching only
140 // "revno" prefix and assuming placeholder of length 2 (": " or
141 // "??").
142 // The same below with exception of "committer" which possibly
143 // can have also some suffix which changes meaning like
144 // "committer-some_property: "...
145 revno = revno.left(revno.indexOf(QLatin1Char(' ')));
146 revision = revno.toInt();
147 KDevelop::VcsRevision revision;
148 revision.setRevisionValue(revno.toLongLong(), KDevelop::VcsRevision::GlobalNumber);
149 commitInfo.setRevision(revision);
150 } else if (line.startsWith(QLatin1String("committer: "))) {
151 QString commiter = line.mid(QStringLiteral("committer: ").length());
152 commitInfo.setAuthor(commiter); // Author goes after committer, but only if is different
153 } else if (line.startsWith(QLatin1String("author"))) {
154 QString author = line.mid(QStringLiteral("author: ").length());
155 commitInfo.setAuthor(author); // It may override committer (In fact committer is not supported by VcsEvent)
156 } else if (line.startsWith(QLatin1String("timestamp"))) {
157 const QString formatString = QStringLiteral("yyyy-MM-dd hh:mm:ss");
158 QString timestamp = line.mid(QStringLiteral("timestamp: ddd ").length(), formatString.length());
159 commitInfo.setDate(QDateTime::fromString(timestamp, formatString));
160 } else if (line.startsWith(QLatin1String("message"))) {
161 atMessage = true;
162 }
163 } else {
164 message += line.trimmed() + QLatin1Char('\n');
165 }
166 }
167 if (atMessage)
168 commitInfo.setMessage(message.trimmed());
169 Q_ASSERT(revision!=-1);
170 m_commits[revision] = commitInfo;
171 // Invoke from event loop to protect against stack overflow (it could happen
172 // on very big files with very big history of changes if tail-recursion
173 // optimization had failed here).
174 QTimer::singleShot(0, this, &BzrAnnotateJob::parseNextLine);
175}
176
177QVariant BzrAnnotateJob::fetchResults()
178{

Callers

nothing calls this directly

Calls 11

outputMethod · 0.80
midMethod · 0.80
toIntMethod · 0.80
setRevisionValueMethod · 0.80
splitMethod · 0.45
lengthMethod · 0.45
indexOfMethod · 0.45
setRevisionMethod · 0.45
setAuthorMethod · 0.45
setDateMethod · 0.45
setMessageMethod · 0.45

Tested by

no test coverage detected