changeset 520:a17c06f773cd

idiot -- we don't need to query bookmarks separately, we can just add them to the log template
author Chris Cannam
date Wed, 09 Nov 2011 13:04:00 +0000
parents 000f13faa089
children b5a342a71218
files src/changeset.cpp src/changeset.h src/changesetitem.cpp src/changesetitem.h src/hgaction.h src/hgtabwidget.cpp src/hgtabwidget.h src/historywidget.cpp src/historywidget.h src/mainwindow.cpp src/mainwindow.h
diffstat 11 files changed, 32 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/src/changeset.cpp	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/changeset.cpp	Wed Nov 09 13:04:00 2011 +0000
@@ -33,6 +33,10 @@
             QStringList tags = e.value(key).split
                 (" ", QString::SkipEmptyParts);
             setTags(tags);
+        } else if (key == "bookmarks") {
+            QStringList bmarks = e.value(key).split
+                (" ", QString::SkipEmptyParts);
+            setBookmarks(bmarks);
         } else if (key == "timestamp") {
             setTimestamp(e.value(key).split(" ")[0].toULongLong());
         } else if (key == "changeset") {
@@ -45,7 +49,7 @@
 
 QString Changeset::getLogTemplate()
 {
-    return "id: {rev}:{node|short}\\nauthor: {author}\\nbranch: {branches}\\ntag: {tags}\\ndatetime: {date|isodate}\\ntimestamp: {date|hgdate}\\nage: {date|age}\\nparents: {parents}\\ncomment: {desc|json}\\n\\n";
+    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";
 }
 
 QString Changeset::formatHtml()
@@ -71,6 +75,7 @@
 	      << "datetime"
 	      << "branch"
 	      << "tags"
+	      << "bookmarks"
 	      << "comment";
 
     propTexts << QObject::tr("Identifier:")
@@ -89,6 +94,8 @@
             value = c;
         } else if (prop == "tags") {
             value = tags().join(" ");
+        } else if (prop == "bookmarks") {
+            value = bookmarks().join(" ");
         } else {
 	    value = xmlEncode(property(prop.toLocal8Bit().data()).toString());
 	}
--- a/src/changeset.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/changeset.h	Wed Nov 09 13:04:00 2011 +0000
@@ -38,6 +38,7 @@
     Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged STORED true);
     Q_PROPERTY(QString branch READ branch WRITE setBranch NOTIFY branchChanged STORED true);
     Q_PROPERTY(QStringList tags READ tags WRITE setTags NOTIFY tagsChanged STORED true);
+    Q_PROPERTY(QStringList bookmarks READ bookmarks WRITE setBookmarks NOTIFY bookmarksChanged STORED true);
     Q_PROPERTY(QString datetime READ datetime WRITE setDatetime NOTIFY datetimeChanged STORED true);
     Q_PROPERTY(qulonglong timestamp READ timestamp WRITE setTimestamp NOTIFY timestampChanged STORED true);
     Q_PROPERTY(QString age READ age WRITE setAge NOTIFY ageChanged STORED true);
@@ -53,6 +54,7 @@
     QString author() const { return m_author; }
     QString branch() const { return m_branch; }
     QStringList tags() const { return m_tags; }
+    QStringList bookmarks() const { return m_bookmarks; }
     QString datetime() const { return m_datetime; }
     qulonglong timestamp() const { return m_timestamp; }
     QString age() const { return m_age; }
@@ -120,6 +122,7 @@
     void authorChanged(QString author);
     void branchChanged(QString branch);
     void tagsChanged(QStringList tags);
+    void bookmarksChanged(QStringList bookmarks);
     void datetimeChanged(QString datetime);
     void timestampChanged(qulonglong timestamp);
     void ageChanged(QString age);
@@ -134,6 +137,8 @@
     void setBranch(QString branch) { m_branch = branch; emit branchChanged(branch); }
     void setTags(QStringList tags) { m_tags = tags; emit tagsChanged(tags); }
     void addTag(QString tag) { m_tags.push_back(tag); emit tagsChanged(m_tags); }
+    void setBookmarks(QStringList bmarks) { m_bookmarks = bmarks; emit bookmarksChanged(bmarks); }
+    void addBookmark(QString b) { m_bookmarks.push_back(b); emit bookmarksChanged(m_bookmarks); }
     void setDatetime(QString datetime) { m_datetime = datetime; emit datetimeChanged(datetime); }
     void setTimestamp(qulonglong timestamp) { m_timestamp = timestamp; emit timestampChanged(timestamp); }
     void setAge(QString age) { m_age = age; emit ageChanged(age); }
