eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py

changeset 7775
4a1db75550bd
parent 7759
51aa6c6b66f7
child 7780
41420f82c0ac
diff -r 9eed155411f0 -r 4a1db75550bd eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py	Sat Oct 10 16:03:53 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsSubversion/subversion.py	Sun Oct 11 17:54:52 2020 +0200
@@ -13,7 +13,7 @@
 import shutil
 from urllib.parse import quote
 
-from PyQt5.QtCore import pyqtSignal, QProcess, QRegExp, QCoreApplication
+from PyQt5.QtCore import pyqtSignal, QProcess, QCoreApplication
 from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication
 
 from E5Gui.E5Application import e5App
@@ -99,9 +99,9 @@
         self.logBrowser = None
         
         # regular expression object for evaluation of the status output
-        self.rx_status1 = QRegExp(
+        self.rx_status1 = re.compile(
             '(.{8})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)')
-        self.rx_status2 = QRegExp('(.{8})\\s+(.+)\\s*')
+        self.rx_status2 = re.compile('(.{8})\\s+(.+)\\s*')
         self.statusCache = {}
         
         self.__commitData = {}
@@ -847,7 +847,7 @@
         @param noDialog flag indicating quiet operations
         @return flag indicating successfull operation (boolean)
         """
-        rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+')
+        rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+')
         opts = self.options['global'][:]
         force = '--force' in opts
         if force:
@@ -868,7 +868,7 @@
             if not target:
                 return False
         
-        if not rx_prot.exactMatch(target):
+        if rx_prot.fullmatch(target) is None:
             isDir = os.path.isdir(name)
         else:
             isDir = False
@@ -879,7 +879,7 @@
             self.addArguments(args, opts)
             if force:
                 args.append('--force')
-            if rx_prot.exactMatch(target):
+            if rx_prot.fullmatch(target) is not None:
                 args.append('--message')
                 args.append('Moving {0} to {1}'.format(name, target))
                 target = self.__svnURL(target)
@@ -895,7 +895,7 @@
                 if res:
                     dia.exec()
                     res = dia.normalExit()
-            if res and not rx_prot.exactMatch(target):
+            if res and rx_prot.fullmatch(target) is None:
                 if target.startswith(project.getProjectPath()):
                     if isDir:
                         project.moveDirectory(name, target)
@@ -992,8 +992,9 @@
             return
         
         if self.otherData["standardLayout"]:
-            rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
-            if not rx_base.exactMatch(reposURL):
+            rx_base = re.compile('(.+)/(trunk|tags|branches).*')
+            match = rx_base.fullmatch(reposURL)
+            if match is None:
                 E5MessageBox.critical(
                     self.__ui,
                     self.tr("Subversion Error"),
@@ -1003,7 +1004,7 @@
                         """ be aborted"""))
                 return
             
-            reposRoot = rx_base.cap(1)
+            reposRoot = match.group(1)
             if tagOp in [1, 4]:
                 url = '{0}/tags/{1}'.format(reposRoot, quote(tag))
             elif tagOp in [2, 8]:
@@ -1114,8 +1115,9 @@
             return False
         
         if self.otherData["standardLayout"]:
-            rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
-            if not rx_base.exactMatch(reposURL):
+            rx_base = re.compile('(.+)/(trunk|tags|branches).*')
+            match = rx_base.fullmatch(reposURL)
+            if match is None:
                 E5MessageBox.critical(
                     self.__ui,
                     self.tr("Subversion Error"),
@@ -1125,7 +1127,7 @@
                         """ be aborted"""))
                 return False
             
-            reposRoot = rx_base.cap(1)
+            reposRoot = match.group(1)
             tn = tag
             if tagType == 1:
                 url = '{0}/tags/{1}'.format(reposRoot, quote(tag))
@@ -1184,7 +1186,7 @@
             self.mergeList[1].remove(urlrev2)
         self.mergeList[1].insert(0, urlrev2)
         
-        rx_rev = QRegExp('\\d+|HEAD')
+        rx_rev = re.compile('\\d+|HEAD')
         
         args = []
         args.append('merge')
@@ -1194,7 +1196,7 @@
             args.append('postpone')
         if force:
             args.append('--force')
-        if rx_rev.exactMatch(urlrev1):
+        if rx_rev.fullmatch(urlrev1) is not None:
             args.append('-r')
             args.append('{0}:{1}'.format(urlrev1, urlrev2))
             if not target:
@@ -1354,14 +1356,17 @@
                     output = str(process.readAllStandardOutput(), ioEncoding,
                                  'replace')
                     for line in output.splitlines():
-                        if self.rx_status1.exactMatch(line):
-                            flags = str(self.rx_status1.cap(1))
-                            path = self.rx_status1.cap(5).strip()
-                        elif self.rx_status2.exactMatch(line):
-                            flags = str(self.rx_status2.cap(1))
-                            path = self.rx_status2.cap(2).strip()
+                        match = self.rx_status1.fullmatch(line)
+                        if match is not None:
+                            flags = self.rx_status1.group(1)
+                            path = self.rx_status1.group(5).strip()
                         else:
-                            continue
+                            match = self.rx_status2.fullmatch(line)
+                            if match is not None:
+                                flags = self.rx_status2.group(1)
+                                path = self.rx_status2.group(2).strip()
+                            else:
+                                continue
                         name = os.path.normcase(path)
                         if flags[0] not in "?I":
                             if name in names:
@@ -1420,14 +1425,17 @@
                     output = str(process.readAllStandardOutput(), ioEncoding,
                                  'replace')
                     for line in output.splitlines():
-                        if self.rx_status1.exactMatch(line):
-                            flags = self.rx_status1.cap(1)
-                            path = self.rx_status1.cap(5).strip()
-                        elif self.rx_status2.exactMatch(line):
-                            flags = self.rx_status2.cap(1)
-                            path = self.rx_status2.cap(2).strip()
+                        match = self.rx_status1.fullmatch(line)
+                        if match is not None:
+                            flags = self.rx_status1.group(1)
+                            path = self.rx_status1.group(5).strip()
                         else:
-                            continue
+                            match = self.rx_status2.fullmatch(line)
+                            if match is not None:
+                                flags = self.rx_status2.group(1)
+                                path = self.rx_status2.group(2).strip()
+                            else:
+                                continue
                         name = os.path.normcase(path)
                         if flags[0] not in "?I":
                             if name in names:
@@ -1697,7 +1705,7 @@
         @return flag indicating successfull operation (boolean)
         """
         from .SvnCopyDialog import SvnCopyDialog
-        rx_prot = QRegExp('(file:|svn:|svn+ssh:|http:|https:).+')
+        rx_prot = re.compile('(file:|svn:|svn+ssh:|http:|https:).+')
         dlg = SvnCopyDialog(name)
         res = False
         if dlg.exec() == QDialog.Accepted:
@@ -1706,7 +1714,8 @@
             args = []
             args.append('copy')
             self.addArguments(args, self.options['global'])
-            if rx_prot.exactMatch(target):
+            match = rx_prot.fullmatch(target)
+            if match is not None:
                 args.append('--message')
                 args.append('Copying {0} to {1}'.format(name, target))
                 target = self.__svnURL(target)
@@ -1721,7 +1730,7 @@
                 res = dia.normalExit()
                 if (
                     res and
-                    not rx_prot.exactMatch(target) and
+                    match is None and
                     target.startswith(project.getProjectPath())
                 ):
                     if os.path.isdir(name):
@@ -2262,7 +2271,7 @@
         @return list of defined change list names (list of strings)
         """
         changelists = []
-        rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s*')
+        rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s*')
         # three dashes, Changelist (translated), quote,
         # changelist name, quote, :
         
@@ -2284,8 +2293,9 @@
                              'replace')
                 if output:
                     for line in output.splitlines():
-                        if rx_changelist.exactMatch(line):
-                            changelist = rx_changelist.cap(1)
+                        match = rx_changelist.fullmatch(line)
+                        if match is not None:
+                            changelist = match.group(1)
                             if changelist not in changelists:
                                 changelists.append(changelist)
         

eric ide

mercurial