changeset 519:000f13faa089

Bookmarks are now displayed -- but exactly like tags, so far, there's no differentiation yet
author Chris Cannam
date Tue, 08 Nov 2011 16:42:09 +0000
parents 5c846f3c9244
children a17c06f773cd
files 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 9 files changed, 80 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/changesetitem.cpp	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/changesetitem.cpp	Tue Nov 08 16:42:09 2011 +0000
@@ -407,6 +407,13 @@
         }
     }
 
+    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);
--- a/src/changesetitem.h	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/changesetitem.h	Tue Nov 08 16:42:09 2011 +0000
@@ -65,6 +65,8 @@
     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();
@@ -110,6 +112,7 @@
     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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/hgaction.h	Tue Nov 08 16:42:09 2011 +0000
@@ -59,7 +59,8 @@
     ACT_NEW_BRANCH,
     ACT_HG_IGNORE,
     ACT_COPY_FILE,
-    ACT_RENAME_FILE
+    ACT_RENAME_FILE,
+    ACT_QUERY_BOOKMARKS
 };
 
 struct HgAction
@@ -97,6 +98,7 @@
         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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/hgtabwidget.cpp	Tue Nov 08 16:42:09 2011 +0000
@@ -144,6 +144,11 @@
     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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/hgtabwidget.h	Tue Nov 08 16:42:09 2011 +0000
@@ -50,6 +50,8 @@
     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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/historywidget.cpp	Tue Nov 08 16:42:09 2011 +0000
@@ -104,6 +104,11 @@
     m_refreshNeeded = true;
 }
 
+void HistoryWidget::setBookmarks(QHash<QString, QStringList> bookmarks)
+{
+    m_bookmarks = bookmarks;
+}
+
 void HistoryWidget::setClosedHeadIds(QSet<QString> closed)
 {
     if (closed == m_closedIds) return;
@@ -285,6 +290,12 @@
             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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/historywidget.h	Tue Nov 08 16:42:09 2011 +0000
@@ -39,8 +39,8 @@
 
     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,6 +76,7 @@
     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	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/mainwindow.cpp	Tue Nov 08 16:42:09 2011 +0000
@@ -323,6 +323,13 @@
 */
 }
 
+void MainWindow::hgQueryBookmarks()
+{
+    QStringList params;
+    params << "bookmarks";
+    m_runner->requestAction(HgAction(ACT_QUERY_BOOKMARKS, m_workFolderPath, params));
+}
+
 void MainWindow::hgQueryHeadsActive()
 {
     QStringList params;
@@ -2195,6 +2202,10 @@
         // 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
@@ -2227,11 +2238,15 @@
 
 void MainWindow::commandCompleted(HgAction completedAction, QString output)
 {
+    std::cerr << "commandCompleted: " << completedAction.action << std::endl;
+
     restoreFileSystemWatcher();
     HGACTIONS action = completedAction.action;
 
     if (action == ACT_NONE) return;
 
+    output.replace("\r\n", "\n");
+
     bool headsChanged = false;
     QStringList oldHeadIds;
 
@@ -2282,6 +2297,26 @@
         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();
@@ -2436,7 +2471,6 @@
     case ACT_DIFF_SUMMARY:
     {
         // Output has log info first, diff following after a blank line
-        output.replace("\r\n", "\n");
         QStringList olist = output.split("\n\n", QString::SkipEmptyParts);
         if (olist.size() > 1) output = olist[1];
 
@@ -2495,11 +2529,12 @@
     }
 
     // Sequence when no full log required:
-    //   paths -> branch -> stat -> resolve-list -> heads ->
+    //   paths -> branch -> stat -> bookmarks -> resolve-list -> heads ->
     //     incremental-log (only if heads changed) -> parents
     // 
     // Sequence when full log required:
-    //   paths -> branch -> stat -> resolve-list -> heads -> parents -> log
+    //   paths -> branch -> stat -> bookmarks -> resolve-list -> heads ->
+    //     parents -> log
     //
     // Note we want to call enableDisableActions only once, at the end
     // of whichever sequence is in use.
@@ -2530,17 +2565,23 @@
         break;
         
     case ACT_QUERY_PATHS:
+        // NB this call is duplicated in hgQueryPaths
         hgQueryBranch();
         break;
 
     case ACT_QUERY_BRANCH:
+        // NB this call is duplicated in hgQueryBranch
         hgStat();
         break;
         
     case ACT_STAT:
+        hgQueryBookmarks();
+        break;
+
+    case ACT_QUERY_BOOKMARKS:
         hgResolveList();
         break;
-
+        
     case ACT_RESOLVE_LIST:
         hgQueryHeadsActive();
         break;
--- a/src/mainwindow.h	Thu Oct 20 15:39:46 2011 +0100
+++ b/src/mainwindow.h	Tue Nov 08 16:42:09 2011 +0000
@@ -122,6 +122,7 @@
 
 private:
     void hgQueryBranch();
+    void hgQueryBookmarks();
     void hgQueryHeadsActive();
     void hgQueryHeads();
     void hgQueryParents();
@@ -192,6 +193,7 @@
     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;