@@ -148,6 +153,7 @@
     QString m_author;
     QString m_branch;
     QStringList m_tags;
+    QStringList m_bookmarks;
     QString m_datetime;
     qulonglong m_timestamp;
     QString m_age;
--- a/src/changesetitem.cpp	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/changesetitem.cpp	Wed Nov 09 13:04:00 2011 +0000
@@ -407,17 +407,6 @@
         }
     }
 
-    if (!m_bookmarks.empty()) {
-        QString bmText = m_bookmarks.join(" ").trimmed();
-        int bw = fm.width(bmText);
-        paint->fillRect(QRectF(x0 + width - 8 - bw, 1, bw + 4, fh - 1),
-                        QBrush(Qt::yellow)); paint->drawText(x0 + width - 6 - bw, fm.ascent(), bmText);
-    }
-
-    paint->setPen(QPen(branchColour, 2));
-    paint->setBrush(Qt::NoBrush);
-    paint->drawRoundedRect(r, 7, 7);
-
     if (m_showBranch) {
 	// write branch name
         paint->save();
@@ -433,6 +422,21 @@
         paint->restore();
     }
 
+    QStringList bookmarks = m_changeset->bookmarks();
+    if (!bookmarks.empty()) {
+        QString bmText = bookmarks.join(" ").trimmed();
+        int bw = fm.width(bmText);
+        paint->fillRect(QRectF(x0 + width - fh*2 - bw, -fh - 4,
+                               bw + 4, fh - 1),
+                        QBrush(Qt::yellow));
+        paint->drawText(x0 + width - fh*2 - bw + 2,
+                        -fh + fm.ascent() - 4, bmText);
+    }
+
+    paint->setPen(QPen(branchColour, 2));
+    paint->setBrush(Qt::NoBrush);
+    paint->drawRoundedRect(r, 7, 7);
+
     if (m_current && showProperLines) {
         paint->setRenderHint(QPainter::SmoothPixmapTransform, true);
         int starSize = fh * 1.5;
--- a/src/changesetitem.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/changesetitem.h	Wed Nov 09 13:04:00 2011 +0000
@@ -65,8 +65,6 @@
     bool showBranch() const { return m_showBranch; }
     void setShowBranch(bool s) { m_showBranch = s; }
 
-    void setBookmarks(QStringList b) { m_bookmarks = b; }
-
 signals:
     void detailShown();
     void detailHidden();
@@ -112,7 +110,6 @@
     bool m_current;
     bool m_closing;
     bool m_new;
-    QStringList m_bookmarks;
 
     QMap<QAction *, QString> m_parentDiffActions;
     QMap<QAction *, QString> m_summaryActions;
--- a/src/hgaction.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/hgaction.h	Wed Nov 09 13:04:00 2011 +0000
@@ -59,8 +59,7 @@
     ACT_NEW_BRANCH,
     ACT_HG_IGNORE,
     ACT_COPY_FILE,
-    ACT_RENAME_FILE,
-    ACT_QUERY_BOOKMARKS
+    ACT_RENAME_FILE
 };
 
 struct HgAction
@@ -98,7 +97,6 @@
         case ACT_QUERY_HEADS_ACTIVE:
         case ACT_QUERY_PARENTS:
         case ACT_LOG_INCREMENTAL:
-        case ACT_QUERY_BOOKMARKS:
             return true;
         default:
             return false;
--- a/src/hgtabwidget.cpp	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/hgtabwidget.cpp	Wed Nov 09 13:04:00 2011 +0000
@@ -144,11 +144,6 @@
     m_historyWidget->setClosedHeadIds(closed);
 }
 
-void HgTabWidget::setBookmarks(QHash<QString, QStringList> bmarks)
-{
-    m_historyWidget->setBookmarks(bmarks);
-}
-
 void HgTabWidget::updateFileStates()
 {
     m_fileStatusWidget->updateWidgets();
--- a/src/hgtabwidget.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/hgtabwidget.h	Wed Nov 09 13:04:00 2011 +0000
@@ -50,8 +50,6 @@
     void setCurrent(QStringList ids, QString branch);
     void setClosedHeadIds(QSet<QString> ids);
 
-    void setBookmarks(QHash<QString, QStringList> bmarks);
-
     void setHaveMerge(bool);
 
     void updateFileStates();
--- a/src/historywidget.cpp	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/historywidget.cpp	Wed Nov 09 13:04:00 2011 +0000
@@ -104,11 +104,6 @@
     m_refreshNeeded = true;
 }
 
