5 |
5 |
6 """ |
6 """ |
7 Module implementing a dialog to browse the change lists. |
7 Module implementing a dialog to browse the change lists. |
8 """ |
8 """ |
9 |
9 |
10 |
10 import re |
11 import os |
11 import os |
12 |
12 |
13 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QRegExp, QTimer |
13 from PyQt5.QtCore import pyqtSlot, Qt, QProcess, QTimer |
14 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
15 QDialog, QDialogButtonBox, QListWidgetItem, QLineEdit |
15 QDialog, QDialogButtonBox, QListWidgetItem, QLineEdit |
16 ) |
16 ) |
17 |
17 |
18 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
46 self.process = QProcess() |
46 self.process = QProcess() |
47 self.process.finished.connect(self.__procFinished) |
47 self.process.finished.connect(self.__procFinished) |
48 self.process.readyReadStandardOutput.connect(self.__readStdout) |
48 self.process.readyReadStandardOutput.connect(self.__readStdout) |
49 self.process.readyReadStandardError.connect(self.__readStderr) |
49 self.process.readyReadStandardError.connect(self.__readStderr) |
50 |
50 |
51 self.rx_status = QRegExp( |
51 self.rx_status = re.compile( |
52 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') |
52 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') |
53 # flags (8 or 9 anything), revision, changed rev, author, path |
53 # flags (8 or 9 anything), revision, changed rev, author, path |
54 self.rx_status2 = QRegExp('(.{8,9})\\s+(.+)\\s*') |
54 self.rx_status2 = re.compile('(.{8,9})\\s+(.+)\\s*') |
55 # flags (8 or 9 anything), path |
55 # flags (8 or 9 anything), path |
56 self.rx_changelist = QRegExp('--- \\S+ .([\\w\\s]+).:\\s+') |
56 self.rx_changelist = re.compile('--- \\S+ .([\\w\\s]+).:\\s+') |
57 # three dashes, Changelist (translated), quote, |
57 # three dashes, Changelist (translated), quote, |
58 # changelist name, quote, : |
58 # changelist name, quote, : |
59 |
59 |
60 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
60 @pyqtSlot(QListWidgetItem, QListWidgetItem) |
61 def on_changeLists_currentItemChanged(self, current, previous): |
61 def on_changeLists_currentItemChanged(self, current, previous): |
184 |
184 |
185 while self.process.canReadLine(): |
185 while self.process.canReadLine(): |
186 s = str(self.process.readLine(), |
186 s = str(self.process.readLine(), |
187 Preferences.getSystem("IOEncoding"), |
187 Preferences.getSystem("IOEncoding"), |
188 'replace') |
188 'replace') |
189 if ( |
189 match = ( |
190 self.currentChangelist != "" and |
190 self.rx_status.fullmatch(s) or |
191 self.rx_status.exactMatch(s) |
191 self.rx_status2.fullmatch(s) |
192 ): |
192 ) |
193 file = self.rx_status.cap(5).strip() |
193 if self.currentChangelist != "" and match is not None: |
194 filename = file.replace(self.path + os.sep, "") |
194 if match.re is self.rx_status: |
195 if filename not in self.changeListsDict[ |
195 file = match.group(5).strip() |
196 self.currentChangelist |
196 filename = file.replace(self.path + os.sep, "") |
197 ]: |
197 if filename not in self.changeListsDict[ |
198 self.changeListsDict[self.currentChangelist].append( |
198 self.currentChangelist |
199 filename) |
199 ]: |
200 elif ( |
200 self.changeListsDict[ |
201 self.currentChangelist != "" and |
201 self.currentChangelist].append(filename) |
202 self.rx_status2.exactMatch(s) |
202 else: |
203 ): |
203 file = match.group(2).strip() |
204 file = self.rx_status2.cap(2).strip() |
204 filename = file.replace(self.path + os.sep, "") |
205 filename = file.replace(self.path + os.sep, "") |
205 if filename not in self.changeListsDict[ |
206 if filename not in self.changeListsDict[ |
206 self.currentChangelist |
207 self.currentChangelist |
207 ]: |
208 ]: |
208 self.changeListsDict[ |
209 self.changeListsDict[self.currentChangelist].append( |
209 self.currentChangelist].append(filename) |
210 filename) |
210 else: |
211 elif self.rx_changelist.exactMatch(s): |
211 match = self.rx_changelist.fullmatch(s) |
212 self.currentChangelist = self.rx_changelist.cap(1) |
212 if match is not None: |
213 if self.currentChangelist not in self.changeListsDict: |
213 self.currentChangelist = match.group(1) |
214 self.changeListsDict[self.currentChangelist] = [] |
214 if self.currentChangelist not in self.changeListsDict: |
|
215 self.changeListsDict[self.currentChangelist] = [] |
215 |
216 |
216 def __readStderr(self): |
217 def __readStderr(self): |
217 """ |
218 """ |
218 Private slot to handle the readyReadStandardError signal. |
219 Private slot to handle the readyReadStandardError signal. |
219 |
220 |