5 |
5 |
6 """ |
6 """ |
7 Module implementing the version control systems interface to Subversion. |
7 Module implementing the version control systems interface to Subversion. |
8 """ |
8 """ |
9 |
9 |
10 |
10 import re |
11 import os |
11 import os |
12 import shutil |
12 import shutil |
13 import time |
13 import time |
14 from urllib.parse import quote |
14 from urllib.parse import quote |
15 |
15 |
16 from PyQt5.QtCore import ( |
16 from PyQt5.QtCore import pyqtSignal, Qt, QDateTime, QCoreApplication |
17 pyqtSignal, Qt, QRegExp, QDateTime, QCoreApplication |
|
18 ) |
|
19 from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication |
17 from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication |
20 |
18 |
21 from E5Gui.E5Application import e5App |
19 from E5Gui.E5Application import e5App |
22 from E5Gui import E5MessageBox |
20 from E5Gui import E5MessageBox |
23 |
21 |
916 @param project reference to the project object |
914 @param project reference to the project object |
917 @param target new name of the file/directory (string) |
915 @param target new name of the file/directory (string) |
918 @param noDialog flag indicating quiet operations |
916 @param noDialog flag indicating quiet operations |
919 @return flag indicating successfull operation (boolean) |
917 @return flag indicating successfull operation (boolean) |
920 """ |
918 """ |
921 rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') |
919 rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') |
922 opts = self.options['global'] |
920 opts = self.options['global'] |
923 res = False |
921 res = False |
924 |
922 |
925 if noDialog: |
923 if noDialog: |
926 if target is None: |
924 if target is None: |
934 if accepted: |
932 if accepted: |
935 target, force = dlg.getData() |
933 target, force = dlg.getData() |
936 if not target: |
934 if not target: |
937 return False |
935 return False |
938 |
936 |
939 if not rx_prot.exactMatch(target): |
937 if rx_prot.fullmatch(target) is None: |
940 isDir = os.path.isdir(name) |
938 isDir = os.path.isdir(name) |
941 else: |
939 else: |
942 isDir = False |
940 isDir = False |
943 |
941 |
944 if accepted: |
942 if accepted: |
945 client = self.getClient() |
943 client = self.getClient() |
946 if rx_prot.exactMatch(target): |
944 if rx_prot.fullmatch(target) is not None: |
947 target = self.__svnURL(target) |
945 target = self.__svnURL(target) |
948 log = "Moving {0} to {1}".format(name, target) |
946 log = "Moving {0} to {1}".format(name, target) |
949 else: |
947 else: |
950 log = "" |
948 log = "" |
951 target = target |
949 target = target |
967 if not noDialog: |
965 if not noDialog: |
968 dlg.showError(e.args[0]) |
966 dlg.showError(e.args[0]) |
969 if not noDialog: |
967 if not noDialog: |
970 dlg.finish() |
968 dlg.finish() |
971 dlg.exec() |
969 dlg.exec() |
972 if res and not rx_prot.exactMatch(target): |
970 if res and rx_prot.fullmatch(target) is None: |
973 if target.startswith(project.getProjectPath()): |
971 if target.startswith(project.getProjectPath()): |
974 if isDir: |
972 if isDir: |
975 project.moveDirectory(name, target) |
973 project.moveDirectory(name, target) |
976 else: |
974 else: |
977 project.renameFileInPdata(name, target) |
975 project.renameFileInPdata(name, target) |
1065 self.allTagsBranchesList.insert(0, tag) |
1063 self.allTagsBranchesList.insert(0, tag) |
1066 else: |
1064 else: |
1067 return |
1065 return |
1068 |
1066 |
1069 if self.otherData["standardLayout"]: |
1067 if self.otherData["standardLayout"]: |
1070 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') |
1068 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
1071 if not rx_base.exactMatch(reposURL): |
1069 |
|
1070 match = rx_base.fullmatch(reposURL) |
|
1071 if match is None: |
1072 E5MessageBox.critical( |
1072 E5MessageBox.critical( |
1073 self.__ui, |
1073 self.__ui, |
1074 self.tr("Subversion Error"), |
1074 self.tr("Subversion Error"), |
1075 self.tr( |
1075 self.tr( |
1076 """The URL of the project repository has an""" |
1076 """The URL of the project repository has an""" |
1077 """ invalid format. The tag operation will""" |
1077 """ invalid format. The tag operation will""" |
1078 """ be aborted""")) |
1078 """ be aborted""")) |
1079 return |
1079 return |
1080 |
1080 |
1081 reposRoot = rx_base.cap(1) |
1081 reposRoot = match.group(1) |
1082 if tagOp in [1, 4]: |
1082 if tagOp in [1, 4]: |
1083 url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) |
1083 url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) |
1084 elif tagOp in [2, 8]: |
1084 elif tagOp in [2, 8]: |
1085 url = '{0}/branches/{1}'.format(reposRoot, quote(tag)) |
1085 url = '{0}/branches/{1}'.format(reposRoot, quote(tag)) |
1086 else: |
1086 else: |
1205 self.allTagsBranchesList.insert(0, tag) |
1205 self.allTagsBranchesList.insert(0, tag) |
1206 else: |
1206 else: |
1207 return False |
1207 return False |
1208 |
1208 |
1209 if self.otherData["standardLayout"]: |
1209 if self.otherData["standardLayout"]: |
1210 rx_base = QRegExp('(.+)/(trunk|tags|branches).*') |
1210 rx_base = re.compile('(.+)/(trunk|tags|branches).*') |
1211 if not rx_base.exactMatch(reposURL): |
1211 match = rx_base.fullmatch(reposURL) |
|
1212 if match is None: |
1212 E5MessageBox.critical( |
1213 E5MessageBox.critical( |
1213 self.__ui, |
1214 self.__ui, |
1214 self.tr("Subversion Error"), |
1215 self.tr("Subversion Error"), |
1215 self.tr( |
1216 self.tr( |
1216 """The URL of the project repository has an""" |
1217 """The URL of the project repository has an""" |
1217 """ invalid format. The switch operation will""" |
1218 """ invalid format. The switch operation will""" |
1218 """ be aborted""")) |
1219 """ be aborted""")) |
1219 return False |
1220 return False |
1220 |
1221 |
1221 reposRoot = rx_base.cap(1) |
1222 reposRoot = match.group(1) |
1222 tn = tag |
1223 tn = tag |
1223 if tagType == 1: |
1224 if tagType == 1: |
1224 url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) |
1225 url = '{0}/tags/{1}'.format(reposRoot, quote(tag)) |
1225 elif tagType == 2: |
1226 elif tagType == 2: |
1226 url = '{0}/branches/{1}'.format(reposRoot, quote(tag)) |
1227 url = '{0}/branches/{1}'.format(reposRoot, quote(tag)) |
1271 self.mergeList[0].insert(0, urlrev1) |
1272 self.mergeList[0].insert(0, urlrev1) |
1272 if urlrev2 in self.mergeList[1]: |
1273 if urlrev2 in self.mergeList[1]: |
1273 self.mergeList[1].remove(urlrev2) |
1274 self.mergeList[1].remove(urlrev2) |
1274 self.mergeList[1].insert(0, urlrev2) |
1275 self.mergeList[1].insert(0, urlrev2) |
1275 |
1276 |
1276 rx_rev = QRegExp('\\d+|HEAD|head') |
1277 rx_rev = re.compile('\\d+|HEAD|head') |
1277 |
1278 |
1278 cwd = os.getcwd() |
1279 cwd = os.getcwd() |
1279 os.chdir(dname) |
1280 os.chdir(dname) |
1280 recurse = "--non-recursive" not in opts |
1281 recurse = "--non-recursive" not in opts |
1281 if rx_rev.exactMatch(urlrev1): |
1282 if bool(rx_rev.fullmatch(urlrev1)): |
1282 if urlrev1 in ["HEAD", "head"]: |
1283 if urlrev1 in ["HEAD", "head"]: |
1283 revision1 = pysvn.Revision(pysvn.opt_revision_kind.head) |
1284 revision1 = pysvn.Revision(pysvn.opt_revision_kind.head) |
1284 rev1 = "HEAD" |
1285 rev1 = "HEAD" |
1285 else: |
1286 else: |
1286 revision1 = pysvn.Revision( |
1287 revision1 = pysvn.Revision( |
1815 @param name file/directory name to be copied (string) |
1816 @param name file/directory name to be copied (string) |
1816 @param project reference to the project object |
1817 @param project reference to the project object |
1817 @return flag indicating successfull operation (boolean) |
1818 @return flag indicating successfull operation (boolean) |
1818 """ |
1819 """ |
1819 from .SvnCopyDialog import SvnCopyDialog |
1820 from .SvnCopyDialog import SvnCopyDialog |
1820 rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+') |
1821 rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+') |
1821 dlg = SvnCopyDialog(name) |
1822 dlg = SvnCopyDialog(name) |
1822 res = False |
1823 res = False |
1823 if dlg.exec() == QDialog.Accepted: |
1824 if dlg.exec() == QDialog.Accepted: |
1824 target, force = dlg.getData() |
1825 target, force = dlg.getData() |
1825 |
1826 |
1826 client = self.getClient() |
1827 client = self.getClient() |
1827 if rx_prot.exactMatch(target): |
1828 if bool(rx_prot.fullmatch(target)): |
1828 target = self.__svnURL(target) |
1829 target = self.__svnURL(target) |
1829 log = "Copying {0} to {1}".format(name, target) |
1830 log = "Copying {0} to {1}".format(name, target) |
1830 else: |
1831 else: |
1831 log = "" |
1832 log = "" |
1832 target = target |
1833 target = target |
1846 dlg.showError(e.args[0]) |
1847 dlg.showError(e.args[0]) |
1847 dlg.finish() |
1848 dlg.finish() |
1848 dlg.exec() |
1849 dlg.exec() |
1849 if ( |
1850 if ( |
1850 res and |
1851 res and |
1851 not rx_prot.exactMatch(target) and |
1852 not bool(rx_prot.fullmatch(target)) and |
1852 target.startswith(project.getProjectPath()) |
1853 target.startswith(project.getProjectPath()) |
1853 ): |
1854 ): |
1854 if os.path.isdir(name): |
1855 if os.path.isdir(name): |
1855 project.copyDirectory(name, target) |
1856 project.copyDirectory(name, target) |
1856 else: |
1857 else: |