diff src/mainwindow.cpp @ 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
line wrap: on
line diff
--- 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;