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