Mercurial > hg > easyhg
comparison logparser.cpp @ 74:10eb97683aa9
* Show branch names even for changes with children, if those children are on a different branch
* Pick up remote repo path from local repo via hg paths
* Some work towards breaking down files into various groups based on status
* Add /usr/local/bin to path for hg (temporary hack I hope)
author | Chris Cannam |
---|---|
date | Fri, 19 Nov 2010 14:54:19 +0000 |
parents | f583e44d9d31 |
children | 8ae3b44c0073 |
comparison
equal
deleted
inserted
replaced
73:a773c6e7b301 | 74:10eb97683aa9 |
---|---|
15 COPYING included with this distribution for more information. | 15 COPYING included with this distribution for more information. |
16 */ | 16 */ |
17 | 17 |
18 #include "logparser.h" | 18 #include "logparser.h" |
19 | 19 |
20 #include "debug.h" | |
21 | |
20 #include <QStringList> | 22 #include <QStringList> |
21 #include <QRegExp> | 23 #include <QRegExp> |
22 | 24 |
23 LogParser::LogParser(QString text) : m_text(text) | 25 LogParser::LogParser(QString text, QString separator) : |
26 m_text(text), m_sep(separator) | |
24 { | 27 { |
25 m_text.replace("\r\n", "\n"); | 28 m_text.replace("\r\n", "\n"); |
26 } | 29 } |
27 | 30 |
28 QStringList LogParser::split() | 31 QStringList LogParser::split() |
31 } | 34 } |
32 | 35 |
33 LogList LogParser::parse() | 36 LogList LogParser::parse() |
34 { | 37 { |
35 LogList results; | 38 LogList results; |
36 QRegExp re("^(\\w+):\\s+(.*)$"); | 39 QRegExp re(QString("^(\\w+)\\s*%1\\s+(.*)$").arg(m_sep)); |
37 QStringList entries = split(); | 40 QStringList entries = split(); |
38 foreach (QString entry, entries) { | 41 foreach (QString entry, entries) { |
39 LogEntry dictionary; | 42 LogEntry dictionary; |
40 QStringList lines = entry.split('\n'); | 43 QStringList lines = entry.split('\n'); |
41 foreach (QString line, lines) { | 44 foreach (QString line, lines) { |
42 if (re.indexIn(line) == 0) { | 45 if (re.indexIn(line) == 0) { |
43 QString key = re.cap(1); | 46 QString key = re.cap(1); |
44 QString value = re.cap(2); | 47 QString value = re.cap(2); |
45 dictionary[key] = value; | 48 dictionary[key.trimmed()] = value; |
46 } | 49 } |
47 } | 50 } |
48 results.push_back(dictionary); | 51 results.push_back(dictionary); |
49 } | 52 } |
50 return results; | 53 return results; |