18 from .SvnDialogMixin import SvnDialogMixin |
18 from .SvnDialogMixin import SvnDialogMixin |
19 |
19 |
20 from .Ui_SvnRepoBrowserDialog import Ui_SvnRepoBrowserDialog |
20 from .Ui_SvnRepoBrowserDialog import Ui_SvnRepoBrowserDialog |
21 |
21 |
22 import UI.PixmapCache |
22 import UI.PixmapCache |
|
23 |
23 |
24 |
24 class SvnRepoBrowserDialog(QDialog, SvnDialogMixin, Ui_SvnRepoBrowserDialog): |
25 class SvnRepoBrowserDialog(QDialog, SvnDialogMixin, Ui_SvnRepoBrowserDialog): |
25 """ |
26 """ |
26 Class implementing the subversion repository browser dialog. |
27 Class implementing the subversion repository browser dialog. |
27 """ |
28 """ |
28 def __init__(self, vcs, mode = "browse", parent = None): |
29 def __init__(self, vcs, mode="browse", parent=None): |
29 """ |
30 """ |
30 Constructor |
31 Constructor |
31 |
32 |
32 @param vcs reference to the vcs object |
33 @param vcs reference to the vcs object |
33 @param mode mode of the dialog (string, "browse" or "select") |
34 @param mode mode of the dialog (string, "browse" or "select") |
69 |
70 |
70 def __resort(self): |
71 def __resort(self): |
71 """ |
72 """ |
72 Private method to resort the tree. |
73 Private method to resort the tree. |
73 """ |
74 """ |
74 self.repoTree.sortItems(self.repoTree.sortColumn(), |
75 self.repoTree.sortItems(self.repoTree.sortColumn(), |
75 self.repoTree.header().sortIndicatorOrder()) |
76 self.repoTree.header().sortIndicatorOrder()) |
76 |
77 |
77 def __resizeColumns(self): |
78 def __resizeColumns(self): |
78 """ |
79 """ |
79 Private method to resize the tree columns. |
80 Private method to resize the tree columns. |
80 """ |
81 """ |
81 self.repoTree.header().resizeSections(QHeaderView.ResizeToContents) |
82 self.repoTree.header().resizeSections(QHeaderView.ResizeToContents) |
82 self.repoTree.header().setStretchLastSection(True) |
83 self.repoTree.header().setStretchLastSection(True) |
83 |
84 |
84 def __generateItem(self, parent, repopath, revision, author, size, date, |
85 def __generateItem(self, parent, repopath, revision, author, size, date, |
85 nodekind, url): |
86 nodekind, url): |
86 """ |
87 """ |
87 Private method to generate a tree item in the repository tree. |
88 Private method to generate a tree item in the repository tree. |
88 |
89 |
89 @param parent parent of the item to be created (QTreeWidget or QTreeWidgetItem) |
90 @param parent parent of the item to be created (QTreeWidget or QTreeWidgetItem) |
132 itm.setTextAlignment(3, Qt.AlignRight) |
133 itm.setTextAlignment(3, Qt.AlignRight) |
133 itm.setTextAlignment(4, Qt.AlignLeft) |
134 itm.setTextAlignment(4, Qt.AlignLeft) |
134 |
135 |
135 return itm |
136 return itm |
136 |
137 |
137 def __listRepo(self, url, parent = None): |
138 def __listRepo(self, url, parent=None): |
138 """ |
139 """ |
139 Private method to perform the svn list command. |
140 Private method to perform the svn list command. |
140 |
141 |
141 @param url the repository URL to browser (string) |
142 @param url the repository URL to browser (string) |
142 @param parent reference to the item, the data should be appended to |
143 @param parent reference to the item, the data should be appended to |
150 |
151 |
151 locker = QMutexLocker(self.vcs.vcsExecutionMutex) |
152 locker = QMutexLocker(self.vcs.vcsExecutionMutex) |
152 |
153 |
153 try: |
154 try: |
154 try: |
155 try: |
155 entries = self.client.list(url, recurse = False) |
156 entries = self.client.list(url, recurse=False) |
156 firstTime = parent == self.repoTree |
157 firstTime = parent == self.repoTree |
157 for dirent, lock in entries: |
158 for dirent, lock in entries: |
158 if (firstTime and dirent["path"] != url) or \ |
159 if (firstTime and dirent["path"] != url) or \ |
159 (parent != self.repoTree and dirent["path"] == url): |
160 (parent != self.repoTree and dirent["path"] == url): |
160 continue |
161 continue |
163 repoUrl = dirent["path"].replace(dirent["repos_path"], "") |
164 repoUrl = dirent["path"].replace(dirent["repos_path"], "") |
164 else: |
165 else: |
165 repoUrl = dirent["path"] |
166 repoUrl = dirent["path"] |
166 if repoUrl != url: |
167 if repoUrl != url: |
167 self.__ignoreExpand = True |
168 self.__ignoreExpand = True |
168 itm = self.__generateItem(parent, "/", |
169 itm = self.__generateItem(parent, "/", |
169 "", "", 0, "", pysvn.node_kind.dir, repoUrl) |
170 "", "", 0, "", pysvn.node_kind.dir, repoUrl) |
170 itm.setExpanded(True) |
171 itm.setExpanded(True) |
171 parent = itm |
172 parent = itm |
172 urlPart = repoUrl |
173 urlPart = repoUrl |
173 for element in dirent["repos_path"].split("/")[:-1]: |
174 for element in dirent["repos_path"].split("/")[:-1]: |
174 if element: |
175 if element: |
175 urlPart = "{0}/{1}".format(urlPart, element) |
176 urlPart = "{0}/{1}".format(urlPart, element) |
176 itm = self.__generateItem(parent, element, |
177 itm = self.__generateItem(parent, element, |
177 "", "", 0, "", pysvn.node_kind.dir, |
178 "", "", 0, "", pysvn.node_kind.dir, |
178 urlPart) |
179 urlPart) |
179 itm.setExpanded(True) |
180 itm.setExpanded(True) |
180 parent = itm |
181 parent = itm |
181 self.__ignoreExpand = False |
182 self.__ignoreExpand = False |
182 itm = self.__generateItem(parent, dirent["repos_path"], |
183 itm = self.__generateItem(parent, dirent["repos_path"], |
183 dirent["created_rev"], dirent["last_author"], |
184 dirent["created_rev"], dirent["last_author"], |
184 dirent["size"], dirent["time"], |
185 dirent["size"], dirent["time"], |
185 dirent["kind"], dirent["path"]) |
186 dirent["kind"], dirent["path"]) |
186 self.__resort() |
187 self.__resort() |
187 self.__resizeColumns() |
188 self.__resizeColumns() |
188 except pysvn.ClientError as e: |
189 except pysvn.ClientError as e: |
189 self.__showError(e.args[0]) |
190 self.__showError(e.args[0]) |