9 |
9 |
10 |
10 |
11 import pysvn |
11 import pysvn |
12 |
12 |
13 from PyQt5.QtCore import QMutexLocker, Qt, pyqtSlot |
13 from PyQt5.QtCore import QMutexLocker, Qt, pyqtSlot |
14 from PyQt5.QtGui import QCursor |
|
15 from PyQt5.QtWidgets import ( |
14 from PyQt5.QtWidgets import ( |
16 QHeaderView, QDialog, QApplication, QDialogButtonBox, QTreeWidgetItem |
15 QHeaderView, QDialog, QApplication, QDialogButtonBox, QTreeWidgetItem |
17 ) |
16 ) |
18 |
17 |
19 from E5Gui import E5MessageBox |
18 from E5Gui import E5MessageBox |
|
19 from E5Gui.E5OverrideCursor import E5OverrideCursor |
20 |
20 |
21 from .SvnUtilities import formatTime |
21 from .SvnUtilities import formatTime |
22 from .SvnDialogMixin import SvnDialogMixin |
22 from .SvnDialogMixin import SvnDialogMixin |
23 |
23 |
24 from .Ui_SvnRepoBrowserDialog import Ui_SvnRepoBrowserDialog |
24 from .Ui_SvnRepoBrowserDialog import Ui_SvnRepoBrowserDialog |
148 |
148 |
149 @param url the repository URL to browser (string) |
149 @param url the repository URL to browser (string) |
150 @param parent reference to the item, the data should be appended to |
150 @param parent reference to the item, the data should be appended to |
151 (QTreeWidget or QTreeWidgetItem) |
151 (QTreeWidget or QTreeWidgetItem) |
152 """ |
152 """ |
153 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) |
|
154 QApplication.processEvents() |
|
155 |
|
156 if parent is None: |
153 if parent is None: |
157 parent = self.repoTree |
154 parent = self.repoTree |
158 |
155 |
159 locker = QMutexLocker(self.vcs.vcsExecutionMutex) |
156 with E5OverrideCursor(): |
160 |
157 locker = QMutexLocker(self.vcs.vcsExecutionMutex) |
161 try: |
|
162 try: |
158 try: |
163 entries = self.client.list(url, recurse=False) |
159 try: |
164 firstTime = parent == self.repoTree |
160 entries = self.client.list(url, recurse=False) |
165 for dirent, _lock in entries: |
161 firstTime = parent == self.repoTree |
166 if ( |
162 for dirent, _lock in entries: |
167 (firstTime and dirent["path"] != url) or |
163 if ( |
168 (parent != self.repoTree and dirent["path"] == url) |
164 (firstTime and dirent["path"] != url) or |
169 ): |
165 (parent != self.repoTree and dirent["path"] == url) |
170 continue |
166 ): |
171 if firstTime: |
167 continue |
172 if dirent["repos_path"] != "/": |
168 if firstTime: |
173 repoUrl = dirent["path"].replace( |
169 if dirent["repos_path"] != "/": |
174 dirent["repos_path"], "") |
170 repoUrl = dirent["path"].replace( |
175 else: |
171 dirent["repos_path"], "") |
176 repoUrl = dirent["path"] |
172 else: |
177 if repoUrl != url: |
173 repoUrl = dirent["path"] |
178 self.__ignoreExpand = True |
174 if repoUrl != url: |
179 itm = self.__generateItem( |
175 self.__ignoreExpand = True |
180 parent, "/", "", "", 0, "", |
176 itm = self.__generateItem( |
181 pysvn.node_kind.dir, repoUrl) |
177 parent, "/", "", "", 0, "", |
182 itm.setExpanded(True) |
178 pysvn.node_kind.dir, repoUrl) |
183 parent = itm |
179 itm.setExpanded(True) |
184 urlPart = repoUrl |
180 parent = itm |
185 for element in ( |
181 urlPart = repoUrl |
186 dirent["repos_path"].split("/")[:-1] |
182 for element in ( |
187 ): |
183 dirent["repos_path"].split("/")[:-1] |
188 if element: |
184 ): |
189 urlPart = "{0}/{1}".format(urlPart, |
185 if element: |
190 element) |
186 urlPart = "{0}/{1}".format(urlPart, |
191 itm = self.__generateItem( |
187 element) |
192 parent, element, "", "", 0, "", |
188 itm = self.__generateItem( |
193 pysvn.node_kind.dir, urlPart) |
189 parent, element, "", "", 0, "", |
194 itm.setExpanded(True) |
190 pysvn.node_kind.dir, urlPart) |
195 parent = itm |
191 itm.setExpanded(True) |
196 self.__ignoreExpand = False |
192 parent = itm |
197 itm = self.__generateItem( |
193 self.__ignoreExpand = False |
198 parent, dirent["repos_path"], dirent["created_rev"], |
194 itm = self.__generateItem( |
199 dirent["last_author"], dirent["size"], dirent["time"], |
195 parent, dirent["repos_path"], |
200 dirent["kind"], dirent["path"]) |
196 dirent["created_rev"], dirent["last_author"], |
201 self.__resort() |
197 dirent["size"], dirent["time"], dirent["kind"], |
202 self.__resizeColumns() |
198 dirent["path"]) |
203 except pysvn.ClientError as e: |
199 self.__resort() |
204 self.__showError(e.args[0]) |
200 self.__resizeColumns() |
205 except AttributeError: |
201 except pysvn.ClientError as e: |
206 self.__showError( |
202 self.__showError(e.args[0]) |
207 self.tr("The installed version of PySvn should be " |
203 except AttributeError: |
208 "1.4.0 or better.")) |
204 self.__showError( |
209 finally: |
205 self.tr("The installed version of PySvn should be " |
210 locker.unlock() |
206 "1.4.0 or better.")) |
211 QApplication.restoreOverrideCursor() |
207 finally: |
|
208 locker.unlock() |
212 |
209 |
213 def __normalizeUrl(self, url): |
210 def __normalizeUrl(self, url): |
214 """ |
211 """ |
215 Private method to normalite the url. |
212 Private method to normalite the url. |
216 |
213 |