changeset 107:fdca34c989c0

* Make interactivity optional in hgrunner (makes running non-interactive, local commands a bit quicker)
author Chris Cannam
date Thu, 25 Nov 2010 20:18:10 +0000
parents 729438d70af8
children 8ae3b44c0073
files hgrunner.cpp hgrunner.h mainwindow.cpp
diffstat 3 files changed, 32 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/hgrunner.cpp	Thu Nov 25 17:54:35 2010 +0000
+++ b/hgrunner.cpp	Thu Nov 25 20:18:10 2010 +0000
@@ -226,20 +226,25 @@
     }
 }
 
-void HgRunner::startHgCommand(QString workingDir, QStringList params)
+void HgRunner::startHgCommand(QString workingDir, QStringList params, bool interactive)
 {
 #ifdef Q_OS_WIN32
     // This at least means we won't block on the non-working password prompt
     params.push_front("ui.interactive=false");
 #else
     // password prompt should work here
-    params.push_front("ui.interactive=true");
+    if (interactive) {
+        params.push_front("ui.interactive=true");
+    } else {
+        params.push_front("ui.interactive=false");
+    }
 #endif
     params.push_front("--config");
-    startCommand(getHgBinaryName(), workingDir, params);
+    startCommand(getHgBinaryName(), workingDir, params, interactive);
 }
 
-void HgRunner::startCommand(QString command, QString workingDir, QStringList params)
+void HgRunner::startCommand(QString command, QString workingDir, QStringList params,
+                            bool interactive)
 {
     m_isRunning = true;
     setRange(0, 0);
@@ -255,18 +260,22 @@
     }
 
     m_procInput = 0;
+    m_ptySlaveFilename = "";
+
 #ifndef Q_OS_WIN32
-    char name[1024];
-    if (openpty(&m_ptyMasterFd, &m_ptySlaveFd, name, NULL, NULL)) {
-        perror("openpty failed");
-    } else {
-        DEBUG << "openpty succeeded: master " << m_ptyMasterFd
-                << " slave " << m_ptySlaveFd << " filename " << name << endl;
-        m_procInput = new QFile;
-        m_procInput->open(m_ptyMasterFd, QFile::WriteOnly);
-        m_ptySlaveFilename = name;
-        m_proc->setStandardInputFile(m_ptySlaveFilename);
-        ::close(m_ptySlaveFd);
+    if (interactive) {
+        char name[1024];
+        if (openpty(&m_ptyMasterFd, &m_ptySlaveFd, name, NULL, NULL)) {
+            perror("openpty failed");
+        } else {
+            DEBUG << "openpty succeeded: master " << m_ptyMasterFd
+                    << " slave " << m_ptySlaveFd << " filename " << name << endl;
+            m_procInput = new QFile;
+            m_procInput->open(m_ptyMasterFd, QFile::WriteOnly);
+            m_ptySlaveFilename = name;
+            m_proc->setStandardInputFile(m_ptySlaveFilename);
+            ::close(m_ptySlaveFd);
+        }
     }
 #endif
 
--- a/hgrunner.h	Thu Nov 25 17:54:35 2010 +0000
+++ b/hgrunner.h	Thu Nov 25 20:18:10 2010 +0000
@@ -32,8 +32,8 @@
     HgRunner(QWidget * parent = 0);
     ~HgRunner();
 
-    void startHgCommand(QString workingDir, QStringList params);
-    void startCommand(QString command, QString workingDir, QStringList params);
+    void startHgCommand(QString workingDir, QStringList params, bool interactive = false);
+    void startCommand(QString command, QString workingDir, QStringList params, bool interactive = false);
 
     bool isCommandRunning();
     void killCurrentCommand();
--- a/mainwindow.cpp	Thu Nov 25 17:54:35 2010 +0000
+++ b/mainwindow.cpp	Thu Nov 25 20:18:10 2010 +0000
@@ -362,7 +362,7 @@
                 params << "commit" << "--message" << comment << "--user" << getUserInfo();
             }
 
-            runner -> startHgCommand(workFolderPath, params);
+            runner -> startHgCommand(workFolderPath, params, true);
             runningAction = ACT_COMMIT;
         }
     }
@@ -603,7 +603,7 @@
 
         hgTabs->setWorkFolderAndRepoNames(workFolderPath, remoteRepoPath);
 
-        runner -> startHgCommand(workFolderPath, params);
+        runner -> startHgCommand(workFolderPath, params, true);
         runningAction = ACT_CLONEFROMREMOTE;
     }
 }
@@ -632,7 +632,7 @@
 
         params << "incoming" << "--newest-first" << remoteRepoPath;
 
-        runner -> startHgCommand(workFolderPath, params);
+        runner -> startHgCommand(workFolderPath, params, true);
         runningAction = ACT_INCOMING;
     }
 }
@@ -646,7 +646,7 @@
 
         params << "pull" << remoteRepoPath;
 
-        runner -> startHgCommand(workFolderPath, params);
+        runner -> startHgCommand(workFolderPath, params, true);
         runningAction = ACT_PULL;
     }
 }
@@ -660,7 +660,7 @@
 
         params << "push" << remoteRepoPath;
 
-        runner -> startHgCommand(workFolderPath, params);
+        runner -> startHgCommand(workFolderPath, params, true);
         runningAction = ACT_PUSH;
     }
 }
@@ -1265,8 +1265,7 @@
             else if (runningAction == ACT_HEADS)
             {
                 runningAction = ACT_NONE;
-//!!!                hgParents(); // skip this, we don't currently use it
-                hgLog();
+                hgParents();
             }
             else if (runningAction == ACT_PARENTS)
             {