diff mainwindow.cpp @ 6:81a32fffee8f

0.3.9: Remove is now more powerful (can delete files of type ACM!).
author Jari Korhonen <jtkorhonen@gmail.com>
date Fri, 14 May 2010 15:29:41 +0300
parents 7189e9994a60
children 45c4ac1323b2
line wrap: on
line diff
--- a/mainwindow.cpp	Fri May 14 14:50:07 2010 +0300
+++ b/mainwindow.cpp	Fri May 14 15:29:41 2010 +0300
@@ -181,10 +181,14 @@
 
         if (!currentFile.isEmpty())
         {
-            params << "remove" << currentFile.mid(2);   //Jump over status marker characters (e.g "M ")
+            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 -> startProc(getHgBinaryName(), workFolderPath, params);
-            runningAction = ACT_REMOVE;
+                runner -> startProc(getHgBinaryName(), workFolderPath, params);
+                runningAction = ACT_REMOVE;
+            }
         }
     }
 }
@@ -568,13 +572,30 @@
 }
 
 
-bool MainWindow::isSelectedLocallyDeleted(QListWidget *workList)
+bool MainWindow::isSelectedDeletable(QListWidget *workList)
 {
     QList<QListWidgetItem *> selList = workList -> selectedItems();
     if (selList.count() == 1)
     {
-        if (selList.at(0)->text().mid(0, 1) == "!")
+        QString tmp = selList.at(0)->text().mid(0, 1);
+        if (tmp == "A")
         {
+            //scheduled to be added, ok to remove (won't go to repo)
+            return true;
+        }
+        else if (tmp == "C")
+        {
+            //Tracked but unchanged, ok to remove
+            return true;
+        }
+        else if (tmp == "M")
+        {
+            //locally modified, ok to remove from repo
+            return true;
+        }
+        else if (tmp == "!")
+        {
+            //locally deleted, ok to remove from repo
             return true;
         }
     }
@@ -922,7 +943,7 @@
                 hgAddAct -> setEnabled(false);
             }
 
-            if (!isSelectedLocallyDeleted(hgExp -> workFolderFileList))
+            if (!isSelectedDeletable(hgExp -> workFolderFileList))
             {
                 hgRemoveAct -> setEnabled(false);
             }