comparison hgrunner.cpp @ 176:a6ec8d0bdd34

* Add option whether to use extension or not, and show path for it in settings
author Chris Cannam
date Thu, 16 Dec 2010 18:00:12 +0000
parents 6def8bf3be44
children bb89bcd8986b
comparison
equal deleted inserted replaced
175:6def8bf3be44 176:a6ec8d0bdd34
62 } 62 }
63 } 63 }
64 64
65 void HgRunner::findExtension() 65 void HgRunner::findExtension()
66 { 66 {
67 QSettings settings;
68 settings.beginGroup("Locations");
69 m_extensionPath = settings.value("extensionpath", "").toString();
70 if (m_extensionPath != "") return;
67 m_extensionPath = findInPath("easyhg.py", m_myDirPath, false); 71 m_extensionPath = findInPath("easyhg.py", m_myDirPath, false);
68 if (m_extensionPath == "easyhg.py") { 72 if (m_extensionPath == "easyhg.py") {
69 if (!unbundleExtension()) { 73 if (!unbundleExtension()) {
70 m_extensionPath = ""; 74 // might have failed because the file already existed
71 } 75 if (!QFile(m_extensionPath).exists()) {
72 } 76 m_extensionPath = "";
77 }
78 }
79 }
80 settings.setValue("extensionpath", m_extensionPath);
73 } 81 }
74 82
75 bool HgRunner::unbundleExtension() 83 bool HgRunner::unbundleExtension()
76 { 84 {
77 QString bundled = ":easyhg.py"; 85 QString bundled = ":easyhg.py";
336 executable = getHgBinaryName(); 344 executable = getHgBinaryName();
337 345
338 if (action.mayBeInteractive()) { 346 if (action.mayBeInteractive()) {
339 params.push_front("ui.interactive=true"); 347 params.push_front("ui.interactive=true");
340 params.push_front("--config"); 348 params.push_front("--config");
341 params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath)); 349
342 params.push_front("--config"); 350 QSettings settings;
351 settings.beginGroup("General");
352 if (settings.value("useextension", true).toBool()) {
353 params.push_front(QString("extensions.easyhg=%1").arg(m_extensionPath));
354 params.push_front("--config");
355 }
343 interactive = true; 356 interactive = true;
344 } 357 }
345 358
346 //!!! want an option to use the mercurial_keyring extension as well 359 //!!! want an option to use the mercurial_keyring extension as well
347 } 360 }