|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2003 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to show repository related information for a |
|
8 file/directory. |
|
9 """ |
|
10 |
|
11 import os |
|
12 |
|
13 import pysvn |
|
14 |
|
15 from PyQt5.QtCore import Qt |
|
16 from PyQt5.QtWidgets import QDialog, QApplication |
|
17 |
|
18 from E5Utilities.E5MutexLocker import E5MutexLocker |
|
19 |
|
20 from .SvnUtilities import formatTime |
|
21 from .SvnDialogMixin import SvnDialogMixin |
|
22 from VCS.Ui_RepositoryInfoDialog import Ui_VcsRepositoryInfoDialog |
|
23 |
|
24 |
|
25 class SvnInfoDialog(QDialog, SvnDialogMixin, Ui_VcsRepositoryInfoDialog): |
|
26 """ |
|
27 Class implementing a dialog to show repository related information |
|
28 for a file/directory. |
|
29 """ |
|
30 def __init__(self, vcs, parent=None): |
|
31 """ |
|
32 Constructor |
|
33 |
|
34 @param vcs reference to the vcs object |
|
35 @param parent parent widget (QWidget) |
|
36 """ |
|
37 super().__init__(parent) |
|
38 self.setupUi(self) |
|
39 SvnDialogMixin.__init__(self) |
|
40 self.setWindowFlags(Qt.WindowType.Window) |
|
41 |
|
42 self.vcs = vcs |
|
43 |
|
44 self.client = self.vcs.getClient() |
|
45 self.client.callback_cancel = self._clientCancelCallback |
|
46 self.client.callback_get_login = self._clientLoginCallback |
|
47 self.client.callback_ssl_server_trust_prompt = ( |
|
48 self._clientSslServerTrustPromptCallback |
|
49 ) |
|
50 |
|
51 self.show() |
|
52 QApplication.processEvents() |
|
53 |
|
54 def start(self, projectPath, fn): |
|
55 """ |
|
56 Public slot to start the svn info command. |
|
57 |
|
58 @param projectPath path name of the project (string) |
|
59 @param fn file or directory name relative to the project (string) |
|
60 """ |
|
61 cwd = os.getcwd() |
|
62 os.chdir(projectPath) |
|
63 try: |
|
64 with E5MutexLocker(self.vcs.vcsExecutionMutex): |
|
65 entries = self.client.info2(fn, recurse=False) |
|
66 infoStr = "<table>" |
|
67 for path, info in entries: |
|
68 infoStr += self.tr( |
|
69 "<tr><td><b>Path (relative to project):</b></td>" |
|
70 "<td>{0}</td></tr>").format(path) |
|
71 if info['URL']: |
|
72 infoStr += self.tr( |
|
73 "<tr><td><b>Url:</b></td><td>{0}</td></tr>" |
|
74 ).format(info['URL']) |
|
75 if info['rev']: |
|
76 infoStr += self.tr( |
|
77 "<tr><td><b>Revision:</b></td><td>{0}</td></tr>" |
|
78 ).format(info['rev'].number) |
|
79 if info['repos_root_URL']: |
|
80 infoStr += self.tr( |
|
81 "<tr><td><b>Repository root URL:</b></td>" |
|
82 "<td>{0}</td></tr>" |
|
83 ).format(info['repos_root_URL']) |
|
84 if info['repos_UUID']: |
|
85 infoStr += self.tr( |
|
86 "<tr><td><b>Repository UUID:</b></td>" |
|
87 "<td>{0}</td></tr>" |
|
88 ).format(info['repos_UUID']) |
|
89 if info['last_changed_author']: |
|
90 infoStr += self.tr( |
|
91 "<tr><td><b>Last changed author:</b></td>" |
|
92 "<td>{0}</td></tr>" |
|
93 ).format(info['last_changed_author']) |
|
94 if info['last_changed_date']: |
|
95 infoStr += self.tr( |
|
96 "<tr><td><b>Last Changed Date:</b></td>" |
|
97 "<td>{0}</td></tr>" |
|
98 ).format(formatTime(info['last_changed_date'])) |
|
99 if ( |
|
100 info['last_changed_rev'] and |
|
101 info['last_changed_rev'].kind == |
|
102 pysvn.opt_revision_kind.number |
|
103 ): |
|
104 infoStr += self.tr( |
|
105 "<tr><td><b>Last changed revision:</b></td>" |
|
106 "<td>{0}</td></tr>" |
|
107 ).format(info['last_changed_rev'].number) |
|
108 if info['kind']: |
|
109 if info['kind'] == pysvn.node_kind.file: |
|
110 nodeKind = self.tr("file") |
|
111 elif info['kind'] == pysvn.node_kind.dir: |
|
112 nodeKind = self.tr("directory") |
|
113 elif info['kind'] == pysvn.node_kind.none: |
|
114 nodeKind = self.tr("none") |
|
115 else: |
|
116 nodeKind = self.tr("unknown") |
|
117 infoStr += self.tr( |
|
118 "<tr><td><b>Node kind:</b></td><td>{0}</td></tr>" |
|
119 ).format(nodeKind) |
|
120 if info['lock']: |
|
121 lockInfo = info['lock'] |
|
122 infoStr += self.tr( |
|
123 "<tr><td><b>Lock Owner:</b></td><td>{0}</td></tr>" |
|
124 ).format(lockInfo['owner']) |
|
125 infoStr += self.tr( |
|
126 "<tr><td><b>Lock Creation Date:</b></td>" |
|
127 "<td>{0}</td></tr>" |
|
128 ).format(formatTime(lockInfo['creation_date'])) |
|
129 if lockInfo['expiration_date'] is not None: |
|
130 infoStr += self.tr( |
|
131 "<tr><td><b>Lock Expiration Date:</b></td>" |
|
132 "<td>{0}</td></tr>" |
|
133 ).format(formatTime(lockInfo['expiration_date'])) |
|
134 infoStr += self.tr( |
|
135 "<tr><td><b>Lock Token:</b></td><td>{0}</td></tr>" |
|
136 ).format(lockInfo['token']) |
|
137 infoStr += self.tr( |
|
138 "<tr><td><b>Lock Comment:</b></td><td>{0}</td></tr>" |
|
139 ).format(lockInfo['comment']) |
|
140 if info['wc_info']: |
|
141 wcInfo = info['wc_info'] |
|
142 if wcInfo['schedule']: |
|
143 if wcInfo['schedule'] == pysvn.wc_schedule.normal: |
|
144 schedule = self.tr("normal") |
|
145 elif wcInfo['schedule'] == pysvn.wc_schedule.add: |
|
146 schedule = self.tr("add") |
|
147 elif wcInfo['schedule'] == pysvn.wc_schedule.delete: |
|
148 schedule = self.tr("delete") |
|
149 elif wcInfo['schedule'] == pysvn.wc_schedule.replace: |
|
150 schedule = self.tr("replace") |
|
151 infoStr += self.tr( |
|
152 "<tr><td><b>Schedule:</b></td><td>{0}</td></tr>" |
|
153 ).format(schedule) |
|
154 if wcInfo['copyfrom_url']: |
|
155 infoStr += self.tr( |
|
156 "<tr><td><b>Copied From URL:</b></td>" |
|
157 "<td>{0}</td></tr>" |
|
158 ).format(wcInfo['copyfrom_url']) |
|
159 infoStr += self.tr( |
|
160 "<tr><td><b>Copied From Rev:</b></td>" |
|
161 "<td>{0}</td></tr>" |
|
162 ).format(wcInfo['copyfrom_rev'].number) |
|
163 if wcInfo['text_time']: |
|
164 infoStr += self.tr( |
|
165 "<tr><td><b>Text Last Updated:</b></td>" |
|
166 "<td>{0}</td></tr>" |
|
167 ).format(formatTime(wcInfo['text_time'])) |
|
168 if wcInfo['prop_time']: |
|
169 infoStr += self.tr( |
|
170 "<tr><td><b>Properties Last Updated:</b></td>" |
|
171 "<td>{0}</td></tr>" |
|
172 ).format(formatTime(wcInfo['prop_time'])) |
|
173 if wcInfo['checksum']: |
|
174 infoStr += self.tr( |
|
175 "<tr><td><b>Checksum:</b></td><td>{0}</td></tr>" |
|
176 ).format(wcInfo['checksum']) |
|
177 infoStr += "</table>" |
|
178 self.infoBrowser.setHtml(infoStr) |
|
179 except pysvn.ClientError as e: |
|
180 self.__showError(e.args[0]) |
|
181 os.chdir(cwd) |
|
182 |
|
183 def __showError(self, msg): |
|
184 """ |
|
185 Private slot to show an error message. |
|
186 |
|
187 @param msg error message to show (string) |
|
188 """ |
|
189 infoStr = "<p>{0}</p>".format(msg) |
|
190 self.infoBrowser.setHtml(infoStr) |