# HG changeset patch
# User Chris Cannam
# Date 1294754208 0
# Node ID 011312e59e442526263021fb6352fae71ca58681
# Parent 45e6b35afc702b39ea34237732512c56282bc645
Startup fixes:
* Check that Hg works before open-or-stat, and only open-or-stat if tests successful
* Make multichoicedialog for open always reopen with the same choice as last time (vital when an open action is aborted and user has to enter details again)
* Offer to create full path to target dir for clone if parent doesn't exist
diff -r 45e6b35afc70 -r 011312e59e44 mainwindow.cpp
--- a/mainwindow.cpp Tue Jan 11 13:52:54 2011 +0000
+++ b/mainwindow.cpp Tue Jan 11 13:56:48 2011 +0000
@@ -124,10 +124,6 @@
cs->addDefaultName("default");
cs->addDefaultName(getUserInfo());
- if (workFolderPath == "") {
- open();
- }
-
hgTest();
}
@@ -973,11 +969,22 @@
tr("Open a local folder, by creating a Mercurial repository in it."),
MultiChoiceDialog::DirectoryArg);
- d->setCurrentChoice("local");
+ QSettings settings;
+ settings.beginGroup("General");
+ QString lastChoice = settings.value("lastopentype", "local").toString();
+ if (lastChoice != "local" &&
+ lastChoice != "remote" &&
+ lastChoice != "init") {
+ lastChoice = "local";
+ }
+
+ d->setCurrentChoice(lastChoice);
if (d->exec() == QDialog::Accepted) {
QString choice = d->getCurrentChoice();
+ settings.setValue("lastopentype", choice);
+
QString arg = d->getArgument().trimmed();
bool result = false;
@@ -1070,6 +1077,28 @@
return false;
}
+bool MainWindow::askAboutUnknownFolder(QString arg)
+{
+ bool result = (QMessageBox::question
+ (this, tr("Path does not exist"),
+ tr("Path does not exist: create it?
You asked to open a remote repository by cloning it to \"%1\". This folder does not exist, and neither does its parent.
Would you like to create the parent folder as well?").arg(xmlEncode(arg)),
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel)
+ == QMessageBox::Ok);
+ if (result) {
+ QDir dir(arg);
+ dir.cdUp();
+ if (!dir.mkpath(dir.absolutePath())) {
+ QMessageBox::critical
+ (this, tr("Failed to create folder"),
+ tr("Failed to create folder
Sorry, the path for the parent folder \"%1\" could not be created.").arg(dir.absolutePath()));
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
bool MainWindow::complainAboutUnknownFolder(QString arg)
{
QMessageBox::critical
@@ -1265,7 +1294,9 @@
}
if (status == FolderUnknown) {
- return complainAboutUnknownFolder(local);
+ if (!askAboutUnknownFolder(local)) {
+ return false;
+ }
}
if (status == FolderExists) {
@@ -1900,11 +1931,25 @@
switch (action) {
case ACT_TEST_HG:
- hgTestExtension();
+ {
+ QSettings settings;
+ settings.beginGroup("General");
+ if (settings.value("useextension", true).toBool()) {
+ hgTestExtension();
+ } else if (workFolderPath == "") {
+ open();
+ } else {
+ hgQueryPaths();
+ }
break;
+ }
case ACT_TEST_HG_EXT:
- hgQueryPaths();
+ if (workFolderPath == "") {
+ open();
+ } else{
+ hgQueryPaths();
+ }
break;
case ACT_QUERY_PATHS:
@@ -2053,7 +2098,7 @@
workFolderExist = false;
}
- if (!workFolderDir.exists(workFolderPath)) {
+ if (workFolderPath == "" || !workFolderDir.exists(workFolderPath)) {
localRepoActionsEnabled = false;
workFolderExist = false;
} else {
@@ -2175,7 +2220,11 @@
}
if (stateUnknown) {
- hgTabs->setState(tr("(Examining repository)"));
+ if (workFolderPath == "") {
+ hgTabs->setState(tr("No repository open"));
+ } else {
+ hgTabs->setState(tr("(Examining repository)"));
+ }
} else if (emptyRepo) {
hgTabs->setState(tr("Nothing committed to this repository yet"));
} else if (noWorkingCopy) {
diff -r 45e6b35afc70 -r 011312e59e44 mainwindow.h
--- a/mainwindow.h Tue Jan 11 13:52:54 2011 +0000
+++ b/mainwindow.h Tue Jan 11 13:56:48 2011 +0000
@@ -144,6 +144,7 @@
bool complainAboutCloneToFile(QString);
QString complainAboutCloneToExistingFolder(QString local, QString remote); // returns new location, or empty string for cancel
+ bool askAboutUnknownFolder(QString);
bool askToInitExisting(QString);
bool askToInitNew(QString);
bool askToOpenParentRepo(QString, QString);