1
# -*- coding: utf-8 -*-
3
# Copyright (c) 2003 - 2007 Detlev Offenbach <detlev@die-offenbachs.de>
7
Module implementing a dialog to show a list of tags or branches.
14
from PyQt4.QtCore import *
15
from PyQt4.QtGui import *
17
from KdeQt import KQMessageBox, KQInputDialog
19
from SvnUtilities import formatTime
21
from SvnDialogMixin import SvnDialogMixin
22
from Ui_SvnTagBranchListDialog import Ui_SvnTagBranchListDialog
24
class SvnTagBranchListDialog(QDialog, SvnDialogMixin, Ui_SvnTagBranchListDialog):
26
Module implementing a dialog to show a list of tags or branches.
28
def __init__(self, vcs, parent = None):
32
@param vcs reference to the vcs object
33
@param parent parent widget (QWidget)
35
QDialog.__init__(self, parent)
37
SvnDialogMixin.__init__(self)
39
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
40
self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
44
self.tagList.header().setSortIndicator(3, Qt.AscendingOrder)
46
self.client = self.vcs.getClient()
47
self.client.callback_cancel = \
48
self._clientCancelCallback
49
self.client.callback_get_login = \
50
self._clientLoginCallback
51
self.client.callback_ssl_server_trust_prompt = \
52
self._clientSslServerTrustPromptCallback
54
def start(self, path, tags = True):
56
Public slot to start the svn status command.
58
@param path name of directory to be listed (string)
59
@param tags flag indicating a list of tags is requested
60
(False = branches, True = tags)
63
self.setWindowTitle(self.trUtf8("Subversion Branches List"))
65
QApplication.processEvents()
67
dname, fname = self.vcs.splitPath(path)
69
reposURL = self.vcs.svnGetReposName(dname)
71
KQMessageBox.critical(None,
72
self.trUtf8("Subversion Error"),
73
self.trUtf8("""The URL of the project repository could not be"""
74
""" retrieved from the working copy. The list operation will"""
79
if self.vcs.otherData["standardLayout"]:
80
# determine the base path of the project in the repository
81
rx_base = QRegExp('(.+)/(trunk|tags|branches).*')
82
if not rx_base.exactMatch(reposURL):
83
KQMessageBox.critical(None,
84
self.trUtf8("Subversion Error"),
85
self.trUtf8("""The URL of the project repository has an"""
86
""" invalid format. The list operation will"""
90
reposRoot = unicode(rx_base.cap(1))
93
path = "%s/tags" % reposRoot
95
path = "%s/branches" % reposRoot
97
reposPath, ok = KQInputDialog.getText(\
99
self.trUtf8("Subversion List"),
100
self.trUtf8("Enter the repository URL containing the tags or branches"),
102
self.vcs.svnNormalizeURL(reposURL))
106
if reposPath.isEmpty():
107
KQMessageBox.critical(None,
108
self.trUtf8("Subversion List"),
109
self.trUtf8("""The repository URL is empty. Aborting..."""))
112
path = unicode(reposPath)
114
self.tagsList = QStringList()
118
entries = self.client.ls(path, recurse = False)
119
for entry in entries:
120
name = entry["name"].replace(path+'/', "")
121
self.__generateItem(entry["created_rev"].number,
122
entry["last_author"],
123
formatTime(entry["time"]),
125
if self.vcs.otherData["standardLayout"]:
126
self.tagsList.append(name)
128
self.tagsList.append(path + '/' + name)
129
if self._clientCancelCallback():
132
except pysvn.ClientError, e:
133
self.__showError(e.args[0])
141
Private slot called when the process finished or the user pressed the button.
143
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
144
self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
145
self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
147
self.tagList.doItemsLayout()
148
self.__resizeColumns()
153
def on_buttonBox_clicked(self, button):
155
Private slot called by a button of the button box clicked.
157
@param button button that was clicked (QAbstractButton)
159
if button == self.buttonBox.button(QDialogButtonBox.Close):
161
elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
164
def __showError(self, msg):
166
Private slot to show an error message.
168
@param msg error message to show (string or QString)
170
self.errors.insertPlainText(msg)
171
self.errors.ensureCursorVisible()
175
Private method to resort the tree.
177
self.tagList.sortItems(self.tagList.sortColumn(),
178
self.tagList.header().sortIndicatorOrder())
180
def __resizeColumns(self):
182
Private method to resize the list columns.
184
self.tagList.header().resizeSections(QHeaderView.ResizeToContents)
185
self.tagList.header().setStretchLastSection(True)
187
def __generateItem(self, revision, author, date, name):
189
Private method to generate a tag item in the taglist.
191
@param revision revision number (integer)
192
@param author author of the tag (string or QString)
193
@param date date of the tag (string or QString)
194
@param name name (path) of the tag (string or QString)
196
itm = QTreeWidgetItem(self.tagList,
197
QStringList() << "%6d" % revision << author << date << name)
198
itm.setTextAlignment(0, Qt.AlignRight)
200
def getTagList(self):
202
Public method to get the taglist of the last run.
204
@return list of tags (QStringList)