eric6/Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py

changeset 7775
4a1db75550bd
parent 7360
9190402e4505
child 7923
91e843545d9a
equal deleted inserted replaced
7774:9eed155411f0 7775:4a1db75550bd
6 """ 6 """
7 Module implementing a dialog to show the output of the svn status command 7 Module implementing a dialog to show the output of the svn status command
8 process. 8 process.
9 """ 9 """
10 10
11 11 import re
12 import os 12 import os
13 13
14 from PyQt5.QtCore import QTimer, QProcess, QRegExp, Qt, pyqtSlot 14 from PyQt5.QtCore import pyqtSlot, Qt, QTimer, QProcess
15 from PyQt5.QtWidgets import ( 15 from PyQt5.QtWidgets import (
16 QWidget, QHeaderView, QLineEdit, QApplication, QMenu, QDialogButtonBox, 16 QWidget, QHeaderView, QLineEdit, QApplication, QMenu, QDialogButtonBox,
17 QTreeWidgetItem 17 QTreeWidgetItem
18 ) 18 )
19 19
194 self.uptodate = { 194 self.uptodate = {
195 ' ': self.tr('yes'), 195 ' ': self.tr('yes'),
196 '*': self.tr('no'), 196 '*': self.tr('no'),
197 } 197 }
198 198
199 self.rx_status = QRegExp( 199 self.rx_status = re.compile(
200 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') 200 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*')
201 # flags (8 or 9 anything), revision, changed rev, author, path 201 # flags (8 or 9 anything), revision, changed rev, author, path
202 self.rx_status2 = QRegExp('(.{8,9})\\s+(.+)\\s*') 202 self.rx_status2 = re.compile('(.{8,9})\\s+(.+)\\s*')
203 # flags (8 or 9 anything), path 203 # flags (8 or 9 anything), path
204 self.rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s+') 204 self.rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s+')
205 # three dashes, Changelist (translated), quote, 205 # three dashes, Changelist (translated), quote,
206 # changelist name, quote, : 206 # changelist name, quote, :
207 207
208 self.__nonverbose = True 208 self.__nonverbose = True
209 209
505 505
506 while self.process.canReadLine(): 506 while self.process.canReadLine():
507 s = str(self.process.readLine(), 507 s = str(self.process.readLine(),
508 Preferences.getSystem("IOEncoding"), 508 Preferences.getSystem("IOEncoding"),
509 'replace') 509 'replace')
510 if self.rx_status.exactMatch(s): 510 match = (
511 flags = self.rx_status.cap(1) 511 self.rx_status.fullmatch(s) or
512 rev = self.rx_status.cap(2) 512 self.rx_status2.fullmatch(s) or
513 change = self.rx_status.cap(3) 513 self.rx_changelist.fullmatch(s)
514 author = self.rx_status.cap(4) 514 )
515 path = self.rx_status.cap(5).strip() 515 if match.re is self.rx_status:
516 flags = match.group(1)
517 rev = match.group(2)
518 change = match.group(3)
519 author = match.group(4)
520 path = match.group(5).strip()
516 521
517 self.__generateItem(flags[0], flags[1], flags[2], flags[3], 522 self.__generateItem(flags[0], flags[1], flags[2], flags[3],
518 flags[4], flags[5], flags[-1], rev, 523 flags[4], flags[5], flags[-1], rev,
519 change, author, path) 524 change, author, path)
520 elif self.rx_status2.exactMatch(s): 525 elif match.re is self.rx_status2:
521 flags = self.rx_status2.cap(1) 526 flags = match.group(1)
522 path = self.rx_status2.cap(2).strip() 527 path = match.group(2).strip()
523 528
524 if flags[-1] in self.uptodate: 529 if flags[-1] in self.uptodate:
525 self.__generateItem(flags[0], flags[1], flags[2], 530 self.__generateItem(flags[0], flags[1], flags[2],
526 flags[3], flags[4], flags[5], 531 flags[3], flags[4], flags[5],
527 flags[-1], "", "", "", path) 532 flags[-1], "", "", "", path)
528 elif self.rx_changelist.exactMatch(s): 533 elif match.re is self.rx_changelist:
529 self.currentChangelist = self.rx_changelist.cap(1) 534 self.currentChangelist = match.group(1)
530 self.changelistFound = True 535 self.changelistFound = True
531 536
532 def __readStderr(self): 537 def __readStderr(self):
533 """ 538 """
534 Private slot to handle the readyReadStandardError signal. 539 Private slot to handle the readyReadStandardError signal.

eric ide

mercurial