eric6/Plugins/VcsPlugins/vcsSubversion/ProjectBrowserHelper.py

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

eric ide

mercurial