changeset 162:910c2c5d1873

* Better handling of empty repositories; some tidying & textual fixes
author Chris Cannam
date Fri, 03 Dec 2010 14:43:32 +0000
parents 5b2046f67a56
children 5c262ac73948
files filestatuswidget.cpp hgaction.h hgrunner.cpp mainwindow.cpp mainwindow.h
diffstat 5 files changed, 16 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/filestatuswidget.cpp	Fri Dec 03 13:36:53 2010 +0000
+++ b/filestatuswidget.cpp	Fri Dec 03 14:43:32 2010 +0000
@@ -62,7 +62,7 @@
 
     ++row;
     m_noModificationsLabel = new QLabel
-        (tr("You have made no changes."));
+        (tr("You have no uncommitted changes."));
     layout->addWidget(m_noModificationsLabel, row, 1, 1, 2);
 
     m_simpleLabels[FileStates::Clean] = tr("Unmodified:");
--- a/hgaction.h	Fri Dec 03 13:36:53 2010 +0000
+++ b/hgaction.h	Fri Dec 03 14:43:32 2010 +0000
@@ -40,7 +40,6 @@
     ACT_INIT,
     ACT_COMMIT,
     ACT_ANNOTATE,
-    ACT_FILEDIFF,
     ACT_FOLDERDIFF,
     ACT_CHGSETDIFF,
     ACT_UPDATE,
@@ -92,7 +91,6 @@
 	case ACT_PUSH:
 	case ACT_PULL:
 	case ACT_CLONEFROMREMOTE:
-	case ACT_FILEDIFF:
 	case ACT_FOLDERDIFF:
 	case ACT_CHGSETDIFF:
 	case ACT_SERVE:
--- a/hgrunner.cpp	Fri Dec 03 13:36:53 2010 +0000
+++ b/hgrunner.cpp	Fri Dec 03 14:43:32 2010 +0000
@@ -330,22 +330,6 @@
         }            
 
         //!!! want an option to use the mercurial_keyring extension as well
-
-/*
-#ifdef Q_OS_WIN32
-        // This at least means we won't block on the non-working password prompt
-        params.push_front("--noninteractive");
-#else
-        // password prompt should work here
-        if (action.mayBeInteractive()) {
-            params.push_front("ui.interactive=true");
-            params.push_front("--config");
-            interactive = true;
-        } else {
-            params.push_front("--noninteractive");
-        }
-#endif
-*/
     }
 
     m_isRunning = true;
--- a/mainwindow.cpp	Fri Dec 03 13:36:53 2010 +0000
+++ b/mainwindow.cpp	Fri Dec 03 14:43:32 2010 +0000
@@ -291,22 +291,6 @@
         params << "remove" << "--after" << "--force" << "--" << files;
         runner->requestAction(HgAction(ACT_REMOVE, workFolderPath, params));
     }
-
-/*!!!
-        QString currentFile;//!!! = hgTabs -> getCurrentFileListLine();
-
-        if (!currentFile.isEmpty())
-        {
-            if (QMessageBox::Ok == QMessageBox::warning(this, "Remove file", "Really remove file " + currentFile.mid(2) + "?",
-                QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Cancel))
-            {
-                params << "remove" << "--after" << "--force" << "--" << currentFile.mid(2);   //Jump over status marker characters (e.g "M ")
-
-                runner -> startHgCommand(workFolderPath, params);
-                runningAction = ACT_REMOVE;
-            }
-        }
-        */
 }
 
 void MainWindow::hgCommit()
@@ -440,23 +424,6 @@
     diffBinaryName = diff;
 }
 
