annotate src/changeset.cpp @ 548:dca5bd5b2a06

Merge from branch "fswatcher"
author Chris Cannam
date Tue, 14 Feb 2012 17:55:39 +0000
parents b5a342a71218
children 533519ebc0cb
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@244 8 Copyright (c) 2011 Chris Cannam
Chris@244 9 Copyright (c) 2011 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
Chris@57 17
Chris@43 18 #include "changeset.h"
Chris@125 19 #include "common.h"
Chris@419 20 #include "debug.h"
Chris@106 21
Chris@106 22 #include <QVariant>
Chris@106 23
Chris@510 24 Changeset::Changeset(const LogEntry &e) :
Chris@510 25 m_closed(false)
Chris@106 26 {
Chris@106 27 foreach (QString key, e.keys()) {
Chris@106 28 if (key == "parents") {
Chris@106 29 QStringList parents = e.value(key).split
Chris@106 30 (" ", QString::SkipEmptyParts);
Chris@106 31 setParents(parents);
Chris@128 32 } else if (key == "tag") {
Chris@128 33 QStringList tags = e.value(key).split
Chris@128 34 (" ", QString::SkipEmptyParts);
Chris@128 35 setTags(tags);
Chris@520 36 } else if (key == "bookmarks") {
Chris@520 37 QStringList bmarks = e.value(key).split
Chris@520 38 (" ", QString::SkipEmptyParts);
Chris@520 39 setBookmarks(bmarks);
Chris@106 40 } else if (key == "timestamp") {
Chris@106 41 setTimestamp(e.value(key).split(" ")[0].toULongLong());
Chris@108 42 } else if (key == "changeset") {
Chris@108 43 setId(e.value(key));
Chris@106 44 } else {
Chris@106 45 setProperty(key.toLocal8Bit().data(), e.value(key));
Chris@106 46 }
Chris@106 47 }
Chris@106 48 }
Chris@106 49
Chris@125 50 QString Changeset::getLogTemplate()
Chris@125 51 {
Chris@520 52 return "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tags}\\nbookmarks: {bookmarks}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
Chris@125 53 }
Chris@125 54
Chris@125 55 QString Changeset::formatHtml()
Chris@125 56 {
Chris@125 57 QString description;
Chris@153 58 QString rowTemplate = "<tr><td><b>%1</b>&nbsp;</td><td>%2</td></tr>";
Chris@125 59
Chris@125 60 description = "<qt><table border=0>";
Chris@125 61
Chris@419 62 // DEBUG << "comment is " << comment() << endl;
Chris@419 63
Chris@125 64 QString c = comment().trimmed();
Chris@125 65 c = c.replace(QRegExp("^\""), "");
Chris@125 66 c = c.replace(QRegExp("\"$"), "");
Chris@125 67 c = c.replace("\\\"", "\"");
Chris@125 68 c = xmlEncode(c);
Chris@125 69 c = c.replace("\\n", "<br>");
Chris@125 70
Chris@125 71 QStringList propNames, propTexts;
Chris@125 72
Chris@125 73 propNames << "id"
Chris@128 74 << "author"
Chris@125 75 << "datetime"
Chris@125 76 << "branch"
Chris@128 77 << "tags"
Chris@520 78 << "bookmarks"
Chris@125 79 << "comment";
Chris@125 80
Chris@165 81 propTexts << QObject::tr("Identifier:")
Chris@165 82 << QObject::tr("Author:")
Chris@165 83 << QObject::tr("Date:")
Chris@165 84 << QObject::tr("Branch:")
Chris@521 85 << QObject::tr("Tags:")
Chris@521 86 << QObject::tr("Bookmarks:")
Chris@165 87 << QObject::tr("Comment:");
Chris@125 88
Chris@125 89 for (int i = 0; i < propNames.size(); ++i) {
Chris@125 90 QString prop = propNames[i];
Chris@125 91 QString value;
Chris@165 92 if (prop == "id") {
Chris@165 93 value = hashOf(id());
Chris@165 94 } else if (prop == "comment") {
Chris@128 95 value = c;
Chris@128 96 } else if (prop == "tags") {
Chris@128 97 value = tags().join(" ");
Chris@520 98 } else if (prop == "bookmarks") {
Chris@520 99 value = bookmarks().join(" ");
Chris@128 100 } else {
Chris@125 101 value = xmlEncode(property(prop.toLocal8Bit().data()).toString());
Chris@125 102 }
Chris@125 103 if (value != "") {
Chris@125 104 description += rowTemplate
Chris@125 105 .arg(xmlEncode(propTexts[i]))
Chris@125 106 .arg(value);
Chris@125 107 }
Chris@125 108 }
Chris@125 109
Chris@125 110 description += "</table></qt>";
Chris@125 111
Chris@125 112 return description;
Chris@125 113 }