-void HistoryWidget::setBookmarks(QHash<QString, QStringList> bookmarks)
-{
-    m_bookmarks = bookmarks;
-}
-
 void HistoryWidget::setClosedHeadIds(QSet<QString> closed)
 {
     if (closed == m_closedIds) return;
@@ -290,12 +285,6 @@
             DEBUG << "id " << id << " is new" << endl;
         }
 
-        if (m_bookmarks.contains(id)) {
-            csit->setBookmarks(m_bookmarks[id]);
-        } else {
-            csit->setBookmarks(QStringList());
-        }
-
         if (csit->isCurrent() != current ||
             csit->isNew() != newid) {
             csit->setCurrent(current);
--- a/src/historywidget.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/historywidget.h	Wed Nov 09 13:04:00 2011 +0000
@@ -40,7 +40,6 @@
     void setCurrent(QStringList ids, QString branch, bool showUncommitted);
     void setShowUncommitted(bool showUncommitted);
     void setClosedHeadIds(QSet<QString> closed);
-    void setBookmarks(QHash<QString, QStringList> bmarks);
 
     void parseNewLog(QString log);
     void parseIncrementalLog(QString log);
@@ -76,7 +75,6 @@
     QString m_currentBranch;
     QSet<QString> m_newIds;
     QSet<QString> m_closedIds;
-    QHash<QString, QStringList> m_bookmarks;
     bool m_showUncommitted;
     bool m_refreshNeeded;
 
--- a/src/mainwindow.cpp	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/mainwindow.cpp	Wed Nov 09 13:04:00 2011 +0000
@@ -323,13 +323,6 @@
 */
 }
 
-void MainWindow::hgQueryBookmarks()
-{
-    QStringList params;
-    params << "bookmarks";
-    m_runner->requestAction(HgAction(ACT_QUERY_BOOKMARKS, m_workFolderPath, params));
-}
-
 void MainWindow::hgQueryHeadsActive()
 {
     QStringList params;
@@ -2202,10 +2195,6 @@
         // and some return with failure codes when something as basic
         // as the user closing the window via the wm happens
         return;
-    case ACT_QUERY_BOOKMARKS:
-        // probably just means we have an old Hg version: simply don't
-        // display bookmarks
-        return;
     case ACT_MERGE:
     case ACT_RETRY_MERGE:
         MoreInformationDialog::information
@@ -2297,26 +2286,6 @@
         m_currentBranch = output.trimmed();
         break;
 
-    case ACT_QUERY_BOOKMARKS:
-    {
-        m_bookmarks.clear();
-        QStringList outList = output.split('\n', QString::SkipEmptyParts);
-        foreach (QString line, outList) {
-            QStringList items = line.split(' ', QString::SkipEmptyParts);
-            if (items[0] == "*") {
-                if (items.size() == 3) {
-                    m_bookmarks[items[2]].push_back(items[1]);
-                }
-            } else {
-                if (items.size() == 2) {
-                    m_bookmarks[items[1]].push_back(items[0]);
-                }
-            }
-        }
-        m_hgTabs->setBookmarks(m_bookmarks);
-        break;
-    }
-
     case ACT_STAT:
         m_lastStatOutput = output;
         updateFileSystemWatcher();
@@ -2529,11 +2498,11 @@
     }
 
     // Sequence when no full log required:
-    //   paths -> branch -> stat -> bookmarks -> resolve-list -> heads ->
+    //   paths -> branch -> stat -> resolve-list -> heads ->
     //     incremental-log (only if heads changed) -> parents
     // 
     // Sequence when full log required:
-    //   paths -> branch -> stat -> bookmarks -> resolve-list -> heads ->
+    //   paths -> branch -> stat -> resolve-list -> heads ->
     //     parents -> log
     //
     // Note we want to call enableDisableActions only once, at the end
@@ -2575,10 +2544,6 @@
         break;
         
     case ACT_STAT:
-        hgQueryBookmarks();
-        break;
-
-    case ACT_QUERY_BOOKMARKS:
         hgResolveList();
         break;
         
--- a/src/mainwindow.h	Tue Nov 08 16:42:09 2011 +0000
+++ b/src/mainwindow.h	Wed Nov 09 13:04:00 2011 +0000
@@ -122,7 +122,6 @@
 
 private:
     void hgQueryBranch();
-    void hgQueryBookmarks();
     void hgQueryHeadsActive();
     void hgQueryHeads();
     void hgQueryParents();
@@ -193,7 +192,6 @@
     QString m_currentBranch;
     Changesets m_currentHeads;
     Changesets m_activeHeads;
-    QHash<QString, QStringList> m_bookmarks; // changeset id -> names, not vice versa
     QSet<QString> m_closedHeadIds;
     Changesets m_currentParents;
     int m_commitsSincePush;