-void MainWindow::hgFileDiff()
-{
-        QStringList params;
-/*!!!
-        QString currentFile = hgTabs -> getCurrentFileListLine();
-
-        if (!currentFile.isEmpty())
-        {
-            //Diff parent file against working folder file
-            params << "kdiff3" << "--" << currentFile.mid(2);
-            runner -> startHgCommand(workFolderPath, params);
-            runningAction = ACT_FILEDIFF;
-        }
-    */
-}
-
-
 void MainWindow::hgFolderDiff()
 {
     if (diffBinaryName == "") return;
@@ -1195,8 +1162,14 @@
         // are no changes pending
         if (output.trimmed() == "") showIncoming("");
         return;
+    case ACT_QUERY_HEADS:
+        // fails if repo is empty; we don't care (if there's a genuine
+        // problem, something else will fail too).  Need to do this,
+        // otherwise empty repo state will not be reflected properly
+        // (since heads/log procedure never completes for empty repo)
+        enableDisableActions();
+        return;
     case ACT_FOLDERDIFF:
-    case ACT_FILEDIFF:
     case ACT_CHGSETDIFF:
         // external program, unlikely to be anything useful in stderr
         // and some return with failure codes when something as basic
@@ -1364,7 +1337,6 @@
         shouldHgStat = true;
         break;
 
-    case ACT_FILEDIFF:
     case ACT_FOLDERDIFF:
     case ACT_CHGSETDIFF:
     case ACT_SERVE:
@@ -1374,12 +1346,12 @@
         break;
         
     case ACT_UPDATE:
-        QMessageBox::information(this, tr("Update"), output);
+        QMessageBox::information(this, tr("Update"), tr("<qt><h3>Update successful</h3><p>%1</p>").arg(xmlEncode(output)));
         shouldHgStat = true;
         break;
         
     case ACT_MERGE:
-        QMessageBox::information(this, tr("Merge"), output);
+        QMessageBox::information(this, tr("Update"), tr("<qt><h3>Merge successful</h3><p>%1</p>").arg(xmlEncode(output)));
         shouldHgStat = true;
         justMerged = true;
         break;
@@ -1471,7 +1443,6 @@
     connect(hgRemoveAct, SIGNAL(triggered()), this, SLOT(hgRemove()));
     connect(hgAddAct, SIGNAL(triggered()), this, SLOT(hgAdd()));
     connect(hgCommitAct, SIGNAL(triggered()), this, SLOT(hgCommit()));
-    connect(hgFileDiffAct, SIGNAL(triggered()), this, SLOT(hgFileDiff()));
     connect(hgFolderDiffAct, SIGNAL(triggered()), this, SLOT(hgFolderDiff()));
 //    connect(hgChgSetDiffAct, SIGNAL(triggered()), this, SLOT(hgChgSetDiff()));
     connect(hgUpdateAct, SIGNAL(triggered()), this, SLOT(hgUpdate()));
@@ -1584,7 +1555,6 @@
 
     hgInitAct -> setEnabled((localRepoExist == false) && (workFolderExist==true));
     hgRefreshAct -> setEnabled(localRepoActionsEnabled);
-    hgFileDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
     hgFolderDiffAct -> setEnabled(localRepoActionsEnabled && haveDiff);
     hgRevertAct -> setEnabled(localRepoActionsEnabled);
     hgAddAct -> setEnabled(localRepoActionsEnabled);
@@ -1624,6 +1594,7 @@
     bool canMerge = false;
     bool canUpdate = false;
     bool haveMerge = false;
+    bool emptyRepo = false;
     int currentBranchHeads = 0;
 
     if (currentParents.size() == 1) {
@@ -1649,6 +1620,8 @@
                 DEBUG << "head id = " << h->id() << endl;
             }
         }
+    } else if (currentParents.size() == 0) {
+        emptyRepo = true;
     } else {
         haveMerge = true;
     }
@@ -1667,7 +1640,9 @@
 
     //!!! Want "merge failed" report
 
-    if (canMerge) {
+    if (emptyRepo) {
+        hgTabs->setState(tr("Nothing committed to this repository yet"));
+    } else if (canMerge) {
         hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
     } else if (haveMerge) {
         hgTabs->setState(tr("Have merged but not yet committed on %1").arg(branchText));
@@ -1716,9 +1691,6 @@
     hgPushAct->setStatusTip(tr("Push local changesets to remote repository"));
 
     //Workfolder actions
-    hgFileDiffAct   = new QAction(QIcon(":/images/diff.png"), tr("Diff"), this);
-    hgFileDiffAct->setStatusTip(tr("Filediff: View differences between selected working folder file and local repository file"));
-
     hgFolderDiffAct   = new QAction(QIcon(":/images/folderdiff.png"), tr("Diff"), this);
     hgFolderDiffAct->setStatusTip(tr("Folderdiff: View all differences between working folder files and local repository files"));
 
@@ -1835,8 +1807,6 @@
     workFolderToolBar = addToolBar(tr(WORKFOLDERMENU_TITLE));
     addToolBar(Qt::LeftToolBarArea, workFolderToolBar);
     workFolderToolBar -> setIconSize(QSize(MY_ICON_SIZE, MY_ICON_SIZE));
-//    workFolderToolBar->addSeparator();
-//    workFolderToolBar->addAction(hgFileDiffAct);
     workFolderToolBar->addAction(hgFolderDiffAct);
     workFolderToolBar->addSeparator();
     workFolderToolBar->addAction(hgRevertAct);
--- a/mainwindow.h	Fri Dec 03 13:36:53 2010 +0000
+++ b/mainwindow.h	Fri Dec 03 14:43:32 2010 +0000
@@ -74,7 +74,6 @@
     void hgRemove();
     void hgAdd();
     void hgCommit();
-    void hgFileDiff();
     void hgFolderDiff();
     void hgDiffToCurrent(QString);
     void hgDiffToParent(QString, QString);
@@ -165,7 +164,6 @@
     QAction *hgPushAct;
     QAction *hgPullAct;
     QAction *hgRefreshAct;
-    QAction *hgFileDiffAct;
     QAction *hgFolderDiffAct;
     QAction *hgChgSetDiffAct;
     QAction *hgRevertAct;