Plugins/VcsPlugins/vcsMercurial/hg.py

changeset 2222
105f425944a2
parent 1990
7fee3661c4f9
child 2278
72d794b6fef8
--- a/Plugins/VcsPlugins/vcsMercurial/hg.py	Mon Nov 12 14:42:48 2012 +0100
+++ b/Plugins/VcsPlugins/vcsMercurial/hg.py	Mon Nov 12 17:46:11 2012 +0100
@@ -431,6 +431,37 @@
         noDialog = self.__commitData["noDialog"]
         closeBranch = self.__commitData["closeBranch"]
         
+        if not noDialog:
+            # check, if there are unsaved changes, that should be committed
+            if isinstance(name, list):
+                nameList = name
+            else:
+                nameList = [name]
+            ok = True
+            for nam in nameList:
+                # check for commit of the project
+                if os.path.isdir(nam):
+                    project = e5App().getObject("Project")
+                    if nam == project.getProjectPath():
+                        ok &= project.checkAllScriptsDirty(reportSyntaxErrors=True) and \
+                              project.checkDirty()
+                        continue
+                elif os.path.isfile(nam):
+                    editor = e5App().getObject("ViewManager").getOpenEditor(nam)
+                    if editor:
+                       ok &= editor.checkDirty()
+                if not ok:
+                    break
+            
+            if not ok:
+                res = E5MessageBox.yesNo(self.__ui,
+                    self.trUtf8("Commit Changes"),
+                    self.trUtf8("""The commit affects files, that have unsaved"""
+                                """ changes. Shall the commit be continued?"""),
+                    icon = E5MessageBox.Warning)
+                if not res:
+                    return
+        
         if self.__commitDialog is not None:
             msg = self.__commitDialog.logMessage()
             amend = self.__commitDialog.amend()

eric ide

mercurial