diff mainwindow.cpp @ 74:10eb97683aa9

* Show branch names even for changes with children, if those children are on a different branch * Pick up remote repo path from local repo via hg paths * Some work towards breaking down files into various groups based on status * Add /usr/local/bin to path for hg (temporary hack I hope)
author Chris Cannam
date Fri, 19 Nov 2010 14:54:19 +0000
parents a773c6e7b301
children d575a8f76a53
line wrap: on
line diff
--- a/mainwindow.cpp	Thu Nov 18 18:08:18 2010 +0000
+++ b/mainwindow.cpp	Fri Nov 19 14:54:19 2010 +0000
@@ -35,6 +35,7 @@
 #include "startupdialog.h"
 #include "colourset.h"
 #include "debug.h"
+#include "logparser.h"
 
 
 MainWindow::MainWindow()
@@ -83,7 +84,7 @@
         open();
     }
 
-    hgStat();
+    hgPaths();
 }
 
 
@@ -148,6 +149,17 @@
     }
 }
 
+void MainWindow::hgPaths()
+{
+    if (runningAction == ACT_NONE)
+    {
+        QStringList params;
+        params << "paths";
+        runner -> startHgCommand(workFolderPath, params);
+        runningAction = ACT_PATHS;
+    }
+}
+
 void MainWindow::hgHeads()
 {
     if (runningAction == ACT_NONE)
@@ -739,7 +751,7 @@
         
         hgExp->clearLists();
         enableDisableActions();
-        hgStat();
+        hgPaths();
     }
 
     delete d;
@@ -981,6 +993,10 @@
 void MainWindow::commandFailed()
 {
     DEBUG << "MainWindow::commandFailed" << endl;
+    runningAction = ACT_NONE;
+    runner -> hideProgBar();
+
+    //!!! N.B hg incoming returns failure even if successful, if there were no changes
 }
 
 void MainWindow::commandCompleted()
@@ -1003,8 +1019,24 @@
                 //Successful running.
                 switch(runningAction)
                 {
+                    case ACT_PATHS:
+                    {
+                        QString stdout = runner->getStdOut();
+                        DEBUG << "stdout is " << stdout << endl;
+                        LogParser lp(stdout, "=");
+                        LogList ll = lp.parse();
+                        DEBUG << ll.size() << " results" << endl;
+                        if (!ll.empty()) {
+                            remoteRepoPath = lp.parse()[0]["default"].trimmed();
+                            DEBUG << "Set remote path to " << remoteRepoPath << endl;
+                        }
+                        MultiChoiceDialog::addRecentArgument("local", workFolderPath);
+                        MultiChoiceDialog::addRecentArgument("remote", remoteRepoPath);
+                        enableDisableActions();
+                        break;
+                    }
+
                     case ACT_STAT:
-                        MultiChoiceDialog::addRecentArgument("local", workFolderPath);
                         hgExp -> updateWorkFolderFileList(runner -> getStdOut());
                         break;
 
@@ -1097,8 +1129,13 @@
             }
 
 
-            //Typical sequence goes stat -> heads -> parents -> log
-            if (runningAction == ACT_STAT)
+            //Typical sequence goes paths -> stat -> heads -> parents -> log
+            if (runningAction == ACT_PATHS)
+            {
+                runningAction = ACT_NONE;
+                hgStat();
+            }
+            else if (runningAction == ACT_STAT)
             {
                 runningAction = ACT_NONE;
                 hgHeads();
@@ -1132,7 +1169,7 @@
                 runningAction = ACT_NONE;
                 if (shouldHgStat)
                 {
-                    hgStat();
+                    hgPaths();
                 }
             }
         }
@@ -1149,8 +1186,8 @@
     connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
     connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
 
-    connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgStat()));
-    connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgStat()));
+    connect(hgStatAct, SIGNAL(triggered()), this, SLOT(hgPaths()));
+    connect(hgExp, SIGNAL(workFolderViewTypesChanged()), this, SLOT(hgPaths()));
     connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
     connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
     connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));