17 from PyQt6.QtWidgets import ( |
17 from PyQt6.QtWidgets import ( |
18 QWidget, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, QLineEdit, |
18 QWidget, QDialogButtonBox, QMenu, QHeaderView, QTreeWidgetItem, QLineEdit, |
19 QInputDialog |
19 QInputDialog |
20 ) |
20 ) |
21 |
21 |
22 from E5Gui.E5Application import e5App |
22 from E5Gui.EricApplication import ericApp |
23 from E5Gui import E5MessageBox |
23 from E5Gui import EricMessageBox |
24 |
24 |
25 from Globals import strToQByteArray |
25 from Globals import strToQByteArray |
26 |
26 |
27 from .Ui_GitStatusDialog import Ui_GitStatusDialog |
27 from .Ui_GitStatusDialog import Ui_GitStatusDialog |
28 |
28 |
410 self.process.start('git', args) |
410 self.process.start('git', args) |
411 procStarted = self.process.waitForStarted(5000) |
411 procStarted = self.process.waitForStarted(5000) |
412 if not procStarted: |
412 if not procStarted: |
413 self.inputGroup.setEnabled(False) |
413 self.inputGroup.setEnabled(False) |
414 self.inputGroup.hide() |
414 self.inputGroup.hide() |
415 E5MessageBox.critical( |
415 EricMessageBox.critical( |
416 self, |
416 self, |
417 self.tr('Process Generation Error'), |
417 self.tr('Process Generation Error'), |
418 self.tr( |
418 self.tr( |
419 'The process {0} could not be started. ' |
419 'The process {0} could not be started. ' |
420 'Ensure, that it is in the search path.' |
420 'Ensure, that it is in the search path.' |
663 @param amend flag indicating to perform an amend operation (boolean) |
663 @param amend flag indicating to perform an amend operation (boolean) |
664 """ |
664 """ |
665 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
665 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
666 for itm in self.__getCommitableItems()] |
666 for itm in self.__getCommitableItems()] |
667 if not names: |
667 if not names: |
668 E5MessageBox.information( |
668 EricMessageBox.information( |
669 self, |
669 self, |
670 self.tr("Commit"), |
670 self.tr("Commit"), |
671 self.tr("""There are no entries selected to be""" |
671 self.tr("""There are no entries selected to be""" |
672 """ committed.""")) |
672 """ committed.""")) |
673 return |
673 return |
674 |
674 |
675 if Preferences.getVCS("AutoSaveFiles"): |
675 if Preferences.getVCS("AutoSaveFiles"): |
676 vm = e5App().getObject("ViewManager") |
676 vm = ericApp().getObject("ViewManager") |
677 for name in names: |
677 for name in names: |
678 vm.saveEditor(name) |
678 vm.saveEditor(name) |
679 self.vcs.vcsCommit(names, commitAll=False, amend=amend) |
679 self.vcs.vcsCommit(names, commitAll=False, amend=amend) |
680 # staged changes |
680 # staged changes |
681 |
681 |
704 Private slot to handle the Add context menu entry. |
704 Private slot to handle the Add context menu entry. |
705 """ |
705 """ |
706 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
706 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
707 for itm in self.__getUnversionedItems()] |
707 for itm in self.__getUnversionedItems()] |
708 if not names: |
708 if not names: |
709 E5MessageBox.information( |
709 EricMessageBox.information( |
710 self, |
710 self, |
711 self.tr("Add"), |
711 self.tr("Add"), |
712 self.tr("""There are no unversioned entries""" |
712 self.tr("""There are no unversioned entries""" |
713 """ available/selected.""")) |
713 """ available/selected.""")) |
714 return |
714 return |
715 |
715 |
716 self.vcs.vcsAdd(names) |
716 self.vcs.vcsAdd(names) |
717 self.on_refreshButton_clicked() |
717 self.on_refreshButton_clicked() |
718 |
718 |
719 project = e5App().getObject("Project") |
719 project = ericApp().getObject("Project") |
720 for name in names: |
720 for name in names: |
721 project.getModel().updateVCSStatus(name) |
721 project.getModel().updateVCSStatus(name) |
722 self.vcs.checkVCSStatus() |
722 self.vcs.checkVCSStatus() |
723 |
723 |
724 def __stage(self): |
724 def __stage(self): |
726 Private slot to handle the Stage context menu entry. |
726 Private slot to handle the Stage context menu entry. |
727 """ |
727 """ |
728 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
728 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
729 for itm in self.__getStageableItems()] |
729 for itm in self.__getStageableItems()] |
730 if not names: |
730 if not names: |
731 E5MessageBox.information( |
731 EricMessageBox.information( |
732 self, |
732 self, |
733 self.tr("Stage"), |
733 self.tr("Stage"), |
734 self.tr("""There are no stageable entries""" |
734 self.tr("""There are no stageable entries""" |
735 """ available/selected.""")) |
735 """ available/selected.""")) |
736 return |
736 return |
737 |
737 |
738 self.vcs.vcsAdd(names) |
738 self.vcs.vcsAdd(names) |
739 self.on_refreshButton_clicked() |
739 self.on_refreshButton_clicked() |
740 |
740 |
741 project = e5App().getObject("Project") |
741 project = ericApp().getObject("Project") |
742 for name in names: |
742 for name in names: |
743 project.getModel().updateVCSStatus(name) |
743 project.getModel().updateVCSStatus(name) |
744 self.vcs.checkVCSStatus() |
744 self.vcs.checkVCSStatus() |
745 |
745 |
746 def __unstage(self): |
746 def __unstage(self): |
748 Private slot to handle the Unstage context menu entry. |
748 Private slot to handle the Unstage context menu entry. |
749 """ |
749 """ |
750 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
750 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
751 for itm in self.__getUnstageableItems()] |
751 for itm in self.__getUnstageableItems()] |
752 if not names: |
752 if not names: |
753 E5MessageBox.information( |
753 EricMessageBox.information( |
754 self, |
754 self, |
755 self.tr("Unstage"), |
755 self.tr("Unstage"), |
756 self.tr("""There are no unstageable entries""" |
756 self.tr("""There are no unstageable entries""" |
757 """ available/selected.""")) |
757 """ available/selected.""")) |
758 return |
758 return |
759 |
759 |
760 self.vcs.gitUnstage(names) |
760 self.vcs.gitUnstage(names) |
761 self.on_refreshButton_clicked() |
761 self.on_refreshButton_clicked() |
762 |
762 |
763 project = e5App().getObject("Project") |
763 project = ericApp().getObject("Project") |
764 for name in names: |
764 for name in names: |
765 project.getModel().updateVCSStatus(name) |
765 project.getModel().updateVCSStatus(name) |
766 self.vcs.checkVCSStatus() |
766 self.vcs.checkVCSStatus() |
767 |
767 |
768 def __forget(self): |
768 def __forget(self): |
770 Private slot to handle the Forget Missing context menu entry. |
770 Private slot to handle the Forget Missing context menu entry. |
771 """ |
771 """ |
772 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
772 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
773 for itm in self.__getMissingItems()] |
773 for itm in self.__getMissingItems()] |
774 if not names: |
774 if not names: |
775 E5MessageBox.information( |
775 EricMessageBox.information( |
776 self, |
776 self, |
777 self.tr("Forget Missing"), |
777 self.tr("Forget Missing"), |
778 self.tr("""There are no missing entries""" |
778 self.tr("""There are no missing entries""" |
779 """ available/selected.""")) |
779 """ available/selected.""")) |
780 return |
780 return |
787 Private slot to handle the Revert context menu entry. |
787 Private slot to handle the Revert context menu entry. |
788 """ |
788 """ |
789 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
789 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
790 for itm in self.__getStageableItems()] |
790 for itm in self.__getStageableItems()] |
791 if not names: |
791 if not names: |
792 E5MessageBox.information( |
792 EricMessageBox.information( |
793 self, |
793 self, |
794 self.tr("Revert"), |
794 self.tr("Revert"), |
795 self.tr("""There are no uncommitted, unstaged changes""" |
795 self.tr("""There are no uncommitted, unstaged changes""" |
796 """ available/selected.""")) |
796 """ available/selected.""")) |
797 return |
797 return |
799 self.vcs.gitRevert(names) |
799 self.vcs.gitRevert(names) |
800 self.raise_() |
800 self.raise_() |
801 self.activateWindow() |
801 self.activateWindow() |
802 self.on_refreshButton_clicked() |
802 self.on_refreshButton_clicked() |
803 |
803 |
804 project = e5App().getObject("Project") |
804 project = ericApp().getObject("Project") |
805 for name in names: |
805 for name in names: |
806 project.getModel().updateVCSStatus(name) |
806 project.getModel().updateVCSStatus(name) |
807 self.vcs.checkVCSStatus() |
807 self.vcs.checkVCSStatus() |
808 |
808 |
809 def __restoreMissing(self): |
809 def __restoreMissing(self): |
811 Private slot to handle the Restore Missing context menu entry. |
811 Private slot to handle the Restore Missing context menu entry. |
812 """ |
812 """ |
813 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
813 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
814 for itm in self.__getMissingItems()] |
814 for itm in self.__getMissingItems()] |
815 if not names: |
815 if not names: |
816 E5MessageBox.information( |
816 EricMessageBox.information( |
817 self, |
817 self, |
818 self.tr("Restore Missing"), |
818 self.tr("Restore Missing"), |
819 self.tr("""There are no missing entries""" |
819 self.tr("""There are no missing entries""" |
820 """ available/selected.""")) |
820 """ available/selected.""")) |
821 return |
821 return |
829 Private slot to handle the Edit file context menu entry. |
829 Private slot to handle the Edit file context menu entry. |
830 """ |
830 """ |
831 itm = self.__getConflictingItems()[0] |
831 itm = self.__getConflictingItems()[0] |
832 filename = os.path.join(self.__repodir, itm.text(self.__pathColumn)) |
832 filename = os.path.join(self.__repodir, itm.text(self.__pathColumn)) |
833 if Utilities.MimeTypes.isTextFile(filename): |
833 if Utilities.MimeTypes.isTextFile(filename): |
834 e5App().getObject("ViewManager").getEditor(filename) |
834 ericApp().getObject("ViewManager").getEditor(filename) |
835 |
835 |
836 def __diff(self): |
836 def __diff(self): |
837 """ |
837 """ |
838 Private slot to handle the Diff context menu entry. |
838 Private slot to handle the Diff context menu entry. |
839 """ |
839 """ |
840 namesW = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
840 namesW = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
841 for itm in self.__getStageableItems()] |
841 for itm in self.__getStageableItems()] |
842 namesS = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
842 namesS = [os.path.join(self.dname, itm.text(self.__pathColumn)) |
843 for itm in self.__getUnstageableItems()] |
843 for itm in self.__getUnstageableItems()] |
844 if not namesW and not namesS: |
844 if not namesW and not namesS: |
845 E5MessageBox.information( |
845 EricMessageBox.information( |
846 self, |
846 self, |
847 self.tr("Differences"), |
847 self.tr("Differences"), |
848 self.tr("""There are no uncommitted changes""" |
848 self.tr("""There are no uncommitted changes""" |
849 """ available/selected.""")) |
849 """ available/selected.""")) |
850 return |
850 return |
1213 title = ( |
1213 title = ( |
1214 self.tr("Revert selected lines") |
1214 self.tr("Revert selected lines") |
1215 if cursor.hasSelection() else |
1215 if cursor.hasSelection() else |
1216 self.tr("Revert hunk") |
1216 self.tr("Revert hunk") |
1217 ) |
1217 ) |
1218 res = E5MessageBox.yesNo( |
1218 res = EricMessageBox.yesNo( |
1219 self, |
1219 self, |
1220 title, |
1220 title, |
1221 self.tr("""Are you sure you want to revert the selected""" |
1221 self.tr("""Are you sure you want to revert the selected""" |
1222 """ changes?""")) |
1222 """ changes?""")) |
1223 if res: |
1223 if res: |