annotate changeset.cpp @ 127:758471b71721

* Don't provide file list when committing, if the user didn't select files. Previously we (perhaps inadvertantly) used a list of all files because we had generated that for display -- but it breaks merge-commits and it's probably unwise to mess with very long command lines.
author Chris Cannam
date Mon, 29 Nov 2010 17:48:43 +0000
parents 63c2f3f61c79
children fcaf09ee825d
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@57 8 Copyright (c) 2010 Chris Cannam
Chris@57 9 Copyright (c) 2010 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@106 20
Chris@106 21 #include <QVariant>
Chris@106 22
Chris@106 23 Changeset::Changeset(const LogEntry &e)
Chris@106 24 {
Chris@106 25 foreach (QString key, e.keys()) {
Chris@106 26 if (key == "parents") {
Chris@106 27 QStringList parents = e.value(key).split
Chris@106 28 (" ", QString::SkipEmptyParts);
Chris@106 29 setParents(parents);
Chris@106 30 } else if (key == "timestamp") {
Chris@106 31 setTimestamp(e.value(key).split(" ")[0].toULongLong());
Chris@108 32 } else if (key == "changeset") {
Chris@108 33 setId(e.value(key));
Chris@106 34 } else {
Chris@106 35 setProperty(key.toLocal8Bit().data(), e.value(key));
Chris@106 36 }
Chris@106 37 }
Chris@106 38 }
Chris@106 39
Chris@125 40 QString Changeset::getLogTemplate()
Chris@125 41 {
Chris@125 42 return "id: {rev}:{node|short}\\nuser: {author}\\nbranch: {branches}\\ntag: {tag}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
Chris@125 43 }
Chris@125 44
Chris@125 45 QString Changeset::formatHtml()
Chris@125 46 {
Chris@125 47 QString description;
Chris@125 48 QString rowTemplate = "<tr><td><b>%1</b></td><td>%2</td></tr>";
Chris@125 49
Chris@125 50 description = "<qt><table border=0>";
Chris@125 51
Chris@125 52 QString c = comment().trimmed();
Chris@125 53 c = c.replace(QRegExp("^\""), "");
Chris@125 54 c = c.replace(QRegExp("\"$"), "");
Chris@125 55 c = c.replace("\\\"", "\"");
Chris@125 56 c = xmlEncode(c);
Chris@125 57 c = c.replace("\\n", "<br>");
Chris@125 58
Chris@125 59 QStringList propNames, propTexts;
Chris@125 60
Chris@125 61 propNames << "id"
Chris@125 62 << "user"
Chris@125 63 << "datetime"
Chris@125 64 << "branch"
Chris@125 65 << "tag"
Chris@125 66 << "comment";
Chris@125 67
Chris@125 68 propTexts << QObject::tr("Identifier")
Chris@125 69 << QObject::tr("Author")
Chris@125 70 << QObject::tr("Date")
Chris@125 71 << QObject::tr("Branch")
Chris@125 72 << QObject::tr("Tag")
Chris@125 73 << QObject::tr("Comment");
Chris@125 74
Chris@125 75 for (int i = 0; i < propNames.size(); ++i) {
Chris@125 76 QString prop = propNames[i];
Chris@125 77 QString value;
Chris@125 78 if (prop == "comment") value = c;
Chris@125 79 else {
Chris@125 80 value = xmlEncode(property(prop.toLocal8Bit().data()).toString());
Chris@125 81 }
Chris@125 82 if (value != "") {
Chris@125 83 description += rowTemplate
Chris@125 84 .arg(xmlEncode(propTexts[i]))
Chris@125 85 .arg(value);
Chris@125 86 }
Chris@125 87 }
Chris@125 88
Chris@125 89 description += "</table></qt>";
Chris@125 90
Chris@125 91 return description;
Chris@125 92 }