13 from urllib.parse import quote |
13 from urllib.parse import quote |
14 |
14 |
15 from PyQt6.QtCore import pyqtSignal, QProcess, QCoreApplication |
15 from PyQt6.QtCore import pyqtSignal, QProcess, QCoreApplication |
16 from PyQt6.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication |
16 from PyQt6.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication |
17 |
17 |
18 from E5Gui.E5Application import e5App |
18 from E5Gui.EricApplication import ericApp |
19 from E5Gui import E5MessageBox |
19 from E5Gui import EricMessageBox |
20 |
20 |
21 from VCS.VersionControl import VersionControl |
21 from VCS.VersionControl import VersionControl |
22 |
22 |
23 from .SvnDialog import SvnDialog |
23 from .SvnDialog import SvnDialog |
24 from .SvnUtilities import getConfigPath, amendConfig, createDefaultConfig |
24 from .SvnUtilities import getConfigPath, amendConfig, createDefaultConfig |
211 @param addAll flag indicating to add all files to the repository |
211 @param addAll flag indicating to add all files to the repository |
212 @type bool |
212 @type bool |
213 """ |
213 """ |
214 success = self.vcsImport(vcsDataDict, project.ppath, addAll=addAll)[0] |
214 success = self.vcsImport(vcsDataDict, project.ppath, addAll=addAll)[0] |
215 if not success: |
215 if not success: |
216 E5MessageBox.critical( |
216 EricMessageBox.critical( |
217 self.__ui, |
217 self.__ui, |
218 self.tr("Create project in repository"), |
218 self.tr("Create project in repository"), |
219 self.tr( |
219 self.tr( |
220 """The project could not be created in the repository.""" |
220 """The project could not be created in the repository.""" |
221 """ Maybe the given repository doesn't exist or the""" |
221 """ Maybe the given repository doesn't exist or the""" |
235 self.vcsCommit(project.ppath, vcsDataDict["message"], True) |
235 self.vcsCommit(project.ppath, vcsDataDict["message"], True) |
236 pfn = project.pfile |
236 pfn = project.pfile |
237 if not os.path.isfile(pfn): |
237 if not os.path.isfile(pfn): |
238 pfn += "z" |
238 pfn += "z" |
239 if not os.path.isfile(pfn): |
239 if not os.path.isfile(pfn): |
240 E5MessageBox.critical( |
240 EricMessageBox.critical( |
241 self.__ui, |
241 self.__ui, |
242 self.tr("New project"), |
242 self.tr("New project"), |
243 self.tr( |
243 self.tr( |
244 """The project could not be checked out of the""" |
244 """The project could not be checked out of the""" |
245 """ repository.<br />""" |
245 """ repository.<br />""" |
491 nameList = [name] |
491 nameList = [name] |
492 ok = True |
492 ok = True |
493 for nam in nameList: |
493 for nam in nameList: |
494 # check for commit of the project |
494 # check for commit of the project |
495 if os.path.isdir(nam): |
495 if os.path.isdir(nam): |
496 project = e5App().getObject("Project") |
496 project = ericApp().getObject("Project") |
497 if nam == project.getProjectPath(): |
497 if nam == project.getProjectPath(): |
498 ok &= ( |
498 ok &= ( |
499 project.checkAllScriptsDirty( |
499 project.checkAllScriptsDirty( |
500 reportSyntaxErrors=True) and |
500 reportSyntaxErrors=True) and |
501 project.checkDirty() |
501 project.checkDirty() |
502 ) |
502 ) |
503 continue |
503 continue |
504 elif os.path.isfile(nam): |
504 elif os.path.isfile(nam): |
505 editor = e5App().getObject("ViewManager").getOpenEditor( |
505 editor = ericApp().getObject("ViewManager").getOpenEditor( |
506 nam) |
506 nam) |
507 if editor: |
507 if editor: |
508 ok &= editor.checkDirty() |
508 ok &= editor.checkDirty() |
509 if not ok: |
509 if not ok: |
510 break |
510 break |
511 |
511 |
512 if not ok: |
512 if not ok: |
513 res = E5MessageBox.yesNo( |
513 res = EricMessageBox.yesNo( |
514 self.__ui, |
514 self.__ui, |
515 self.tr("Commit Changes"), |
515 self.tr("Commit Changes"), |
516 self.tr( |
516 self.tr( |
517 """The commit affects files, that have unsaved""" |
517 """The commit affects files, that have unsaved""" |
518 """ changes. Shall the commit be continued?"""), |
518 """ changes. Shall the commit be continued?"""), |
519 icon=E5MessageBox.Warning) |
519 icon=EricMessageBox.Warning) |
520 if not res: |
520 if not res: |
521 return |
521 return |
522 |
522 |
523 if self.__commitDialog is not None: |
523 if self.__commitDialog is not None: |
524 msg = self.__commitDialog.logMessage() |
524 msg = self.__commitDialog.logMessage() |
918 @param name file/directory name to be diffed (string) |
918 @param name file/directory name to be diffed (string) |
919 """ |
919 """ |
920 names = name[:] if isinstance(name, list) else [name] |
920 names = name[:] if isinstance(name, list) else [name] |
921 for nam in names: |
921 for nam in names: |
922 if os.path.isfile(nam): |
922 if os.path.isfile(nam): |
923 editor = e5App().getObject("ViewManager").getOpenEditor(nam) |
923 editor = ericApp().getObject("ViewManager").getOpenEditor(nam) |
924 if editor and not editor.checkDirty(): |
924 if editor and not editor.checkDirty(): |
925 return |
925 return |
926 else: |
926 else: |
927 project = e5App().getObject("Project") |
927 project = ericApp().getObject("Project") |
928 if nam == project.ppath and not project.saveAllScripts(): |
928 if nam == project.ppath and not project.saveAllScripts(): |
929 return |
929 return |
930 if self.diff is None: |
930 if self.diff is None: |
931 from .SvnDiffDialog import SvnDiffDialog |
931 from .SvnDiffDialog import SvnDiffDialog |
932 self.diff = SvnDiffDialog(self) |
932 self.diff = SvnDiffDialog(self) |
959 """ |
959 """ |
960 dname, fname = self.splitPath(name) |
960 dname, fname = self.splitPath(name) |
961 |
961 |
962 reposURL = self.svnGetReposName(dname) |
962 reposURL = self.svnGetReposName(dname) |
963 if reposURL is None: |
963 if reposURL is None: |
964 E5MessageBox.critical( |
964 EricMessageBox.critical( |
965 self.__ui, |
965 self.__ui, |
966 self.tr("Subversion Error"), |
966 self.tr("Subversion Error"), |
967 self.tr( |
967 self.tr( |
968 """The URL of the project repository could not be""" |
968 """The URL of the project repository could not be""" |
969 """ retrieved from the working copy. The tag operation""" |
969 """ retrieved from the working copy. The tag operation""" |
988 |
988 |
989 if self.otherData["standardLayout"]: |
989 if self.otherData["standardLayout"]: |
990 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
990 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
991 match = rx_base.fullmatch(reposURL) |
991 match = rx_base.fullmatch(reposURL) |
992 if match is None: |
992 if match is None: |
993 E5MessageBox.critical( |
993 EricMessageBox.critical( |
994 self.__ui, |
994 self.__ui, |
995 self.tr("Subversion Error"), |
995 self.tr("Subversion Error"), |
996 self.tr( |
996 self.tr( |
997 """The URL of the project repository has an""" |
997 """The URL of the project repository has an""" |
998 """ invalid format. The tag operation will""" |
998 """ invalid format. The tag operation will""" |
1046 if os.path.isdir(name): |
1046 if os.path.isdir(name): |
1047 args.append('--recursive') |
1047 args.append('--recursive') |
1048 args.append(name) |
1048 args.append(name) |
1049 names = [name] |
1049 names = [name] |
1050 |
1050 |
1051 project = e5App().getObject("Project") |
1051 project = ericApp().getObject("Project") |
1052 names = [project.getRelativePath(nam) for nam in names] |
1052 names = [project.getRelativePath(nam) for nam in names] |
1053 if names[0]: |
1053 if names[0]: |
1054 from UI.DeleteFilesConfirmationDialog import ( |
1054 from UI.DeleteFilesConfirmationDialog import ( |
1055 DeleteFilesConfirmationDialog |
1055 DeleteFilesConfirmationDialog |
1056 ) |
1056 ) |
1060 self.tr("Do you really want to revert all changes to" |
1060 self.tr("Do you really want to revert all changes to" |
1061 " these files or directories?"), |
1061 " these files or directories?"), |
1062 names) |
1062 names) |
1063 yes = dlg.exec() == QDialog.DialogCode.Accepted |
1063 yes = dlg.exec() == QDialog.DialogCode.Accepted |
1064 else: |
1064 else: |
1065 yes = E5MessageBox.yesNo( |
1065 yes = EricMessageBox.yesNo( |
1066 None, |
1066 None, |
1067 self.tr("Revert changes"), |
1067 self.tr("Revert changes"), |
1068 self.tr("""Do you really want to revert all changes of""" |
1068 self.tr("""Do you really want to revert all changes of""" |
1069 """ the project?""")) |
1069 """ the project?""")) |
1070 if yes: |
1070 if yes: |
1083 """ |
1083 """ |
1084 dname, fname = self.splitPath(name) |
1084 dname, fname = self.splitPath(name) |
1085 |
1085 |
1086 reposURL = self.svnGetReposName(dname) |
1086 reposURL = self.svnGetReposName(dname) |
1087 if reposURL is None: |
1087 if reposURL is None: |
1088 E5MessageBox.critical( |
1088 EricMessageBox.critical( |
1089 self.__ui, |
1089 self.__ui, |
1090 self.tr("Subversion Error"), |
1090 self.tr("Subversion Error"), |
1091 self.tr( |
1091 self.tr( |
1092 """The URL of the project repository could not be""" |
1092 """The URL of the project repository could not be""" |
1093 """ retrieved from the working copy. The switch""" |
1093 """ retrieved from the working copy. The switch""" |
1112 |
1112 |
1113 if self.otherData["standardLayout"]: |
1113 if self.otherData["standardLayout"]: |
1114 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
1114 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
1115 match = rx_base.fullmatch(reposURL) |
1115 match = rx_base.fullmatch(reposURL) |
1116 if match is None: |
1116 if match is None: |
1117 E5MessageBox.critical( |
1117 EricMessageBox.critical( |
1118 self.__ui, |
1118 self.__ui, |
1119 self.tr("Subversion Error"), |
1119 self.tr("Subversion Error"), |
1120 self.tr( |
1120 self.tr( |
1121 """The URL of the project repository has an""" |
1121 """The URL of the project repository has an""" |
1122 """ invalid format. The switch operation will""" |
1122 """ invalid format. The switch operation will""" |
1759 from .SvnPropSetDialog import SvnPropSetDialog |
1759 from .SvnPropSetDialog import SvnPropSetDialog |
1760 dlg = SvnPropSetDialog() |
1760 dlg = SvnPropSetDialog() |
1761 if dlg.exec() == QDialog.DialogCode.Accepted: |
1761 if dlg.exec() == QDialog.DialogCode.Accepted: |
1762 propName, fileFlag, propValue = dlg.getData() |
1762 propName, fileFlag, propValue = dlg.getData() |
1763 if not propName: |
1763 if not propName: |
1764 E5MessageBox.critical( |
1764 EricMessageBox.critical( |
1765 self.__ui, |
1765 self.__ui, |
1766 self.tr("Subversion Set Property"), |
1766 self.tr("Subversion Set Property"), |
1767 self.tr("""You have to supply a property name.""" |
1767 self.tr("""You have to supply a property name.""" |
1768 """ Aborting.""")) |
1768 """ Aborting.""")) |
1769 return |
1769 return |
1891 @param name file/directory name to be diffed (string) |
1891 @param name file/directory name to be diffed (string) |
1892 """ |
1892 """ |
1893 names = name[:] if isinstance(name, list) else [name] |
1893 names = name[:] if isinstance(name, list) else [name] |
1894 for nam in names: |
1894 for nam in names: |
1895 if os.path.isfile(nam): |
1895 if os.path.isfile(nam): |
1896 editor = e5App().getObject("ViewManager").getOpenEditor(nam) |
1896 editor = ericApp().getObject("ViewManager").getOpenEditor(nam) |
1897 if editor and not editor.checkDirty(): |
1897 if editor and not editor.checkDirty(): |
1898 return |
1898 return |
1899 else: |
1899 else: |
1900 project = e5App().getObject("Project") |
1900 project = ericApp().getObject("Project") |
1901 if nam == project.ppath and not project.saveAllScripts(): |
1901 if nam == project.ppath and not project.saveAllScripts(): |
1902 return |
1902 return |
1903 from .SvnRevisionSelectionDialog import SvnRevisionSelectionDialog |
1903 from .SvnRevisionSelectionDialog import SvnRevisionSelectionDialog |
1904 dlg = SvnRevisionSelectionDialog() |
1904 dlg = SvnRevisionSelectionDialog() |
1905 if dlg.exec() == QDialog.DialogCode.Accepted: |
1905 if dlg.exec() == QDialog.DialogCode.Accepted: |
1924 @param name file/directory name to be diffed (string) |
1924 @param name file/directory name to be diffed (string) |
1925 """ |
1925 """ |
1926 names = name[:] if isinstance(name, list) else [name] |
1926 names = name[:] if isinstance(name, list) else [name] |
1927 for nam in names: |
1927 for nam in names: |
1928 if os.path.isfile(nam): |
1928 if os.path.isfile(nam): |
1929 editor = e5App().getObject("ViewManager").getOpenEditor(nam) |
1929 editor = ericApp().getObject("ViewManager").getOpenEditor(nam) |
1930 if editor and not editor.checkDirty(): |
1930 if editor and not editor.checkDirty(): |
1931 return |
1931 return |
1932 else: |
1932 else: |
1933 project = e5App().getObject("Project") |
1933 project = ericApp().getObject("Project") |
1934 if nam == project.ppath and not project.saveAllScripts(): |
1934 if nam == project.ppath and not project.saveAllScripts(): |
1935 return |
1935 return |
1936 |
1936 |
1937 dname = self.splitPath(names[0])[0] |
1937 dname = self.splitPath(names[0])[0] |
1938 |
1938 |
2019 else: |
2019 else: |
2020 rev1, rev2 = "", "" |
2020 rev1, rev2 = "", "" |
2021 |
2021 |
2022 output1, error = self.__svnGetFileForRevision(name, rev=rev1) |
2022 output1, error = self.__svnGetFileForRevision(name, rev=rev1) |
2023 if error: |
2023 if error: |
2024 E5MessageBox.critical( |
2024 EricMessageBox.critical( |
2025 self.__ui, |
2025 self.__ui, |
2026 self.tr("Subversion Side-by-Side Difference"), |
2026 self.tr("Subversion Side-by-Side Difference"), |
2027 error) |
2027 error) |
2028 return |
2028 return |
2029 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") |
2029 name1 = "{0} (rev. {1})".format(name, rev1 and rev1 or ".") |
2030 |
2030 |
2031 if rev2: |
2031 if rev2: |
2032 output2, error = self.__svnGetFileForRevision(name, rev=rev2) |
2032 output2, error = self.__svnGetFileForRevision(name, rev=rev2) |
2033 if error: |
2033 if error: |
2034 E5MessageBox.critical( |
2034 EricMessageBox.critical( |
2035 self.__ui, |
2035 self.__ui, |
2036 self.tr("Subversion Side-by-Side Difference"), |
2036 self.tr("Subversion Side-by-Side Difference"), |
2037 error) |
2037 error) |
2038 return |
2038 return |
2039 name2 = "{0} (rev. {1})".format(name, rev2) |
2039 name2 = "{0} (rev. {1})".format(name, rev2) |
2041 try: |
2041 try: |
2042 with open(name, "r", encoding="utf-8") as f1: |
2042 with open(name, "r", encoding="utf-8") as f1: |
2043 output2 = f1.read() |
2043 output2 = f1.read() |
2044 name2 = name |
2044 name2 = name |
2045 except OSError: |
2045 except OSError: |
2046 E5MessageBox.critical( |
2046 EricMessageBox.critical( |
2047 self.__ui, |
2047 self.__ui, |
2048 self.tr("Subversion Side-by-Side Difference"), |
2048 self.tr("Subversion Side-by-Side Difference"), |
2049 self.tr( |
2049 self.tr( |
2050 """<p>The file <b>{0}</b> could not be read.</p>""") |
2050 """<p>The file <b>{0}</b> could not be read.</p>""") |
2051 .format(name)) |
2051 .format(name)) |
2264 args = [] |
2264 args = [] |
2265 args.append("status") |
2265 args.append("status") |
2266 args.append("--non-interactive") |
2266 args.append("--non-interactive") |
2267 args.append(".") |
2267 args.append(".") |
2268 |
2268 |
2269 ppath = e5App().getObject("Project").getProjectPath() |
2269 ppath = ericApp().getObject("Project").getProjectPath() |
2270 process = QProcess() |
2270 process = QProcess() |
2271 process.setWorkingDirectory(ppath) |
2271 process.setWorkingDirectory(ppath) |
2272 process.start('svn', args) |
2272 process.start('svn', args) |
2273 procStarted = process.waitForStarted(5000) |
2273 procStarted = process.waitForStarted(5000) |
2274 if procStarted: |
2274 if procStarted: |