diff statparser.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
children 89f793fbedda
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/statparser.cpp	Fri Nov 19 14:54:19 2010 +0000
@@ -0,0 +1,25 @@
+#include "statparser.h"
+
+#include <QMap>
+
+StatParser::StatParser(QString text)
+{
+    text.replace("\r\n", "\n");
+
+    QMap<QChar, QStringList *> buckets;
+    buckets['M'] = &modified;
+    buckets['A'] = &added;
+    buckets['R'] = &removed;
+    buckets['!'] = &missing;
+    buckets['?'] = &unknown;
+
+    QStringList lines = text.split("\n", QString::SkipEmptyParts);
+    foreach (QString line, lines) {
+        if (line.length() < 3 || line[2] != ' ') continue;
+        QChar tag = line[0];
+        QString file = line.right(line.length() - 2);
+        if (buckets.contains(tag)) {
+            buckets[tag]->push_back(file);
+        }
+    }
+}