Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py

changeset 3190
a9a94491c4fd
parent 3160
209a07d7e401
child 3484
645c12de6b0c
equal deleted inserted replaced
3189:9a21c547de5f 3190:a9a94491c4fd
48 self.__upToDateColumn = 8 48 self.__upToDateColumn = 8
49 self.__pathColumn = 12 49 self.__pathColumn = 12
50 self.__lastColumn = self.statusList.columnCount() 50 self.__lastColumn = self.statusList.columnCount()
51 51
52 self.refreshButton = \ 52 self.refreshButton = \
53 self.buttonBox.addButton(self.trUtf8("Refresh"), 53 self.buttonBox.addButton(self.tr("Refresh"),
54 QDialogButtonBox.ActionRole) 54 QDialogButtonBox.ActionRole)
55 self.refreshButton.setToolTip( 55 self.refreshButton.setToolTip(
56 self.trUtf8("Press to refresh the status display")) 56 self.tr("Press to refresh the status display"))
57 self.refreshButton.setEnabled(False) 57 self.refreshButton.setEnabled(False)
58 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 58 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
59 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 59 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
60 60
61 self.diff = None 61 self.diff = None
70 self.statusList.header().hideSection(self.__changelistColumn) 70 self.statusList.header().hideSection(self.__changelistColumn)
71 71
72 self.menuactions = [] 72 self.menuactions = []
73 self.menu = QMenu() 73 self.menu = QMenu()
74 self.menuactions.append(self.menu.addAction( 74 self.menuactions.append(self.menu.addAction(
75 self.trUtf8("Commit changes to repository..."), self.__commit)) 75 self.tr("Commit changes to repository..."), self.__commit))
76 self.menuactions.append(self.menu.addAction( 76 self.menuactions.append(self.menu.addAction(
77 self.trUtf8("Select all for commit"), self.__commitSelectAll)) 77 self.tr("Select all for commit"), self.__commitSelectAll))
78 self.menuactions.append(self.menu.addAction( 78 self.menuactions.append(self.menu.addAction(
79 self.trUtf8("Deselect all from commit"), self.__commitDeselectAll)) 79 self.tr("Deselect all from commit"), self.__commitDeselectAll))
80 self.menu.addSeparator() 80 self.menu.addSeparator()
81 self.menuactions.append(self.menu.addAction( 81 self.menuactions.append(self.menu.addAction(
82 self.trUtf8("Add to repository"), self.__add)) 82 self.tr("Add to repository"), self.__add))
83 self.menuactions.append(self.menu.addAction( 83 self.menuactions.append(self.menu.addAction(
84 self.trUtf8("Show differences"), self.__diff)) 84 self.tr("Show differences"), self.__diff))
85 self.menuactions.append(self.menu.addAction( 85 self.menuactions.append(self.menu.addAction(
86 self.trUtf8("Show differences side-by-side"), self.__sbsDiff)) 86 self.tr("Show differences side-by-side"), self.__sbsDiff))
87 self.menuactions.append(self.menu.addAction( 87 self.menuactions.append(self.menu.addAction(
88 self.trUtf8("Revert changes"), self.__revert)) 88 self.tr("Revert changes"), self.__revert))
89 self.menuactions.append(self.menu.addAction( 89 self.menuactions.append(self.menu.addAction(
90 self.trUtf8("Restore missing"), self.__restoreMissing)) 90 self.tr("Restore missing"), self.__restoreMissing))
91 if self.vcs.version >= (1, 5, 0): 91 if self.vcs.version >= (1, 5, 0):
92 self.menu.addSeparator() 92 self.menu.addSeparator()
93 self.menuactions.append(self.menu.addAction( 93 self.menuactions.append(self.menu.addAction(
94 self.trUtf8("Add to Changelist"), self.__addToChangelist)) 94 self.tr("Add to Changelist"), self.__addToChangelist))
95 self.menuactions.append(self.menu.addAction( 95 self.menuactions.append(self.menu.addAction(
96 self.trUtf8("Remove from Changelist"), 96 self.tr("Remove from Changelist"),
97 self.__removeFromChangelist)) 97 self.__removeFromChangelist))
98 if self.vcs.version >= (1, 2, 0): 98 if self.vcs.version >= (1, 2, 0):
99 self.menu.addSeparator() 99 self.menu.addSeparator()
100 self.menuactions.append(self.menu.addAction( 100 self.menuactions.append(self.menu.addAction(
101 self.trUtf8("Lock"), self.__lock)) 101 self.tr("Lock"), self.__lock))
102 self.menuactions.append(self.menu.addAction( 102 self.menuactions.append(self.menu.addAction(
103 self.trUtf8("Unlock"), self.__unlock)) 103 self.tr("Unlock"), self.__unlock))
104 self.menuactions.append(self.menu.addAction( 104 self.menuactions.append(self.menu.addAction(
105 self.trUtf8("Break lock"), 105 self.tr("Break lock"),
106 self.__breakLock)) 106 self.__breakLock))
107 self.menuactions.append(self.menu.addAction( 107 self.menuactions.append(self.menu.addAction(
108 self.trUtf8("Steal lock"), 108 self.tr("Steal lock"),
109 self.__stealLock)) 109 self.__stealLock))
110 self.menu.addSeparator() 110 self.menu.addSeparator()
111 self.menuactions.append(self.menu.addAction( 111 self.menuactions.append(self.menu.addAction(
112 self.trUtf8("Adjust column sizes"), 112 self.tr("Adjust column sizes"),
113 self.__resizeColumns)) 113 self.__resizeColumns))
114 for act in self.menuactions: 114 for act in self.menuactions:
115 act.setEnabled(False) 115 act.setEnabled(False)
116 116
117 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 117 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu)
118 self.statusList.customContextMenuRequested.connect( 118 self.statusList.customContextMenuRequested.connect(
119 self.__showContextMenu) 119 self.__showContextMenu)
120 120
121 self.modifiedIndicators = [ 121 self.modifiedIndicators = [
122 self.trUtf8('added'), 122 self.tr('added'),
123 self.trUtf8('deleted'), 123 self.tr('deleted'),
124 self.trUtf8('modified'), 124 self.tr('modified'),
125 ] 125 ]
126 126
127 self.missingIndicators = [ 127 self.missingIndicators = [
128 self.trUtf8('missing'), 128 self.tr('missing'),
129 ] 129 ]
130 130
131 self.unversionedIndicators = [ 131 self.unversionedIndicators = [
132 self.trUtf8('unversioned'), 132 self.tr('unversioned'),
133 ] 133 ]
134 134
135 self.lockedIndicators = [ 135 self.lockedIndicators = [
136 self.trUtf8('locked'), 136 self.tr('locked'),
137 ] 137 ]
138 138
139 self.stealBreakLockIndicators = [ 139 self.stealBreakLockIndicators = [
140 self.trUtf8('other lock'), 140 self.tr('other lock'),
141 self.trUtf8('stolen lock'), 141 self.tr('stolen lock'),
142 self.trUtf8('broken lock'), 142 self.tr('broken lock'),
143 ] 143 ]
144 144
145 self.unlockedIndicators = [ 145 self.unlockedIndicators = [
146 self.trUtf8('not locked'), 146 self.tr('not locked'),
147 ] 147 ]
148 148
149 self.status = { 149 self.status = {
150 ' ': self.trUtf8('normal'), 150 ' ': self.tr('normal'),
151 'A': self.trUtf8('added'), 151 'A': self.tr('added'),
152 'D': self.trUtf8('deleted'), 152 'D': self.tr('deleted'),
153 'M': self.trUtf8('modified'), 153 'M': self.tr('modified'),
154 'R': self.trUtf8('replaced'), 154 'R': self.tr('replaced'),
155 'C': self.trUtf8('conflict'), 155 'C': self.tr('conflict'),
156 'X': self.trUtf8('external'), 156 'X': self.tr('external'),
157 'I': self.trUtf8('ignored'), 157 'I': self.tr('ignored'),
158 '?': self.trUtf8('unversioned'), 158 '?': self.tr('unversioned'),
159 '!': self.trUtf8('missing'), 159 '!': self.tr('missing'),
160 '~': self.trUtf8('type error'), 160 '~': self.tr('type error'),
161 } 161 }
162 self.propStatus = { 162 self.propStatus = {
163 ' ': self.trUtf8('normal'), 163 ' ': self.tr('normal'),
164 'M': self.trUtf8('modified'), 164 'M': self.tr('modified'),
165 'C': self.trUtf8('conflict'), 165 'C': self.tr('conflict'),
166 } 166 }
167 self.locked = { 167 self.locked = {
168 ' ': self.trUtf8('no'), 168 ' ': self.tr('no'),
169 'L': self.trUtf8('yes'), 169 'L': self.tr('yes'),
170 } 170 }
171 self.history = { 171 self.history = {
172 ' ': self.trUtf8('no'), 172 ' ': self.tr('no'),
173 '+': self.trUtf8('yes'), 173 '+': self.tr('yes'),
174 } 174 }
175 self.switched = { 175 self.switched = {
176 ' ': self.trUtf8('no'), 176 ' ': self.tr('no'),
177 'S': self.trUtf8('yes'), 177 'S': self.tr('yes'),
178 } 178 }
179 self.lockinfo = { 179 self.lockinfo = {
180 ' ': self.trUtf8('not locked'), 180 ' ': self.tr('not locked'),
181 'K': self.trUtf8('locked'), 181 'K': self.tr('locked'),
182 'O': self.trUtf8('other lock'), 182 'O': self.tr('other lock'),
183 'T': self.trUtf8('stolen lock'), 183 'T': self.tr('stolen lock'),
184 'B': self.trUtf8('broken lock'), 184 'B': self.tr('broken lock'),
185 } 185 }
186 self.uptodate = { 186 self.uptodate = {
187 ' ': self.trUtf8('yes'), 187 ' ': self.tr('yes'),
188 '*': self.trUtf8('no'), 188 '*': self.tr('no'),
189 } 189 }
190 190
191 self.rx_status = QRegExp( 191 self.rx_status = QRegExp(
192 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*') 192 '(.{8,9})\\s+([0-9-]+)\\s+([0-9?]+)\\s+(\\S+)\\s+(.+)\\s*')
193 # flags (8 or 9 anything), revision, changed rev, author, path 193 # flags (8 or 9 anything), revision, changed rev, author, path
381 self.dname, fname = self.vcs.splitPath(fn) 381 self.dname, fname = self.vcs.splitPath(fn)
382 args.append(fname) 382 args.append(fname)
383 383
384 self.process.setWorkingDirectory(self.dname) 384 self.process.setWorkingDirectory(self.dname)
385 385
386 self.setWindowTitle(self.trUtf8('Subversion Status')) 386 self.setWindowTitle(self.tr('Subversion Status'))
387 387
388 self.process.start('svn', args) 388 self.process.start('svn', args)
389 procStarted = self.process.waitForStarted(5000) 389 procStarted = self.process.waitForStarted(5000)
390 if not procStarted: 390 if not procStarted:
391 self.inputGroup.setEnabled(False) 391 self.inputGroup.setEnabled(False)
392 self.inputGroup.hide() 392 self.inputGroup.hide()
393 E5MessageBox.critical( 393 E5MessageBox.critical(
394 self, 394 self,
395 self.trUtf8('Process Generation Error'), 395 self.tr('Process Generation Error'),
396 self.trUtf8( 396 self.tr(
397 'The process {0} could not be started. ' 397 'The process {0} could not be started. '
398 'Ensure, that it is in the search path.' 398 'Ensure, that it is in the search path.'
399 ).format('svn')) 399 ).format('svn'))
400 else: 400 else:
401 self.inputGroup.setEnabled(True) 401 self.inputGroup.setEnabled(True)
421 self.inputGroup.setEnabled(False) 421 self.inputGroup.setEnabled(False)
422 self.inputGroup.hide() 422 self.inputGroup.hide()
423 self.refreshButton.setEnabled(True) 423 self.refreshButton.setEnabled(True)
424 424
425 self.__statusFilters.sort() 425 self.__statusFilters.sort()
426 self.__statusFilters.insert(0, "<{0}>".format(self.trUtf8("all"))) 426 self.__statusFilters.insert(0, "<{0}>".format(self.tr("all")))
427 self.statusFilterCombo.addItems(self.__statusFilters) 427 self.statusFilterCombo.addItems(self.__statusFilters)
428 428
429 for act in self.menuactions: 429 for act in self.menuactions:
430 act.setEnabled(True) 430 act.setEnabled(True)
431 431
617 """ 617 """
618 Private slot to react to the selection of a status filter. 618 Private slot to react to the selection of a status filter.
619 619
620 @param txt selected status filter (string) 620 @param txt selected status filter (string)
621 """ 621 """
622 if txt == "<{0}>".format(self.trUtf8("all")): 622 if txt == "<{0}>".format(self.tr("all")):
623 for topIndex in range(self.statusList.topLevelItemCount()): 623 for topIndex in range(self.statusList.topLevelItemCount()):
624 topItem = self.statusList.topLevelItem(topIndex) 624 topItem = self.statusList.topLevelItem(topIndex)
625 topItem.setHidden(False) 625 topItem.setHidden(False)
626 else: 626 else:
627 for topIndex in range(self.statusList.topLevelItemCount()): 627 for topIndex in range(self.statusList.topLevelItemCount()):
707 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 707 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
708 for itm in self.__getCommitableItems()] 708 for itm in self.__getCommitableItems()]
709 if not names: 709 if not names:
710 E5MessageBox.information( 710 E5MessageBox.information(
711 self, 711 self,
712 self.trUtf8("Commit"), 712 self.tr("Commit"),
713 self.trUtf8("""There are no entries selected to be""" 713 self.tr("""There are no entries selected to be"""
714 """ committed.""")) 714 """ committed."""))
715 return 715 return
716 716
717 if Preferences.getVCS("AutoSaveFiles"): 717 if Preferences.getVCS("AutoSaveFiles"):
718 vm = e5App().getObject("ViewManager") 718 vm = e5App().getObject("ViewManager")
719 for name in names: 719 for name in names:
747 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 747 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
748 for itm in self.__getUnversionedItems()] 748 for itm in self.__getUnversionedItems()]
749 if not names: 749 if not names:
750 E5MessageBox.information( 750 E5MessageBox.information(
751 self, 751 self,
752 self.trUtf8("Add"), 752 self.tr("Add"),
753 self.trUtf8("""There are no unversioned entries""" 753 self.tr("""There are no unversioned entries"""
754 """ available/selected.""")) 754 """ available/selected."""))
755 return 755 return
756 756
757 self.vcs.vcsAdd(names) 757 self.vcs.vcsAdd(names)
758 self.on_refreshButton_clicked() 758 self.on_refreshButton_clicked()
759 759
769 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 769 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
770 for itm in self.__getModifiedItems()] 770 for itm in self.__getModifiedItems()]
771 if not names: 771 if not names:
772 E5MessageBox.information( 772 E5MessageBox.information(
773 self, 773 self,
774 self.trUtf8("Revert"), 774 self.tr("Revert"),
775 self.trUtf8("""There are no uncommitted changes""" 775 self.tr("""There are no uncommitted changes"""
776 """ available/selected.""")) 776 """ available/selected."""))
777 return 777 return
778 778
779 self.vcs.vcsRevert(names) 779 self.vcs.vcsRevert(names)
780 self.raise_() 780 self.raise_()
781 self.activateWindow() 781 self.activateWindow()
793 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 793 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
794 for itm in self.__getMissingItems()] 794 for itm in self.__getMissingItems()]
795 if not names: 795 if not names:
796 E5MessageBox.information( 796 E5MessageBox.information(
797 self, 797 self,
798 self.trUtf8("Revert"), 798 self.tr("Revert"),
799 self.trUtf8("""There are no missing entries""" 799 self.tr("""There are no missing entries"""
800 """ available/selected.""")) 800 """ available/selected."""))
801 return 801 return
802 802
803 self.vcs.vcsRevert(names) 803 self.vcs.vcsRevert(names)
804 self.on_refreshButton_clicked() 804 self.on_refreshButton_clicked()
805 self.vcs.checkVCSStatus() 805 self.vcs.checkVCSStatus()
811 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 811 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
812 for itm in self.__getModifiedItems()] 812 for itm in self.__getModifiedItems()]
813 if not names: 813 if not names:
814 E5MessageBox.information( 814 E5MessageBox.information(
815 self, 815 self,
816 self.trUtf8("Differences"), 816 self.tr("Differences"),
817 self.trUtf8("""There are no uncommitted changes""" 817 self.tr("""There are no uncommitted changes"""
818 """ available/selected.""")) 818 """ available/selected."""))
819 return 819 return
820 820
821 if self.diff is None: 821 if self.diff is None:
822 from .SvnDiffDialog import SvnDiffDialog 822 from .SvnDiffDialog import SvnDiffDialog
823 self.diff = SvnDiffDialog(self.vcs) 823 self.diff = SvnDiffDialog(self.vcs)
832 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 832 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
833 for itm in self.__getModifiedItems()] 833 for itm in self.__getModifiedItems()]
834 if not names: 834 if not names:
835 E5MessageBox.information( 835 E5MessageBox.information(
836 self, 836 self,
837 self.trUtf8("Side-by-Side Diff"), 837 self.tr("Side-by-Side Diff"),
838 self.trUtf8("""There are no uncommitted changes""" 838 self.tr("""There are no uncommitted changes"""
839 """ available/selected.""")) 839 """ available/selected."""))
840 return 840 return
841 elif len(names) > 1: 841 elif len(names) > 1:
842 E5MessageBox.information( 842 E5MessageBox.information(
843 self, 843 self,
844 self.trUtf8("Side-by-Side Diff"), 844 self.tr("Side-by-Side Diff"),
845 self.trUtf8("""Only one file with uncommitted changes""" 845 self.tr("""Only one file with uncommitted changes"""
846 """ must be selected.""")) 846 """ must be selected."""))
847 return 847 return
848 848
849 self.vcs.svnSbsDiff(names[0]) 849 self.vcs.svnSbsDiff(names[0])
850 850
851 def __lock(self): 851 def __lock(self):
855 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 855 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
856 for itm in self.__getLockActionItems(self.unlockedIndicators)] 856 for itm in self.__getLockActionItems(self.unlockedIndicators)]
857 if not names: 857 if not names:
858 E5MessageBox.information( 858 E5MessageBox.information(
859 self, 859 self,
860 self.trUtf8("Lock"), 860 self.tr("Lock"),
861 self.trUtf8("""There are no unlocked files""" 861 self.tr("""There are no unlocked files"""
862 """ available/selected.""")) 862 """ available/selected."""))
863 return 863 return
864 864
865 self.vcs.svnLock(names, parent=self) 865 self.vcs.svnLock(names, parent=self)
866 self.on_refreshButton_clicked() 866 self.on_refreshButton_clicked()
867 867
872 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 872 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
873 for itm in self.__getLockActionItems(self.lockedIndicators)] 873 for itm in self.__getLockActionItems(self.lockedIndicators)]
874 if not names: 874 if not names:
875 E5MessageBox.information( 875 E5MessageBox.information(
876 self, 876 self,
877 self.trUtf8("Unlock"), 877 self.tr("Unlock"),
878 self.trUtf8("""There are no locked files""" 878 self.tr("""There are no locked files"""
879 """ available/selected.""")) 879 """ available/selected."""))
880 return 880 return
881 881
882 self.vcs.svnUnlock(names, parent=self) 882 self.vcs.svnUnlock(names, parent=self)
883 self.on_refreshButton_clicked() 883 self.on_refreshButton_clicked()
884 884
890 for itm in self.__getLockActionItems( 890 for itm in self.__getLockActionItems(
891 self.stealBreakLockIndicators)] 891 self.stealBreakLockIndicators)]
892 if not names: 892 if not names:
893 E5MessageBox.information( 893 E5MessageBox.information(
894 self, 894 self,
895 self.trUtf8("Break Lock"), 895 self.tr("Break Lock"),
896 self.trUtf8("""There are no locked files""" 896 self.tr("""There are no locked files"""
897 """ available/selected.""")) 897 """ available/selected."""))
898 return 898 return
899 899
900 self.vcs.svnUnlock(names, parent=self, breakIt=True) 900 self.vcs.svnUnlock(names, parent=self, breakIt=True)
901 self.on_refreshButton_clicked() 901 self.on_refreshButton_clicked()
902 902
908 for itm in self.__getLockActionItems( 908 for itm in self.__getLockActionItems(
909 self.stealBreakLockIndicators)] 909 self.stealBreakLockIndicators)]
910 if not names: 910 if not names:
911 E5MessageBox.information( 911 E5MessageBox.information(
912 self, 912 self,
913 self.trUtf8("Steal Lock"), 913 self.tr("Steal Lock"),
914 self.trUtf8("""There are no locked files""" 914 self.tr("""There are no locked files"""
915 """ available/selected.""")) 915 """ available/selected."""))
916 return 916 return
917 917
918 self.vcs.svnLock(names, parent=self, stealIt=True) 918 self.vcs.svnLock(names, parent=self, stealIt=True)
919 self.on_refreshButton_clicked() 919 self.on_refreshButton_clicked()
920 920
925 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 925 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
926 for itm in self.__getNonChangelistItems()] 926 for itm in self.__getNonChangelistItems()]
927 if not names: 927 if not names:
928 E5MessageBox.information( 928 E5MessageBox.information(
929 self, 929 self,
930 self.trUtf8("Remove from Changelist"), 930 self.tr("Remove from Changelist"),
931 self.trUtf8( 931 self.tr(
932 """There are no files available/selected not """ 932 """There are no files available/selected not """
933 """belonging to a changelist.""" 933 """belonging to a changelist."""
934 ) 934 )
935 ) 935 )
936 return 936 return
944 names = [os.path.join(self.dname, itm.text(self.__pathColumn)) 944 names = [os.path.join(self.dname, itm.text(self.__pathColumn))
945 for itm in self.__getChangelistItems()] 945 for itm in self.__getChangelistItems()]
946 if not names: 946 if not names:
947 E5MessageBox.information( 947 E5MessageBox.information(
948 self, 948 self,
949 self.trUtf8("Remove from Changelist"), 949 self.tr("Remove from Changelist"),
950 self.trUtf8( 950 self.tr(
951 """There are no files available/selected belonging""" 951 """There are no files available/selected belonging"""
952 """ to a changelist.""" 952 """ to a changelist."""
953 ) 953 )
954 ) 954 )
955 return 955 return

eric ide

mercurial