23 |
23 |
24 class SvnProjectBrowserHelper(VcsProjectBrowserHelper): |
24 class SvnProjectBrowserHelper(VcsProjectBrowserHelper): |
25 """ |
25 """ |
26 Class implementing the VCS project browser helper for subversion. |
26 Class implementing the VCS project browser helper for subversion. |
27 """ |
27 """ |
28 def __init__(self, vcsObject, browserObject, projectObject, isTranslationsBrowser, |
28 def __init__(self, vcsObject, browserObject, projectObject, |
29 parent=None, name=None): |
29 isTranslationsBrowser, parent=None, name=None): |
30 """ |
30 """ |
31 Constructor |
31 Constructor |
32 |
32 |
33 @param vcsObject reference to the vcs object |
33 @param vcsObject reference to the vcs object |
34 @param browserObject reference to the project browser object |
34 @param browserObject reference to the project browser object |
35 @param projectObject reference to the project object |
35 @param projectObject reference to the project object |
36 @param isTranslationsBrowser flag indicating, the helper is requested for the |
36 @param isTranslationsBrowser flag indicating, the helper is requested |
37 translations browser (this needs some special treatment) |
37 for the translations browser (this needs some special treatment) |
38 @param parent parent widget (QWidget) |
38 @param parent parent widget (QWidget) |
39 @param name name of this object (string) |
39 @param name name of this object (string) |
40 """ |
40 """ |
41 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, projectObject, |
41 VcsProjectBrowserHelper.__init__(self, vcsObject, browserObject, |
42 isTranslationsBrowser, parent, name) |
42 projectObject, isTranslationsBrowser, |
|
43 parent, name) |
43 |
44 |
44 def showContextMenu(self, menu, standardItems): |
45 def showContextMenu(self, menu, standardItems): |
45 """ |
46 """ |
46 Slot called before the context menu is shown. |
47 Slot called before the context menu is shown. |
47 |
48 |
48 It enables/disables the VCS menu entries depending on the overall |
49 It enables/disables the VCS menu entries depending on the overall |
49 VCS status and the file status. |
50 VCS status and the file status. |
50 |
51 |
51 @param menu reference to the menu to be shown |
52 @param menu reference to the menu to be shown |
52 @param standardItems array of standard items that need activation/deactivation |
53 @param standardItems array of standard items that need |
53 depending on the overall VCS status |
54 activation/deactivation depending on the overall VCS status |
54 """ |
55 """ |
55 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
56 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
56 for act in self.vcsMenuActions: |
57 for act in self.vcsMenuActions: |
57 act.setEnabled(True) |
58 act.setEnabled(True) |
58 for act in self.vcsAddMenuActions: |
59 for act in self.vcsAddMenuActions: |
82 |
83 |
83 It enables/disables the VCS menu entries depending on the overall |
84 It enables/disables the VCS menu entries depending on the overall |
84 VCS status and the files status. |
85 VCS status and the files status. |
85 |
86 |
86 @param menu reference to the menu to be shown |
87 @param menu reference to the menu to be shown |
87 @param standardItems array of standard items that need activation/deactivation |
88 @param standardItems array of standard items that need |
88 depending on the overall VCS status |
89 activation/deactivation depending on the overall VCS status |
89 """ |
90 """ |
90 vcsName = self.vcs.vcsName() |
91 vcsName = self.vcs.vcsName() |
91 items = self.browser.getSelectedItems() |
92 items = self.browser.getSelectedItems() |
92 vcsItems = 0 |
93 vcsItems = 0 |
93 # determine number of selected items under VCS control |
94 # determine number of selected items under VCS control |
123 |
124 |
124 It enables/disables the VCS menu entries depending on the overall |
125 It enables/disables the VCS menu entries depending on the overall |
125 VCS status and the directory status. |
126 VCS status and the directory status. |
126 |
127 |
127 @param menu reference to the menu to be shown |
128 @param menu reference to the menu to be shown |
128 @param standardItems array of standard items that need activation/deactivation |
129 @param standardItems array of standard items that need |
129 depending on the overall VCS status |
130 activation/deactivation depending on the overall VCS status |
130 """ |
131 """ |
131 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
132 if self.browser.currentItem().data(1) == self.vcs.vcsName(): |
132 for act in self.vcsDirMenuActions: |
133 for act in self.vcsDirMenuActions: |
133 act.setEnabled(True) |
134 act.setEnabled(True) |
134 for act in self.vcsAddDirMenuActions: |
135 for act in self.vcsAddDirMenuActions: |
149 |
150 |
150 It enables/disables the VCS menu entries depending on the overall |
151 It enables/disables the VCS menu entries depending on the overall |
151 VCS status and the directory status. |
152 VCS status and the directory status. |
152 |
153 |
153 @param menu reference to the menu to be shown |
154 @param menu reference to the menu to be shown |
154 @param standardItems array of standard items that need activation/deactivation |
155 @param standardItems array of standard items that need |
155 depending on the overall VCS status |
156 activation/deactivation depending on the overall VCS status |
156 """ |
157 """ |
157 vcsName = self.vcs.vcsName() |
158 vcsName = self.vcs.vcsName() |
158 items = self.browser.getSelectedItems() |
159 items = self.browser.getSelectedItems() |
159 vcsItems = 0 |
160 vcsItems = 0 |
160 # determine number of selected items under VCS control |
161 # determine number of selected items under VCS control |
179 for act in self.vcsAddDirMultiMenuActions: |
180 for act in self.vcsAddDirMultiMenuActions: |
180 act.setEnabled(True) |
181 act.setEnabled(True) |
181 for act in standardItems: |
182 for act in standardItems: |
182 act.setEnabled(True) |
183 act.setEnabled(True) |
183 |
184 |
184 ############################################################################ |
185 ########################################################################### |
185 # Protected menu generation methods below |
186 # Protected menu generation methods below |
186 ############################################################################ |
187 ########################################################################### |
187 |
188 |
188 def _addVCSMenu(self, mainMenu): |
189 def _addVCSMenu(self, mainMenu): |
189 """ |
190 """ |
190 Protected method used to add the VCS menu to all project browsers. |
191 Protected method used to add the VCS menu to all project browsers. |
191 |
192 |
216 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
217 act = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
217 self.trUtf8('Add to repository'), |
218 self.trUtf8('Add to repository'), |
218 self._VCSAdd) |
219 self._VCSAdd) |
219 self.vcsAddMenuActions.append(act) |
220 self.vcsAddMenuActions.append(act) |
220 if 1 in self.browser.specialMenuEntries: |
221 if 1 in self.browser.specialMenuEntries: |
221 self.vcsMenuAddTree = menu.addAction(UI.PixmapCache.getIcon("vcsAdd.png"), |
222 self.vcsMenuAddTree = menu.addAction( |
|
223 UI.PixmapCache.getIcon("vcsAdd.png"), |
222 self.trUtf8('Add tree to repository'), |
224 self.trUtf8('Add tree to repository'), |
223 self._VCSAddTree) |
225 self._VCSAddTree) |
224 self.vcsAddMenuActions.append(self.vcsMenuAddTree) |
226 self.vcsAddMenuActions.append(self.vcsMenuAddTree) |
225 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
227 act = menu.addAction(UI.PixmapCache.getIcon("vcsRemove.png"), |
226 self.trUtf8('Remove from repository (and disk)'), |
228 self.trUtf8('Remove from repository (and disk)'), |
280 self.trUtf8('Revert changes'), self._VCSRevert) |
282 self.trUtf8('Revert changes'), self._VCSRevert) |
281 self.vcsMenuActions.append(act) |
283 self.vcsMenuActions.append(act) |
282 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
284 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
283 self.trUtf8('Merge changes'), self._VCSMerge) |
285 self.trUtf8('Merge changes'), self._VCSMerge) |
284 self.vcsMenuActions.append(act) |
286 self.vcsMenuActions.append(act) |
285 act = menu.addAction(self.trUtf8('Conflict resolved'), self.__SVNResolve) |
287 act = menu.addAction( |
|
288 self.trUtf8('Conflict resolved'), self.__SVNResolve) |
286 self.vcsMenuActions.append(act) |
289 self.vcsMenuActions.append(act) |
287 menu.addSeparator() |
290 menu.addSeparator() |
288 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
291 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
289 self.trUtf8('Lock'), self.__SVNLock) |
292 self.trUtf8('Lock'), self.__SVNLock) |
290 self.vcsMenuActions.append(act) |
293 self.vcsMenuActions.append(act) |
298 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
301 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
299 self.vcsMenuActions.append(act) |
302 self.vcsMenuActions.append(act) |
300 menu.addSeparator() |
303 menu.addSeparator() |
301 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
304 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
302 self.vcsMenuActions.append(act) |
305 self.vcsMenuActions.append(act) |
303 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
306 act = menu.addAction( |
|
307 self.trUtf8('List Properties'), self.__SVNListProps) |
304 self.vcsMenuActions.append(act) |
308 self.vcsMenuActions.append(act) |
305 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
309 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
306 self.vcsMenuActions.append(act) |
310 self.vcsMenuActions.append(act) |
307 menu.addSeparator() |
311 menu.addSeparator() |
308 menu.addAction(self.trUtf8('Select all local file entries'), |
312 menu.addAction(self.trUtf8('Select all local file entries'), |
387 self.vcsMultiMenuActions.append(act) |
391 self.vcsMultiMenuActions.append(act) |
388 menu.addSeparator() |
392 menu.addSeparator() |
389 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
393 act = menu.addAction(UI.PixmapCache.getIcon("vcsRevert.png"), |
390 self.trUtf8('Revert changes'), self._VCSRevert) |
394 self.trUtf8('Revert changes'), self._VCSRevert) |
391 self.vcsMultiMenuActions.append(act) |
395 self.vcsMultiMenuActions.append(act) |
392 act = menu.addAction(self.trUtf8('Conflict resolved'), self.__SVNResolve) |
396 act = menu.addAction( |
|
397 self.trUtf8('Conflict resolved'), self.__SVNResolve) |
393 self.vcsMultiMenuActions.append(act) |
398 self.vcsMultiMenuActions.append(act) |
394 menu.addSeparator() |
399 menu.addSeparator() |
395 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
400 act = menu.addAction(UI.PixmapCache.getIcon("vcsLock.png"), |
396 self.trUtf8('Lock'), self.__SVNLock) |
401 self.trUtf8('Lock'), self.__SVNLock) |
397 self.vcsMultiMenuActions.append(act) |
402 self.vcsMultiMenuActions.append(act) |
405 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
410 self.trUtf8('Steal Lock'), self.__SVNStealLock) |
406 self.vcsMultiMenuActions.append(act) |
411 self.vcsMultiMenuActions.append(act) |
407 menu.addSeparator() |
412 menu.addSeparator() |
408 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
413 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
409 self.vcsMultiMenuActions.append(act) |
414 self.vcsMultiMenuActions.append(act) |
410 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
415 act = menu.addAction( |
|
416 self.trUtf8('List Properties'), self.__SVNListProps) |
411 self.vcsMultiMenuActions.append(act) |
417 self.vcsMultiMenuActions.append(act) |
412 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
418 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
413 self.vcsMultiMenuActions.append(act) |
419 self.vcsMultiMenuActions.append(act) |
414 menu.addSeparator() |
420 menu.addSeparator() |
415 menu.addAction(self.trUtf8('Select all local file entries'), |
421 menu.addAction(self.trUtf8('Select all local file entries'), |
541 self.trUtf8('Revert changes'), self._VCSRevert) |
547 self.trUtf8('Revert changes'), self._VCSRevert) |
542 self.vcsDirMenuActions.append(act) |
548 self.vcsDirMenuActions.append(act) |
543 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
549 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
544 self.trUtf8('Merge changes'), self._VCSMerge) |
550 self.trUtf8('Merge changes'), self._VCSMerge) |
545 self.vcsDirMenuActions.append(act) |
551 self.vcsDirMenuActions.append(act) |
546 act = menu.addAction(self.trUtf8('Conflict resolved'), self.__SVNResolve) |
552 act = menu.addAction( |
|
553 self.trUtf8('Conflict resolved'), self.__SVNResolve) |
547 self.vcsDirMenuActions.append(act) |
554 self.vcsDirMenuActions.append(act) |
548 menu.addSeparator() |
555 menu.addSeparator() |
549 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
556 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
550 self.vcsDirMenuActions.append(act) |
557 self.vcsDirMenuActions.append(act) |
551 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
558 act = menu.addAction( |
|
559 self.trUtf8('List Properties'), self.__SVNListProps) |
552 self.vcsDirMenuActions.append(act) |
560 self.vcsDirMenuActions.append(act) |
553 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
561 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
554 self.vcsDirMenuActions.append(act) |
562 self.vcsDirMenuActions.append(act) |
555 menu.addSeparator() |
563 menu.addSeparator() |
556 menu.addAction(self.trUtf8('Select all local file entries'), |
564 menu.addAction(self.trUtf8('Select all local file entries'), |
635 self.trUtf8('Revert changes'), self._VCSRevert) |
643 self.trUtf8('Revert changes'), self._VCSRevert) |
636 self.vcsDirMultiMenuActions.append(act) |
644 self.vcsDirMultiMenuActions.append(act) |
637 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
645 act = menu.addAction(UI.PixmapCache.getIcon("vcsMerge.png"), |
638 self.trUtf8('Merge changes'), self._VCSMerge) |
646 self.trUtf8('Merge changes'), self._VCSMerge) |
639 self.vcsDirMultiMenuActions.append(act) |
647 self.vcsDirMultiMenuActions.append(act) |
640 act = menu.addAction(self.trUtf8('Conflict resolved'), self.__SVNResolve) |
648 act = menu.addAction( |
|
649 self.trUtf8('Conflict resolved'), self.__SVNResolve) |
641 self.vcsDirMultiMenuActions.append(act) |
650 self.vcsDirMultiMenuActions.append(act) |
642 menu.addSeparator() |
651 menu.addSeparator() |
643 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
652 act = menu.addAction(self.trUtf8('Set Property'), self.__SVNSetProp) |
644 self.vcsDirMultiMenuActions.append(act) |
653 self.vcsDirMultiMenuActions.append(act) |
645 act = menu.addAction(self.trUtf8('List Properties'), self.__SVNListProps) |
654 act = menu.addAction( |
|
655 self.trUtf8('List Properties'), self.__SVNListProps) |
646 self.vcsDirMultiMenuActions.append(act) |
656 self.vcsDirMultiMenuActions.append(act) |
647 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
657 act = menu.addAction(self.trUtf8('Delete Property'), self.__SVNDelProp) |
648 self.vcsDirMultiMenuActions.append(act) |
658 self.vcsDirMultiMenuActions.append(act) |
649 menu.addSeparator() |
659 menu.addSeparator() |
650 menu.addAction(self.trUtf8('Select all local file entries'), |
660 menu.addAction(self.trUtf8('Select all local file entries'), |
660 |
670 |
661 mainMenu.addSeparator() |
671 mainMenu.addSeparator() |
662 mainMenu.addMenu(menu) |
672 mainMenu.addMenu(menu) |
663 self.menuDirMulti = menu |
673 self.menuDirMulti = menu |
664 |
674 |
665 ############################################################################ |
675 ########################################################################### |
666 # Menu handling methods below |
676 # Menu handling methods below |
667 ############################################################################ |
677 ########################################################################### |
668 |
678 |
669 def __SVNCopy(self): |
679 def __SVNCopy(self): |
670 """ |
680 """ |
671 Private slot called by the context menu to copy the selected file. |
681 Private slot called by the context menu to copy the selected file. |
672 """ |
682 """ |
744 names.append(itm.dirName()) |
756 names.append(itm.dirName()) |
745 self.vcs.svnDelProp(names) |
757 self.vcs.svnDelProp(names) |
746 |
758 |
747 def __SVNExtendedDiff(self): |
759 def __SVNExtendedDiff(self): |
748 """ |
760 """ |
749 Private slot called by the context menu to show the difference of a file to |
761 Private slot called by the context menu to show the difference of a |
750 the repository. |
762 file to the repository. |
751 |
763 |
752 This gives the chance to enter the revisions to compare. |
764 This gives the chance to enter the revisions to compare. |
753 """ |
765 """ |
754 names = [] |
766 names = [] |
755 for itm in self.browser.getSelectedItems(): |
767 for itm in self.browser.getSelectedItems(): |
759 names.append(itm.dirName()) |
771 names.append(itm.dirName()) |
760 self.vcs.svnExtendedDiff(names) |
772 self.vcs.svnExtendedDiff(names) |
761 |
773 |
762 def __SVNUrlDiff(self): |
774 def __SVNUrlDiff(self): |
763 """ |
775 """ |
764 Private slot called by the context menu to show the difference of a file of |
776 Private slot called by the context menu to show the difference of a |
765 two repository URLs. |
777 file of two repository URLs. |
766 |
778 |
767 This gives the chance to enter the repository URLs to compare. |
779 This gives the chance to enter the repository URLs to compare. |
768 """ |
780 """ |
769 names = [] |
781 names = [] |
770 for itm in self.browser.getSelectedItems(): |
782 for itm in self.browser.getSelectedItems(): |
774 names.append(itm.dirName()) |
786 names.append(itm.dirName()) |
775 self.vcs.svnUrlDiff(names) |
787 self.vcs.svnUrlDiff(names) |
776 |
788 |
777 def __SVNSbsDiff(self): |
789 def __SVNSbsDiff(self): |
778 """ |
790 """ |
779 Private slot called by the context menu to show the difference of a file to |
791 Private slot called by the context menu to show the difference of a |
780 the repository side-by-side. |
792 file to the repository side-by-side. |
781 """ |
793 """ |
782 itm = self.browser.currentItem() |
794 itm = self.browser.currentItem() |
783 fn = itm.fileName() |
795 fn = itm.fileName() |
784 self.vcs.svnSbsDiff(fn) |
796 self.vcs.svnSbsDiff(fn) |
785 |
797 |
786 def __SVNSbsExtendedDiff(self): |
798 def __SVNSbsExtendedDiff(self): |
787 """ |
799 """ |
788 Private slot called by the context menu to show the difference of a file to |
800 Private slot called by the context menu to show the difference of a |
789 the repository side-by-side allowing the selection of revisions to compare. |
801 file to the repository side-by-side allowing the selection of |
|
802 revisions to compare. |
790 """ |
803 """ |
791 itm = self.browser.currentItem() |
804 itm = self.browser.currentItem() |
792 fn = itm.fileName() |
805 fn = itm.fileName() |
793 self.vcs.svnSbsDiff(fn, extended=True) |
806 self.vcs.svnSbsDiff(fn, extended=True) |
794 |
807 |
795 def __SVNLogBrowser(self): |
808 def __SVNLogBrowser(self): |
796 """ |
809 """ |
797 Private slot called by the context menu to show the log browser for a file. |
810 Private slot called by the context menu to show the log browser for a |
|
811 file. |
798 """ |
812 """ |
799 itm = self.browser.currentItem() |
813 itm = self.browser.currentItem() |
800 try: |
814 try: |
801 fn = itm.fileName() |
815 fn = itm.fileName() |
802 isFile = True |
816 isFile = True |
849 names.append(itm.dirName()) |
866 names.append(itm.dirName()) |
850 self.vcs.svnUnlock(names, breakIt=True) |
867 self.vcs.svnUnlock(names, breakIt=True) |
851 |
868 |
852 def __SVNStealLock(self): |
869 def __SVNStealLock(self): |
853 """ |
870 """ |
854 Private slot called by the context menu to steal lock files in the repository. |
871 Private slot called by the context menu to steal lock files in the |
|
872 repository. |
855 """ |
873 """ |
856 names = [] |
874 names = [] |
857 for itm in self.browser.getSelectedItems(): |
875 for itm in self.browser.getSelectedItems(): |
858 try: |
876 try: |
859 names.append(itm.fileName()) |
877 names.append(itm.fileName()) |
861 names.append(itm.dirName()) |
879 names.append(itm.dirName()) |
862 self.vcs.svnLock(names, stealIt=True) |
880 self.vcs.svnLock(names, stealIt=True) |
863 |
881 |
864 def __SVNInfo(self): |
882 def __SVNInfo(self): |
865 """ |
883 """ |
866 Private slot called by the context menu to show repository information of |
884 Private slot called by the context menu to show repository information |
867 a file or directory. |
885 of a file or directory. |
868 """ |
886 """ |
869 try: |
887 try: |
870 name = self.browser.currentItem().fileName() |
888 name = self.browser.currentItem().fileName() |
871 except AttributeError: |
889 except AttributeError: |
872 name = self.browser.currentItem().dirName() |
890 name = self.browser.currentItem().dirName() |
891 names.append(itm.dirName()) |
910 names.append(itm.dirName()) |
892 self.vcs.svnAddToChangelist(names) |
911 self.vcs.svnAddToChangelist(names) |
893 |
912 |
894 def __SVNRemoveFromChangelist(self): |
913 def __SVNRemoveFromChangelist(self): |
895 """ |
914 """ |
896 Private slot called by the context menu to remove files from their changelist. |
915 Private slot called by the context menu to remove files from their |
|
916 changelist. |
897 """ |
917 """ |
898 names = [] |
918 names = [] |
899 for itm in self.browser.getSelectedItems(): |
919 for itm in self.browser.getSelectedItems(): |
900 try: |
920 try: |
901 names.append(itm.fileName()) |
921 names.append(itm.fileName()) |
902 except AttributeError: |
922 except AttributeError: |
903 names.append(itm.dirName()) |
923 names.append(itm.dirName()) |
904 self.vcs.svnRemoveFromChangelist(names) |
924 self.vcs.svnRemoveFromChangelist(names) |
905 |
925 |
906 ############################################################################ |
926 ########################################################################### |
907 # Some private utility methods below |
927 # Some private utility methods below |
908 ############################################################################ |
928 ########################################################################### |
909 |
929 |
910 def __itemsHaveFiles(self, items): |
930 def __itemsHaveFiles(self, items): |
911 """ |
931 """ |
912 Private method to check, if items contain file type items. |
932 Private method to check, if items contain file type items. |
913 |
933 |