eric6/Plugins/VcsPlugins/vcsSubversion/SvnLogBrowserDialog.py

changeset 7775
4a1db75550bd
parent 7771
787a6b3f8c9f
child 7900
72b88fb20261
child 7924
8a96736d465e
--- a/eric6/Plugins/VcsPlugins/vcsSubversion/SvnLogBrowserDialog.py	Sat Oct 10 16:03:53 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsSubversion/SvnLogBrowserDialog.py	Sun Oct 11 17:54:52 2020 +0200
@@ -7,12 +7,10 @@
 Module implementing a dialog to browse the log history.
 """
 
-
+import re
 import os
 
-from PyQt5.QtCore import (
-    QTimer, QDate, QProcess, QRegExp, Qt, pyqtSlot, QPoint
-)
+from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QDate, QProcess, QPoint
 from PyQt5.QtWidgets import (
     QHeaderView, QLineEdit, QWidget, QApplication, QDialogButtonBox,
     QTreeWidgetItem
@@ -69,23 +67,23 @@
         self.__process.readyReadStandardOutput.connect(self.__readStdout)
         self.__process.readyReadStandardError.connect(self.__readStderr)
         
-        self.rx_sep1 = QRegExp('\\-+\\s*')
-        self.rx_sep2 = QRegExp('=+\\s*')
-        self.rx_rev1 = QRegExp(
+        self.rx_sep1 = re.compile('\\-+\\s*')
+        self.rx_sep2 = re.compile('=+\\s*')
+        self.rx_rev1 = re.compile(
             r'rev ([0-9]+):  ([^|]*) \| ([^|]*) \| ([0-9]+) .*')
         # "rev" followed by one or more decimals followed by a colon followed
         # anything up to " | " (twice) followed by one or more decimals
         # followed by anything
-        self.rx_rev2 = QRegExp(
+        self.rx_rev2 = re.compile(
             r'r([0-9]+) \| ([^|]*) \| ([^|]*) \| ([0-9]+) .*')
         # "r" followed by one or more decimals followed by " | " followed
         # anything up to " | " (twice) followed by one or more decimals
         # followed by anything
-        self.rx_flags1 = QRegExp(
+        self.rx_flags1 = re.compile(
             r"""   ([ADM])\s(.*)\s+\(\w+\s+(.*):([0-9]+)\)\s*""")
         # three blanks followed by A or D or M followed by path followed by
         # path copied from followed by copied from revision
-        self.rx_flags2 = QRegExp('   ([ADM]) (.*)\\s*')
+        self.rx_flags2 = re.compile('   ([ADM]) (.*)\\s*')
         # three blanks followed by A or D or M followed by path
         
         self.flags = {
@@ -383,37 +381,47 @@
         log = {"message": []}
         changedPaths = []
         for s in self.buf:
-            if self.rx_rev1.exactMatch(s):
-                log["revision"] = self.rx_rev.cap(1)
-                log["author"] = self.rx_rev.cap(2)
-                log["date"] = self.rx_rev.cap(3)
+            match = (
+                self.rx_rev1.fullmatch(s) or
+                self.rx_rev2.fullmatch(s) or
+                self.rx_flags1.fullmatch(s) or
+                self.rx_flags2.fullmatch(s) or
+                self.rx_sep1.fullmatch(s) or
+                self.rx_sep2.fullmatch(s)
+            )
+            if match is None:
+                if s.strip().endswith(":") or not s.strip():
+                    continue
+                else:
+                    log["message"].append(s)
+            elif match.re is self.rx_rev1:
+                log["revision"] = match.group(1)
+                log["author"] = match.group(2)
+                log["date"] = match.group(3)
                 # number of lines is ignored
-            elif self.rx_rev2.exactMatch(s):
-                log["revision"] = self.rx_rev2.cap(1)
-                log["author"] = self.rx_rev2.cap(2)
-                log["date"] = " ".join(self.rx_rev2.cap(3).split()[:2])
+            elif match.re is self.rx_rev2:
+                log["revision"] = match.group(1)
+                log["author"] = match.group(2)
+                log["date"] = " ".join(match.group(3).split()[:2])
                 # number of lines is ignored
-            elif self.rx_flags1.exactMatch(s):
+            elif match.re is self.rx_flags1:
                 changedPaths.append({
-                    "action":
-                    self.rx_flags1.cap(1).strip(),
-                    "path":
-                    self.rx_flags1.cap(2).strip(),
-                    "copyfrom_path":
-                    self.rx_flags1.cap(3).strip(),
-                    "copyfrom_revision":
-                    self.rx_flags1.cap(4).strip(),
+                    "action": match.group(1).strip(),
+                    "path": match.group(2).strip(),
+                    "copyfrom_path": match.group(3).strip(),
+                    "copyfrom_revision": match.group(4).strip(),
                 })
-            elif self.rx_flags2.exactMatch(s):
+            elif match.re is self.rx_flags2:
                 changedPaths.append({
-                    "action":
-                    self.rx_flags2.cap(1).strip(),
-                    "path":
-                    self.rx_flags2.cap(2).strip(),
+                    "action": match.group(1).strip(),
+                    "path": match.group(2).strip(),
                     "copyfrom_path": "",
                     "copyfrom_revision": "",
                 })
-            elif self.rx_sep1.exactMatch(s) or self.rx_sep2.exactMatch(s):
+            elif (
+                match.re is self.rx_sep1 or
+                match.re is self.rx_sep2
+            ):
                 if len(log) > 1:
                     self.__generateLogItem(
                         log["author"], log["date"], log["message"],
@@ -433,11 +441,6 @@
                     noEntries += 1
                     log = {"message": []}
                     changedPaths = []
-            else:
-                if s.strip().endswith(":") or not s.strip():
-                    continue
-                else:
-                    log["message"].append(s)
         
         self.__resizeColumnsLog()
         self.__resortLog()
@@ -657,18 +660,18 @@
             txt = self.fieldCombo.currentText()
             if txt == self.tr("Author"):
                 fieldIndex = 1
-                searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive)
+                searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE)
             elif txt == self.tr("Revision"):
                 fieldIndex = 0
                 txt = self.rxEdit.text()
                 if txt.startswith("^"):
-                    searchRx = QRegExp(
-                        r"^\s*{0}".format(txt[1:]), Qt.CaseInsensitive)
+                    searchRx = re.compile(
+                        r"^\s*{0}".format(txt[1:]), re.IGNORECASE)
                 else:
-                    searchRx = QRegExp(txt, Qt.CaseInsensitive)
+                    searchRx = re.compile(txt, re.IGNORECASE)
             else:
                 fieldIndex = 3
-                searchRx = QRegExp(self.rxEdit.text(), Qt.CaseInsensitive)
+                searchRx = re.compile(self.rxEdit.text(), re.IGNORECASE)
             
             currentItem = self.logTree.currentItem()
             for topIndex in range(self.logTree.topLevelItemCount()):
@@ -676,7 +679,7 @@
                 if (
                     topItem.text(2) <= to_ and
                     topItem.text(2) >= from_ and
-                    searchRx.indexIn(topItem.text(fieldIndex)) > -1
+                    searchRx.match(topItem.text(fieldIndex)) is not None
                 ):
                     topItem.setHidden(False)
                     if topItem is currentItem:

eric ide

mercurial