changeset 406:c567fed39559

Add ability to configure the ssh client; default to TortoisePlink on Windows
author Chris Cannam <chris.cannam@eecs.qmul.ac.uk>
date Thu, 26 May 2011 15:48:11 +0100
parents 46267ab70ef3
children b45e6cd9f1d4
files src/hgrunner.cpp src/hgrunner.h src/settingsdialog.cpp src/settingsdialog.h
diffstat 4 files changed, 67 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/hgrunner.cpp	Wed May 25 16:52:31 2011 +0100
+++ b/src/hgrunner.cpp	Thu May 26 15:48:11 2011 +0100
@@ -160,6 +160,13 @@
     return settings.value("hgbinary", "").toString();
 }
 
+QString HgRunner::getSshBinaryName()
+{
+    QSettings settings;
+    settings.beginGroup("Locations");
+    return settings.value("sshbinary", "").toString();
+}
+
 QString HgRunner::getExtensionLocation()
 {
     QSettings settings;
@@ -397,6 +404,13 @@
     if (executable == "") {
         // This is a Hg command
         executable = getHgBinaryName();
+        if (executable == "") executable = "hg";
+
+        QString ssh = getSshBinaryName();
+        if (ssh != "") {
+            params.push_front(QString("ui.ssh=\"%1\"").arg(ssh));
+            params.push_front("--config");
+        }
 
         if (action.mayBeInteractive()) {
             params.push_front("ui.interactive=true");
@@ -404,7 +418,7 @@
 
             if (settings.value("useextension", true).toBool()) {
                 QString extpath = getExtensionLocation();
-                params.push_front(QString("extensions.easyhg=%1").arg(extpath));
+                params.push_front(QString("extensions.easyhg=\"%1\"").arg(extpath));
                 params.push_front("--config");
             }
             interactive = true;
--- a/src/hgrunner.h	Wed May 25 16:52:31 2011 +0100
+++ b/src/hgrunner.h	Thu May 26 15:48:11 2011 +0100
@@ -66,8 +66,9 @@
 
     void openTerminal();
     void closeTerminal();
-
+    
     QString getHgBinaryName();
+    QString getSshBinaryName();
     QString getExtensionLocation();
 
     QString getUnbundledFileName();
--- a/src/settingsdialog.cpp	Wed May 25 16:52:31 2011 +0100
+++ b/src/settingsdialog.cpp	Thu May 26 15:48:11 2011 +0100
@@ -125,6 +125,15 @@
     pathsLayout->addWidget(browse, row++, 1);
     connect(browse, SIGNAL(clicked()), this, SLOT(mergePathBrowse()));
 
+    pathsLayout->addWidget(new QLabel(tr("SSH program (for ssh URLs):")), row, 0);
+
+    m_sshPathLabel = new QLineEdit();
+    pathsLayout->addWidget(m_sshPathLabel, row, 2);
+
+    browse = new QPushButton(tr("Browse..."));
+    pathsLayout->addWidget(browse, row++, 1);
+    connect(browse, SIGNAL(clicked()), this, SLOT(sshPathBrowse()));
+
     pathsLayout->addWidget(new QLabel(tr("External text editor:")), row, 0);
 
     m_editPathLabel = new QLineEdit();
@@ -178,6 +187,12 @@
 }
 
 void
+SettingsDialog::sshPathBrowse()
+{
+    browseFor(tr("SSH program"), m_sshPathLabel);
+}
+
+void
 SettingsDialog::editPathBrowse()
 {
     browseFor(tr("External text editor"), m_editPathLabel);
@@ -230,6 +245,7 @@
     findExtension();
     findDiffBinaryName();
     findMergeBinaryName();
+    findSshBinaryName();
     findEditorBinaryName();
 }
 
@@ -335,6 +351,34 @@
 }
 
 void
+SettingsDialog::findSshBinaryName()
+{
+    QSettings settings;
+    settings.beginGroup("Locations");
+    if (settings.contains("sshbinary")) {
+        return;
+    }
+    QString ssh;
+    QStringList bases;
+#ifdef Q_OS_WIN32
+    bases << "TortoisePlink.exe";
+#else
+    bases << "ssh";
+#endif
+    bool found = false;
+    foreach (QString base, bases) {
+        ssh = findInPath(base, m_installPath, true);
+        if (ssh != "") {
+            found = true;
+            break;
+        }
+    }
+    if (found) {
+        settings.setValue("sshbinary", ssh);
+    }
+}
+
+void
 SettingsDialog::findEditorBinaryName()
 {
     QSettings settings;
@@ -381,6 +425,7 @@
     settings.remove("hgbinary");
     settings.remove("extdiffbinary");
     settings.remove("mergebinary");
+    settings.remove("sshbinary");
     settings.remove("editorbinary");
     settings.remove("extensionpath");
     settings.endGroup();
@@ -410,6 +455,7 @@
     m_hgPathLabel->setText(settings.value("hgbinary").toString());
     m_diffPathLabel->setText(settings.value("extdiffbinary").toString());
     m_mergePathLabel->setText(settings.value("mergebinary").toString());
+    m_sshPathLabel->setText(settings.value("sshbinary").toString());
     m_editPathLabel->setText(settings.value("editorbinary").toString());
     m_extensionPathLabel->setText(settings.value("extensionpath").toString());
     settings.endGroup();
@@ -457,6 +503,7 @@
     settings.setValue("hgbinary", m_hgPathLabel->text());
     settings.setValue("extdiffbinary", m_diffPathLabel->text());
     settings.setValue("mergebinary", m_mergePathLabel->text());
+    settings.setValue("sshbinary", m_sshPathLabel->text());
     settings.setValue("editorbinary", m_editPathLabel->text());
     settings.setValue("extensionpath", m_extensionPathLabel->text());
     settings.endGroup();
--- a/src/settingsdialog.h	Wed May 25 16:52:31 2011 +0100
+++ b/src/settingsdialog.h	Thu May 26 15:48:11 2011 +0100
@@ -43,6 +43,7 @@
     void hgPathBrowse();
     void diffPathBrowse();
     void mergePathBrowse();
+    void sshPathBrowse();
     void editPathBrowse();
     void extensionPathBrowse();
 
@@ -57,6 +58,7 @@
     QLineEdit *m_hgPathLabel;
     QLineEdit *m_diffPathLabel;
     QLineEdit *m_mergePathLabel;
+    QLineEdit *m_sshPathLabel;
     QLineEdit *m_editPathLabel;
 
     QCheckBox *m_useExtension;
@@ -79,6 +81,7 @@
     static void findExtension();
     static void findDiffBinaryName();
     static void findMergeBinaryName();
+    static void findSshBinaryName();
     static void findEditorBinaryName();
 
     static QString m_installPath;