diff mainwindow.cpp @ 225:05255f23f2af

* Properly handle the case where the working copy is empty but the repo is not (e.g. just after convert)
author Chris Cannam
date Thu, 06 Jan 2011 11:52:23 +0000
parents 90e70a9024f3
children 5d8a5ce96163
line wrap: on
line diff
--- a/mainwindow.cpp	Wed Jan 05 20:59:48 2011 +0000
+++ b/mainwindow.cpp	Thu Jan 06 11:52:23 2011 +0000
@@ -181,7 +181,8 @@
                          "modify it under the terms of the GNU General Public License as "
                          "published by the Free Software Foundation; either version 2 of the "
                          "License, or (at your option) any later version.  See the file "
-                         "COPYING included with this distribution for more information.</p>"));
+                         "COPYING included with this distribution for more information.</p>"
+                          ));
 }
 
 void MainWindow::clearSelections()
@@ -2023,6 +2024,7 @@
     bool canUpdate = false;
     bool haveMerge = false;
     bool emptyRepo = false;
+    bool noWorkingCopy = false;
     int currentBranchHeads = 0;
 
     if (currentParents.size() == 1) {
@@ -2049,7 +2051,16 @@
             }
         }
     } else if (currentParents.size() == 0) {
-        emptyRepo = true;
+        if (currentHeads.size() == 0) {
+            // No heads -> empty repo
+            emptyRepo = true;
+        } else {
+            // Heads, but no parents -> no working copy, e.g. we have
+            // just converted this repo but haven't updated in it yet.
+            // Uncommon but confusing; probably merits a special case
+            noWorkingCopy = true;
+            canUpdate = true;
+        }
     } else {
         haveMerge = true;
         justMerged = true;
@@ -2073,6 +2084,8 @@
         hgTabs->setState(tr("(Examining repository)"));
     } else if (emptyRepo) {
         hgTabs->setState(tr("Nothing committed to this repository yet"));
+    } else if (noWorkingCopy) {
+        hgTabs->setState(tr("No working copy yet: consider updating"));
     } else if (canMerge) {
         hgTabs->setState(tr("<b>Awaiting merge</b> on %1").arg(branchText));
     } else if (!hgTabs->getAllUnresolvedFiles().empty()) {