|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2005 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the VCS project browser helper for subversion. |
|
8 """ |
|
9 |
|
10 import os |
|
11 |
|
12 import pysvn |
|
13 |
|
14 from PyQt4.QtCore import * |
|
15 from PyQt4.QtGui import * |
|
16 |
|
17 from E4Gui.E4Application import e4App |
|
18 |
|
19 from VCS.ProjectBrowserHelper import VcsProjectBrowserHelper |
|
20 |
|
21 from Project.ProjectBrowserModel import ProjectBrowserFileItem |
|
22 |
|
23 import UI.PixmapCache |
|
24 |
|
25 class SvnProjectBrowserHelper(VcsProjectBrowserHelper): |
|
26 """ |
|
27 Class implementing the VCS project browser helper for subversion. |
|
28 """ |
|
29 def __init__(self, vcsObject, browserObject, projectObject, isTranslationsBrowser, |
|
30 parent = None, name = None): |
|
31 """ |
|
32 Constructor |
|
33 |
|
34 @param vcsObject reference to the vcs object |
|
35 @param browserObject reference to the project browser object |
|
36 @param projectObject reference to the project object |
|
37 @param isTranslationsBrowser flag indicating, the helper is requested for the |
|
38 translations browser (this needs some special treatment) |
|
39 @param parent parent widget (QWidget) |
|
40 @param name name of this object (string) |
|
41 """ |
|
42 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, projectObject, |
|
43 isTranslationsBrowser, parent, name) |
|
44 |
|
45 def showContextMenu(self, menu, standardItems): |
|
46 """ |
|
47 Slot called before the context menu is shown. |
|
48 |
|
49 It enables/disables the VCS menu entries depending on the overall |
|
50 VCS status and the file status. |
|
51 |
|
52 @param menu reference to the menu to be shown |
|
53 @param standardItems array of standard items that need activation/deactivation |
|
54 depending on the overall VCS status |
|
55 """ |
|
56 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
|
57 for act in self.vcsMenuActions: |
|
58 act.setEnabled(True) |
|
59 for act in self.vcsAddMenuActions: |
|
60 act.setEnabled(False) |
|
61 for act in standardItems: |
|
62 act.setEnabled(False) |
|
63 if not hasattr(self.browser.currentItem(), 'fileName'): |
|
64 self.blameAct.setEnabled(False) |
|
65 else: |
|
66 for act in self.vcsMenuActions: |
|
67 act.setEnabled(False) |
|
68 for act in self.vcsAddMenuActions: |
|
69 act.setEnabled(True) |
|
70 if 1 in self.browser.specialMenuEntries: |
|
71 try: |
|
72 name = self.browser.currentItem().fileName() |
|
73 except AttributeError: |
|
74 name = self.browser.currentItem().dirName() |
|
75 if not os.path.isdir(name): |
|
76 self.vcsMenuAddTree.setEnabled(False) |
|
77 for act in standardItems: |
|
78 act.setEnabled(True) |
|
79 |
|
80 def showContextMenuMulti(self, menu, standardItems): |
|
81 """ |
|
82 Slot called before the context menu (multiple selections) is shown. |
|
83 |
|
84 It enables/disables the VCS menu entries depending on the overall |
|
85 VCS status and the files status. |
|
86 |
|
87 @param menu reference to the menu to be shown |
|
88 @param standardItems array of standard items that need activation/deactivation |
|
89 depending on the overall VCS status |
|
90 """ |
|
91 vcsName = self.vcs.vcsName() |
|
92 items = self.browser.getSelectedItems() |
|
93 vcsItems = 0 |
|
94 # determine number of selected items under VCS control |
|
95 for itm in items: |
|
96 if itm.data(1) == vcsName: |
|
97 vcsItems += 1 |
|
98 |
|
99 if vcsItems > 0: |
|
100 if vcsItems != len(items): |
|
101 for act in self.vcsMultiMenuActions: |
|
102 act.setEnabled(False) |
|
103 else: |
|
104 for act in self.vcsMultiMenuActions: |
|
105 act.setEnabled(True) |
|
106 for act in self.vcsAddMultiMenuActions: |
|
107 act.setEnabled(False) |
|
108 for act in standardItems: |
|
109 act.setEnabled(False) |
|
110 else: |
|
111 for act in self.vcsMultiMenuActions: |
|
112 act.setEnabled(False) |
|
113 for act in self.vcsAddMultiMenuActions: |
|
114 act.setEnabled(True) |
|
115 if 1 in self.browser.specialMenuEntries and \ |
|
116 self.__itemsHaveFiles(items): |
|
117 self.vcsMultiMenuAddTree.setEnabled(False) |
|
118 for act in standardItems: |
|
119 act.setEnabled(True) |
|
120 |
|
121 def showContextMenuDir(self, menu, standardItems): |
|
122 """ |
|
123 Slot called before the context menu is shown. |
|
124 |
|
125 It enables/disables the VCS menu entries depending on the overall |
|
126 VCS status and the directory status. |
|
127 |
|
128 @param menu reference to the menu to be shown |
|
129 @param standardItems array of standard items that need activation/deactivation |
|
130 depending on the overall VCS status |
|
131 """ |
|
132 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
|
133 for act in self.vcsDirMenuActions: |
|
134 act.setEnabled(True) |
|
135 for act in self.vcsAddDirMenuActions: |
|
136 act.setEnabled(False) |
|
137 for act in standardItems: |
|
138 act.setEnabled(False) |
|
139 else: |
|
140 for act in self.vcsDirMenuActions: |
|
141 act.setEnabled(False) |
|
142 for act in self.vcsAddDirMenuActions: |
|
143 act.setEnabled(True) |
|
144 for act in standardItems: |
|
145 act.setEnabled(True) |
|
146 |
|
147 def showContextMenuDirMulti(self, menu, standardItems): |
|
148 """ |
|
149 Slot called before the context menu is shown. |
|
150 |
|
151 It enables/disables the VCS menu entries depending on the overall |
|
152 VCS status and the directory status. |
|
153 |
|
154 @param menu reference to the menu to be shown |
|
155 @param standardItems array of standard items that need activation/deactivation |
|
156 depending on the overall VCS status |
|
157 """ |
|
158 vcsName = self.vcs.vcsName() |
|
159 items = self.browser.getSelectedItems() |
|
160 vcsItems = 0 |
|
161 # determine number of selected items under VCS control |
|
162 for itm in items: |
|
163 if itm.data(1) == vcsName: |
|
164 vcsItems += 1 |
|
165 |
|
166 if vcsItems > 0: |
|
167 if vcsItems != len(items): |
|
168 for act in self.vcsDirMultiMenuActions: |
|
169 act.setEnabled(False) |
|
170 else: |
|
171 for act in self.vcsDirMultiMenuActions: |
|
172 act.setEnabled(True) |
|
173 for act in self.vcsAddDirMultiMenuActions: |
|
174 act.setEnabled(False) |
|
175 for act in standardItems: |
|
176 act.setEnabled(False) |
|
177 else: |
|
178 for act in self.vcsDirMultiMenuActions: |
|
179 act.setEnabled(False) |
|
180 for act in self.vcsAddDirMultiMenuActions: |
|
181 act.setEnabled(True) |
|
182 for act in standardItems: |
|
183 act.setEnabled(True) |
|
184 |
|
185 ############################################################################ |
|
186 # Protected menu generation methods below |
|
187 ############################################################################ |
|
188 |
|
189 def _addVCSMenu(self, mainMenu): |
|
190 """ |
|
191 Protected method used to add the VCS menu to all project browsers. |
|
192 |
|
193 @param mainMenu reference to the menu to be amended |
|
194 """ |
|
195 self.vcsMenuActions = [] |
|
196 self.vcsAddMenuActions = [] |
|
197 |
|
198 menu = QMenu(self.trUtf8("Version Control")) |
|
199 |
|
200 act = menu.addAction( |
|
201 UI.PixmapCache.getIcon( |
|
202 os.path.join("VcsPlugins", "vcsPySvn", "icons", "pysvn.png")), |
|
203 self.vcs.vcsName(), self._VCSInfoDisplay) |
|
204 font = act.font() |
|
205 font.setBold(True) |
|
206 act.setFont(font) |
|
207 menu.addSeparator() |
|
208 |
|
209 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"), |
|
210 self.trUtf8('Update from repository'), self._VCSUpdate) |
|
211 self.vcsMenuActions.append(act) |
|
212 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
|
213 self.trUtf8('Commit changes to repository...'), |
|
214 self._VCSCommit) |
|
215 self.vcsMenuActions.append(act) |
|
216 menu.addSeparator() |
|
217 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
218 self.trUtf8('Add to repository'), |
|
219 self._VCSAdd) |
|
220 self.vcsAddMenuActions.append(act) |
|
221 if 1 in self.browser.specialMenuEntries: |
|
222 self.vcsMenuAddTree = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
223 self.trUtf8('Add tree to repository'), |
|
224 self._VCSAddTree) |
|
225 self.vcsAddMenuActions.append(self.vcsMenuAddTree) |
|
226 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
|
227 self.trUtf8('Remove from repository (and disk)'), |
|
228 self._VCSRemove) |
|
229 self.vcsMenuActions.append(act) |
|
230 menu.addSeparator() |
|
231 act = menu.addAction(self.trUtf8('Copy in repository'), self.__SVNCopy) |
|
232 self.vcsMenuActions.append(act) |
|
233 act = menu.addAction(self.trUtf8('Move in repository'), self.__SVNMove) |
|
234 self.vcsMenuActions.append(act) |
|
235 if pysvn.svn_version >= (1, 5, 0) and pysvn.version >= (1, 6, 0): |
|
236 menu.addSeparator() |
|
237 act = menu.addAction(self.trUtf8("Add to Changelist"), |
|
238 self.__SVNAddToChangelist) |
|
239 self.vcsMenuActions.append(act) |
|
240 act = menu.addAction(self.trUtf8("Remove from Changelist"), |
|
241 self.__SVNRemoveFromChangelist) |
|
242 self.vcsMenuActions.append(act) |
|
243 menu.addSeparator() |
|
244 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
245 self.trUtf8('Show log'), self._VCSLog) |
|
246 self.vcsMenuActions.append(act) |
|
247 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
248 self.trUtf8('Show limited log'), self.__SVNLogLimited) |
|
249 self.vcsMenuActions.append(act) |
|
250 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
251 self.trUtf8('Show log browser'), self.__SVNLogBrowser) |
|
252 self.vcsMenuActions.append(act) |
|
253 menu.addSeparator() |
|
254 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
|
255 self.trUtf8('Show status'), self._VCSStatus) |
|
256 self.vcsMenuActions.append(act) |
|
257 act = menu.addAction(UI.PixmapCache.getIcon("vcsRepo.png"), |
|
258 self.trUtf8('Show repository info'), self.__SVNInfo) |
|
259 self.vcsMenuActions.append(act) |
|
260 menu.addSeparator() |
|
261 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
262 self.trUtf8('Show difference'), self._VCSDiff) |
|
263 self.vcsMenuActions.append(act) |
|
264 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
265 self.trUtf8('Show difference (extended)'), |
|
266 self.__SVNExtendedDiff) |
|
267 self.vcsMenuActions.append(act) |
|
268 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
269 self.trUtf8('Show difference (URLs)'), |
|
270 self.__SVNUrlDiff) |
|
271 self.vcsMenuActions.append(act) |
|
272 self.blameAct = menu.addAction(self.trUtf8('Show annotated file'), |
|
273 self.__SVNBlame) |
|
274 self.vcsMenuActions.append(self.blameAct) |
|
275 menu.addSeparator() |
|
276 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
|
277 self.trUtf8('Revert changes'), self._VCSRevert) |
|
278 self.vcsMenuActions.append(act) |
|
279 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
|
280 self.trUtf8('Merge changes'), self._VCSMerge) |
|
281 self.vcsMenuActions.append(act) |
|
282 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve) |
|
283 self.vcsMenuActions.append(act) |
|
284 menu.addSeparator() |
|
285 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
|
286 self.trUtf8('Lock'), self.__SVNLock) |
|
287 self.vcsMenuActions.append(act) |
|
288 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
289 self.trUtf8('Unlock'), self.__SVNUnlock) |
|
290 self.vcsMenuActions.append(act) |
|
291 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
292 self.trUtf8('Break Lock'), self.__SVNBreakLock) |
|
293 self.vcsMenuActions.append(act) |
|
294 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
295 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
|
296 self.vcsMenuActions.append(act) |
|
297 menu.addSeparator() |
|
298 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
|
299 self.vcsMenuActions.append(act) |
|
300 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
|
301 self.vcsMenuActions.append(act) |
|
302 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
|
303 self.vcsMenuActions.append(act) |
|
304 menu.addSeparator() |
|
305 menu.addAction(self.trUtf8('Select all local file entries'), |
|
306 self.browser.selectLocalEntries) |
|
307 menu.addAction(self.trUtf8('Select all versioned file entries'), |
|
308 self.browser.selectVCSEntries) |
|
309 menu.addAction(self.trUtf8('Select all local directory entries'), |
|
310 self.browser.selectLocalDirEntries) |
|
311 menu.addAction(self.trUtf8('Select all versioned directory entries'), |
|
312 self.browser.selectVCSDirEntries) |
|
313 menu.addSeparator() |
|
314 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure) |
|
315 |
|
316 mainMenu.addSeparator() |
|
317 mainMenu.addMenu(menu) |
|
318 self.menu = menu |
|
319 |
|
320 def _addVCSMenuMulti(self, mainMenu): |
|
321 """ |
|
322 Protected method used to add the VCS menu for multi selection to all |
|
323 project browsers. |
|
324 |
|
325 @param mainMenu reference to the menu to be amended |
|
326 """ |
|
327 self.vcsMultiMenuActions = [] |
|
328 self.vcsAddMultiMenuActions = [] |
|
329 |
|
330 menu = QMenu(self.trUtf8("Version Control")) |
|
331 |
|
332 act = menu.addAction( |
|
333 UI.PixmapCache.getIcon( |
|
334 os.path.join("VcsPlugins", "vcsPySvn", "icons", "pysvn.png")), |
|
335 self.vcs.vcsName(), self._VCSInfoDisplay) |
|
336 font = act.font() |
|
337 font.setBold(True) |
|
338 act.setFont(font) |
|
339 menu.addSeparator() |
|
340 |
|
341 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"), |
|
342 self.trUtf8('Update from repository'), self._VCSUpdate) |
|
343 self.vcsMultiMenuActions.append(act) |
|
344 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
|
345 self.trUtf8('Commit changes to repository...'), |
|
346 self._VCSCommit) |
|
347 self.vcsMultiMenuActions.append(act) |
|
348 menu.addSeparator() |
|
349 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
350 self.trUtf8('Add to repository'), self._VCSAdd) |
|
351 self.vcsAddMultiMenuActions.append(act) |
|
352 if 1 in self.browser.specialMenuEntries: |
|
353 self.vcsMultiMenuAddTree = \ |
|
354 menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
355 self.trUtf8('Add tree to repository'), self._VCSAddTree) |
|
356 self.vcsAddMultiMenuActions.append(self.vcsMultiMenuAddTree) |
|
357 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
|
358 self.trUtf8('Remove from repository (and disk)'), |
|
359 self._VCSRemove) |
|
360 self.vcsMultiMenuActions.append(act) |
|
361 self.vcsRemoveMultiMenuItem = act |
|
362 if pysvn.svn_version >= (1, 5, 0) and pysvn.version >= (1, 6, 0): |
|
363 menu.addSeparator() |
|
364 act = menu.addAction(self.trUtf8("Add to Changelist"), |
|
365 self.__SVNAddToChangelist) |
|
366 self.vcsMenuActions.append(act) |
|
367 act = menu.addAction(self.trUtf8("Remove from Changelist"), |
|
368 self.__SVNRemoveFromChangelist) |
|
369 self.vcsMenuActions.append(act) |
|
370 menu.addSeparator() |
|
371 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
|
372 self.trUtf8('Show status'), self._VCSStatus) |
|
373 self.vcsMultiMenuActions.append(act) |
|
374 menu.addSeparator() |
|
375 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
376 self.trUtf8('Show difference'), self._VCSDiff) |
|
377 self.vcsMultiMenuActions.append(act) |
|
378 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
379 self.trUtf8('Show difference (extended)'), |
|
380 self.__SVNExtendedDiff) |
|
381 self.vcsMultiMenuActions.append(act) |
|
382 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
383 self.trUtf8('Show difference (URLs)'), |
|
384 self.__SVNUrlDiff) |
|
385 self.vcsMultiMenuActions.append(act) |
|
386 menu.addSeparator() |
|
387 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
|
388 self.trUtf8('Revert changes'), self._VCSRevert) |
|
389 self.vcsMultiMenuActions.append(act) |
|
390 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve) |
|
391 self.vcsMultiMenuActions.append(act) |
|
392 menu.addSeparator() |
|
393 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
|
394 self.trUtf8('Lock'), self.__SVNLock) |
|
395 self.vcsMultiMenuActions.append(act) |
|
396 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
397 self.trUtf8('Unlock'), self.__SVNUnlock) |
|
398 self.vcsMultiMenuActions.append(act) |
|
399 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
400 self.trUtf8('Break Lock'), self.__SVNBreakLock) |
|
401 self.vcsMultiMenuActions.append(act) |
|
402 act = menu.addAction(UI.PixmapCache.getIcon("vcsUnlock.png"), |
|
403 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
|
404 self.vcsMultiMenuActions.append(act) |
|
405 menu.addSeparator() |
|
406 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
|
407 self.vcsMultiMenuActions.append(act) |
|
408 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
|
409 self.vcsMultiMenuActions.append(act) |
|
410 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
|
411 self.vcsMultiMenuActions.append(act) |
|
412 menu.addSeparator() |
|
413 menu.addAction(self.trUtf8('Select all local file entries'), |
|
414 self.browser.selectLocalEntries) |
|
415 menu.addAction(self.trUtf8('Select all versioned file entries'), |
|
416 self.browser.selectVCSEntries) |
|
417 menu.addAction(self.trUtf8('Select all local directory entries'), |
|
418 self.browser.selectLocalDirEntries) |
|
419 menu.addAction(self.trUtf8('Select all versioned directory entries'), |
|
420 self.browser.selectVCSDirEntries) |
|
421 menu.addSeparator() |
|
422 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure) |
|
423 |
|
424 mainMenu.addSeparator() |
|
425 mainMenu.addMenu(menu) |
|
426 self.menuMulti = menu |
|
427 |
|
428 def _addVCSMenuBack(self, mainMenu): |
|
429 """ |
|
430 Protected method used to add the VCS menu to all project browsers. |
|
431 |
|
432 @param mainMenu reference to the menu to be amended |
|
433 """ |
|
434 menu = QMenu(self.trUtf8("Version Control")) |
|
435 |
|
436 act = menu.addAction( |
|
437 UI.PixmapCache.getIcon( |
|
438 os.path.join("VcsPlugins", "vcsPySvn", "icons", "pysvn.png")), |
|
439 self.vcs.vcsName(), self._VCSInfoDisplay) |
|
440 font = act.font() |
|
441 font.setBold(True) |
|
442 act.setFont(font) |
|
443 menu.addSeparator() |
|
444 |
|
445 menu.addAction(self.trUtf8('Select all local file entries'), |
|
446 self.browser.selectLocalEntries) |
|
447 menu.addAction(self.trUtf8('Select all versioned file entries'), |
|
448 self.browser.selectVCSEntries) |
|
449 menu.addAction(self.trUtf8('Select all local directory entries'), |
|
450 self.browser.selectLocalDirEntries) |
|
451 menu.addAction(self.trUtf8('Select all versioned directory entries'), |
|
452 self.browser.selectVCSDirEntries) |
|
453 menu.addSeparator() |
|
454 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure) |
|
455 |
|
456 mainMenu.addSeparator() |
|
457 mainMenu.addMenu(menu) |
|
458 self.menuBack = menu |
|
459 |
|
460 def _addVCSMenuDir(self, mainMenu): |
|
461 """ |
|
462 Protected method used to add the VCS menu to all project browsers. |
|
463 |
|
464 @param mainMenu reference to the menu to be amended |
|
465 """ |
|
466 if mainMenu is None: |
|
467 return |
|
468 |
|
469 self.vcsDirMenuActions = [] |
|
470 self.vcsAddDirMenuActions = [] |
|
471 |
|
472 menu = QMenu(self.trUtf8("Version Control")) |
|
473 |
|
474 act = menu.addAction( |
|
475 UI.PixmapCache.getIcon( |
|
476 os.path.join("VcsPlugins", "vcsPySvn", "icons", "pysvn.png")), |
|
477 self.vcs.vcsName(), self._VCSInfoDisplay) |
|
478 font = act.font() |
|
479 font.setBold(True) |
|
480 act.setFont(font) |
|
481 menu.addSeparator() |
|
482 |
|
483 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"), |
|
484 self.trUtf8('Update from repository'), self._VCSUpdate) |
|
485 self.vcsDirMenuActions.append(act) |
|
486 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
|
487 self.trUtf8('Commit changes to repository...'), |
|
488 self._VCSCommit) |
|
489 self.vcsDirMenuActions.append(act) |
|
490 menu.addSeparator() |
|
491 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
492 self.trUtf8('Add to repository'), self._VCSAdd) |
|
493 self.vcsAddDirMenuActions.append(act) |
|
494 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
|
495 self.trUtf8('Remove from repository (and disk)'), |
|
496 self._VCSRemove) |
|
497 self.vcsDirMenuActions.append(act) |
|
498 menu.addSeparator() |
|
499 act = menu.addAction(self.trUtf8('Copy in repository'), self.__SVNCopy) |
|
500 self.vcsDirMenuActions.append(act) |
|
501 act = menu.addAction(self.trUtf8('Move in repository'), self.__SVNMove) |
|
502 self.vcsDirMenuActions.append(act) |
|
503 if pysvn.svn_version >= (1, 5, 0) and pysvn.version >= (1, 6, 0): |
|
504 menu.addSeparator() |
|
505 act = menu.addAction(self.trUtf8("Add to Changelist"), |
|
506 self.__SVNAddToChangelist) |
|
507 self.vcsMenuActions.append(act) |
|
508 act = menu.addAction(self.trUtf8("Remove from Changelist"), |
|
509 self.__SVNRemoveFromChangelist) |
|
510 self.vcsMenuActions.append(act) |
|
511 menu.addSeparator() |
|
512 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
513 self.trUtf8('Show log'), self._VCSLog) |
|
514 self.vcsDirMenuActions.append(act) |
|
515 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
516 self.trUtf8('Show limited log'), self.__SVNLogLimited) |
|
517 self.vcsDirMenuActions.append(act) |
|
518 act = menu.addAction(UI.PixmapCache.getIcon("vcsLog.png"), |
|
519 self.trUtf8('Show log browser'), self.__SVNLogBrowser) |
|
520 self.vcsDirMenuActions.append(act) |
|
521 menu.addSeparator() |
|
522 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
|
523 self.trUtf8('Show status'), self._VCSStatus) |
|
524 self.vcsDirMenuActions.append(act) |
|
525 act = menu.addAction(UI.PixmapCache.getIcon("vcsRepo.png"), |
|
526 self.trUtf8('Show repository info'), self.__SVNInfo) |
|
527 self.vcsDirMenuActions.append(act) |
|
528 menu.addSeparator() |
|
529 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
530 self.trUtf8('Show difference'), self._VCSDiff) |
|
531 self.vcsDirMenuActions.append(act) |
|
532 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
533 self.trUtf8('Show difference (extended)'), |
|
534 self.__SVNExtendedDiff) |
|
535 self.vcsDirMenuActions.append(act) |
|
536 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
537 self.trUtf8('Show difference (URLs)'), |
|
538 self.__SVNUrlDiff) |
|
539 self.vcsDirMenuActions.append(act) |
|
540 menu.addSeparator() |
|
541 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
|
542 self.trUtf8('Revert changes'), self._VCSRevert) |
|
543 self.vcsDirMenuActions.append(act) |
|
544 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
|
545 self.trUtf8('Merge changes'), self._VCSMerge) |
|
546 self.vcsDirMenuActions.append(act) |
|
547 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve) |
|
548 self.vcsDirMenuActions.append(act) |
|
549 menu.addSeparator() |
|
550 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
|
551 self.vcsDirMenuActions.append(act) |
|
552 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
|
553 self.vcsDirMenuActions.append(act) |
|
554 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
|
555 self.vcsDirMenuActions.append(act) |
|
556 menu.addSeparator() |
|
557 menu.addAction(self.trUtf8('Select all local file entries'), |
|
558 self.browser.selectLocalEntries) |
|
559 menu.addAction(self.trUtf8('Select all versioned file entries'), |
|
560 self.browser.selectVCSEntries) |
|
561 menu.addAction(self.trUtf8('Select all local directory entries'), |
|
562 self.browser.selectLocalDirEntries) |
|
563 menu.addAction(self.trUtf8('Select all versioned directory entries'), |
|
564 self.browser.selectVCSDirEntries) |
|
565 menu.addSeparator() |
|
566 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure) |
|
567 |
|
568 mainMenu.addSeparator() |
|
569 mainMenu.addMenu(menu) |
|
570 self.menuDir = menu |
|
571 |
|
572 def _addVCSMenuDirMulti(self, mainMenu): |
|
573 """ |
|
574 Protected method used to add the VCS menu to all project browsers. |
|
575 |
|
576 @param mainMenu reference to the menu to be amended |
|
577 """ |
|
578 if mainMenu is None: |
|
579 return |
|
580 |
|
581 self.vcsDirMultiMenuActions = [] |
|
582 self.vcsAddDirMultiMenuActions = [] |
|
583 |
|
584 menu = QMenu(self.trUtf8("Version Control")) |
|
585 |
|
586 act = menu.addAction( |
|
587 UI.PixmapCache.getIcon( |
|
588 os.path.join("VcsPlugins", "vcsPySvn", "icons", "pysvn.png")), |
|
589 self.vcs.vcsName(), self._VCSInfoDisplay) |
|
590 font = act.font() |
|
591 font.setBold(True) |
|
592 act.setFont(font) |
|
593 menu.addSeparator() |
|
594 |
|
595 act = menu.addAction(UI.PixmapCache.getIcon("vcsUpdate.png"), |
|
596 self.trUtf8('Update from repository'), self._VCSUpdate) |
|
597 self.vcsDirMultiMenuActions.append(act) |
|
598 act = menu.addAction(UI.PixmapCache.getIcon("vcsCommit.png"), |
|
599 self.trUtf8('Commit changes to repository...'), |
|
600 self._VCSCommit) |
|
601 self.vcsDirMultiMenuActions.append(act) |
|
602 menu.addSeparator() |
|
603 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
|
604 self.trUtf8('Add to repository'), self._VCSAdd) |
|
605 self.vcsAddDirMultiMenuActions.append(act) |
|
606 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
|
607 self.trUtf8('Remove from repository (and disk)'), |
|
608 self._VCSRemove) |
|
609 self.vcsDirMultiMenuActions.append(act) |
|
610 if pysvn.svn_version >= (1, 5, 0) and pysvn.version >= (1, 6, 0): |
|
611 menu.addSeparator() |
|
612 act = menu.addAction(self.trUtf8("Add to Changelist"), |
|
613 self.__SVNAddToChangelist) |
|
614 self.vcsMenuActions.append(act) |
|
615 act = menu.addAction(self.trUtf8("Remove from Changelist"), |
|
616 self.__SVNRemoveFromChangelist) |
|
617 self.vcsMenuActions.append(act) |
|
618 menu.addSeparator() |
|
619 act = menu.addAction(UI.PixmapCache.getIcon("vcsStatus.png"), |
|
620 self.trUtf8('Show status'), self._VCSStatus) |
|
621 self.vcsDirMultiMenuActions.append(act) |
|
622 menu.addSeparator() |
|
623 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
624 self.trUtf8('Show difference'), self._VCSDiff) |
|
625 self.vcsDirMultiMenuActions.append(act) |
|
626 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
627 self.trUtf8('Show difference (extended)'), |
|
628 self.__SVNExtendedDiff) |
|
629 self.vcsDirMultiMenuActions.append(act) |
|
630 act = menu.addAction(UI.PixmapCache.getIcon("vcsDiff.png"), |
|
631 self.trUtf8('Show difference (URLs)'), |
|
632 self.__SVNUrlDiff) |
|
633 self.vcsDirMultiMenuActions.append(act) |
|
634 menu.addSeparator() |
|
635 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
|
636 self.trUtf8('Revert changes'), self._VCSRevert) |
|
637 self.vcsDirMenuActions.append(act) |
|
638 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
|
639 self.trUtf8('Merge changes'), self._VCSMerge) |
|
640 self.vcsDirMenuActions.append(act) |
|
641 act = menu.addAction(self.trUtf8('Resolve conflict'), self.__SVNResolve) |
|
642 self.vcsDirMultiMenuActions.append(act) |
|
643 menu.addSeparator() |
|
644 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
|
645 self.vcsDirMultiMenuActions.append(act) |
|
646 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
|
647 self.vcsDirMultiMenuActions.append(act) |
|
648 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
|
649 self.vcsDirMultiMenuActions.append(act) |
|
650 menu.addSeparator() |
|
651 menu.addAction(self.trUtf8('Select all local file entries'), |
|
652 self.browser.selectLocalEntries) |
|
653 menu.addAction(self.trUtf8('Select all versioned file entries'), |
|
654 self.browser.selectVCSEntries) |
|
655 menu.addAction(self.trUtf8('Select all local directory entries'), |
|
656 self.browser.selectLocalDirEntries) |
|
657 menu.addAction(self.trUtf8('Select all versioned directory entries'), |
|
658 self.browser.selectVCSDirEntries) |
|
659 menu.addSeparator() |
|
660 menu.addAction(self.trUtf8("Configure..."), self.__SVNConfigure) |
|
661 |
|
662 mainMenu.addSeparator() |
|
663 mainMenu.addMenu(menu) |
|
664 self.menuDirMulti = menu |
|
665 |
|
666 ############################################################################ |
|
667 # Menu handling methods below |
|
668 ############################################################################ |
|
669 |
|
670 def __SVNCopy(self): |
|
671 """ |
|
672 Private slot called by the context menu to copy the selected file. |
|
673 """ |
|
674 itm = self.browser.currentItem() |
|
675 try: |
|
676 fn = itm.fileName() |
|
677 except AttributeError: |
|
678 fn = itm.dirName() |
|
679 self.vcs.svnCopy(fn, self.project) |
|
680 |
|
681 def __SVNMove(self): |
|
682 """ |
|
683 Private slot called by the context menu to move the selected file. |
|
684 """ |
|
685 itm = self.browser.currentItem() |
|
686 try: |
|
687 fn = itm.fileName() |
|
688 except AttributeError: |
|
689 fn = itm.dirName() |
|
690 isFile = os.path.isfile(fn) |
|
691 movefiles = self.browser.project.getFiles(fn) |
|
692 if self.vcs.vcsMove(fn, self.project): |
|
693 if isFile: |
|
694 self.browser.emit(SIGNAL('closeSourceWindow'), fn) |
|
695 else: |
|
696 for mf in movefiles: |
|
697 self.browser.emit(SIGNAL('closeSourceWindow'), mf) |
|
698 |
|
699 def __SVNResolve(self): |
|
700 """ |
|
701 Private slot called by the context menu to resolve conflicts of a file. |
|
702 """ |
|
703 names = [] |
|
704 for itm in self.browser.getSelectedItems(): |
|
705 try: |
|
706 names.append(itm.fileName()) |
|
707 except AttributeError: |
|
708 names.append(itm.dirName()) |
|
709 self.vcs.svnResolve(names) |
|
710 |
|
711 def __SVNListProps(self): |
|
712 """ |
|
713 Private slot called by the context menu to list the subversion properties of |
|
714 a file. |
|
715 """ |
|
716 names = [] |
|
717 for itm in self.browser.getSelectedItems(): |
|
718 try: |
|
719 names.append(itm.fileName()) |
|
720 except AttributeError: |
|
721 names.append(itm.dirName()) |
|
722 self.vcs.svnListProps(names) |
|
723 |
|
724 def __SVNSetProp(self): |
|
725 """ |
|
726 Private slot called by the context menu to set a subversion property of a file. |
|
727 """ |
|
728 names = [] |
|
729 for itm in self.browser.getSelectedItems(): |
|
730 try: |
|
731 names.append(itm.fileName()) |
|
732 except AttributeError: |
|
733 names.append(itm.dirName()) |
|
734 self.vcs.svnSetProp(names) |
|
735 |
|
736 def __SVNDelProp(self): |
|
737 """ |
|
738 Private slot called by the context menu to delete a subversion property of a file. |
|
739 """ |
|
740 names = [] |
|
741 for itm in self.browser.getSelectedItems(): |
|
742 try: |
|
743 names.append(itm.fileName()) |
|
744 except AttributeError: |
|
745 names.append(itm.dirName()) |
|
746 self.vcs.svnDelProp(names) |
|
747 |
|
748 def __SVNExtendedDiff(self): |
|
749 """ |
|
750 Private slot called by the context menu to show the difference of a file to |
|
751 the repository. |
|
752 |
|
753 This gives the chance to enter the revisions to compare. |
|
754 """ |
|
755 names = [] |
|
756 for itm in self.browser.getSelectedItems(): |
|
757 try: |
|
758 names.append(itm.fileName()) |
|
759 except AttributeError: |
|
760 names.append(itm.dirName()) |
|
761 self.vcs.svnExtendedDiff(names) |
|
762 |
|
763 def __SVNUrlDiff(self): |
|
764 """ |
|
765 Private slot called by the context menu to show the difference of a file of |
|
766 two repository URLs. |
|
767 |
|
768 This gives the chance to enter the repository URLs to compare. |
|
769 """ |
|
770 names = [] |
|
771 for itm in self.browser.getSelectedItems(): |
|
772 try: |
|
773 names.append(itm.fileName()) |
|
774 except AttributeError: |
|
775 names.append(itm.dirName()) |
|
776 self.vcs.svnUrlDiff(names) |
|
777 |
|
778 def __SVNLogLimited(self): |
|
779 """ |
|
780 Private slot called by the context menu to show the limited log of a file. |
|
781 """ |
|
782 itm = self.browser.currentItem() |
|
783 try: |
|
784 fn = itm.fileName() |
|
785 except AttributeError: |
|
786 fn = itm.dirName() |
|
787 self.vcs.svnLogLimited(fn) |
|
788 |
|
789 def __SVNLogBrowser(self): |
|
790 """ |
|
791 Private slot called by the context menu to show the log browser for a file. |
|
792 """ |
|
793 itm = self.browser.currentItem() |
|
794 try: |
|
795 fn = itm.fileName() |
|
796 except AttributeError: |
|
797 fn = itm.dirName() |
|
798 self.vcs.svnLogBrowser(fn) |
|
799 |
|
800 def __SVNBlame(self): |
|
801 """ |
|
802 Private slot called by the context menu to show the blame of a file. |
|
803 """ |
|
804 itm = self.browser.currentItem() |
|
805 fn = itm.fileName() |
|
806 self.vcs.svnBlame(fn) |
|
807 |
|
808 def __SVNLock(self): |
|
809 """ |
|
810 Private slot called by the context menu to lock files in the repository. |
|
811 """ |
|
812 names = [] |
|
813 for itm in self.browser.getSelectedItems(): |
|
814 try: |
|
815 names.append(itm.fileName()) |
|
816 except AttributeError: |
|
817 names.append(itm.dirName()) |
|
818 self.vcs.svnLock(names) |
|
819 |
|
820 def __SVNUnlock(self): |
|
821 """ |
|
822 Private slot called by the context menu to unlock files in the repository. |
|
823 """ |
|
824 names = [] |
|
825 for itm in self.browser.getSelectedItems(): |
|
826 try: |
|
827 names.append(itm.fileName()) |
|
828 except AttributeError: |
|
829 names.append(itm.dirName()) |
|
830 self.vcs.svnUnlock(names) |
|
831 |
|
832 def __SVNBreakLock(self): |
|
833 """ |
|
834 Private slot called by the context menu to break lock files in the repository. |
|
835 """ |
|
836 names = [] |
|
837 for itm in self.browser.getSelectedItems(): |
|
838 try: |
|
839 names.append(itm.fileName()) |
|
840 except AttributeError: |
|
841 names.append(itm.dirName()) |
|
842 self.vcs.svnUnlock(names, breakIt = True) |
|
843 |
|
844 def __SVNStealLock(self): |
|
845 """ |
|
846 Private slot called by the context menu to steal lock files in the repository. |
|
847 """ |
|
848 names = [] |
|
849 for itm in self.browser.getSelectedItems(): |
|
850 try: |
|
851 names.append(itm.fileName()) |
|
852 except AttributeError: |
|
853 names.append(itm.dirName()) |
|
854 self.vcs.svnLock(names, stealIt = True) |
|
855 |
|
856 def __SVNInfo(self): |
|
857 """ |
|
858 Private slot called by the context menu to show repository information of |
|
859 a file or directory. |
|
860 """ |
|
861 try: |
|
862 name = self.browser.currentItem().fileName() |
|
863 except AttributeError: |
|
864 name = self.browser.currentItem().dirName() |
|
865 name = name.replace(self.project.ppath+os.sep, "") |
|
866 self.vcs.svnInfo(self.project.ppath, name) |
|
867 |
|
868 def __SVNConfigure(self): |
|
869 """ |
|
870 Private method to open the configuration dialog. |
|
871 """ |
|
872 e4App().getObject("UserInterface").showPreferences("zzz_subversionPage") |
|
873 |
|
874 def __SVNAddToChangelist(self): |
|
875 """ |
|
876 Private slot called by the context menu to add files to a changelist. |
|
877 """ |
|
878 names = [] |
|
879 for itm in self.browser.getSelectedItems(): |
|
880 try: |
|
881 names.append(itm.fileName()) |
|
882 except AttributeError: |
|
883 names.append(itm.dirName()) |
|
884 self.vcs.svnAddToChangelist(names) |
|
885 |
|
886 def __SVNRemoveFromChangelist(self): |
|
887 """ |
|
888 Private slot called by the context menu to remove files from their changelist. |
|
889 """ |
|
890 names = [] |
|
891 for itm in self.browser.getSelectedItems(): |
|
892 try: |
|
893 names.append(itm.fileName()) |
|
894 except AttributeError: |
|
895 names.append(itm.dirName()) |
|
896 self.vcs.svnRemoveFromChangelist(names) |
|
897 |
|
898 ############################################################################ |
|
899 # Some private utility methods below |
|
900 ############################################################################ |
|
901 |
|
902 def __itemsHaveFiles(self, items): |
|
903 """ |
|
904 Private method to check, if items contain file type items. |
|
905 |
|
906 @param items items to check (list of QTreeWidgetItems) |
|
907 @return flag indicating items contain file type items (boolean) |
|
908 """ |
|
909 for itm in items: |
|
910 if isinstance(itm, ProjectBrowserFileItem): |
|
911 return True |
|
912 return False |