Plugins/VcsPlugins/vcsSubversion/SvnStatusDialog.py

changeset 945
8cd4d08fa9f6
parent 917
746c54b643eb
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
19 from .SvnDiffDialog import SvnDiffDialog 19 from .SvnDiffDialog import SvnDiffDialog
20 20
21 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog 21 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog
22 22
23 import Preferences 23 import Preferences
24
24 25
25 class SvnStatusDialog(QWidget, Ui_SvnStatusDialog): 26 class SvnStatusDialog(QWidget, Ui_SvnStatusDialog):
26 """ 27 """
27 Class implementing a dialog to show the output of the svn status command 28 Class implementing a dialog to show the output of the svn status command
28 process. 29 process.
29 """ 30 """
30 def __init__(self, vcs, parent = None): 31 def __init__(self, vcs, parent=None):
31 """ 32 """
32 Constructor 33 Constructor
33 34
34 @param vcs reference to the vcs object 35 @param vcs reference to the vcs object
35 @param parent parent widget (QWidget) 36 @param parent parent widget (QWidget)
62 self.process = None 63 self.process = None
63 self.vcs = vcs 64 self.vcs = vcs
64 self.vcs.committed.connect(self.__committed) 65 self.vcs.committed.connect(self.__committed)
65 66
66 self.statusList.headerItem().setText(self.__lastColumn, "") 67 self.statusList.headerItem().setText(self.__lastColumn, "")
67 self.statusList.header().setSortIndicator(self.__pathColumn, 68 self.statusList.header().setSortIndicator(self.__pathColumn,
68 Qt.AscendingOrder) 69 Qt.AscendingOrder)
69 if self.vcs.versionStr < '1.5.0': 70 if self.vcs.versionStr < '1.5.0':
70 self.statusList.header().hideSection(self.__changelistColumn) 71 self.statusList.header().hideSection(self.__changelistColumn)
71 72
72 self.menuactions = [] 73 self.menuactions = []
111 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 112 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu)
112 self.statusList.customContextMenuRequested.connect( 113 self.statusList.customContextMenuRequested.connect(
113 self.__showContextMenu) 114 self.__showContextMenu)
114 115
115 self.modifiedIndicators = [ 116 self.modifiedIndicators = [
116 self.trUtf8('added'), 117 self.trUtf8('added'),
117 self.trUtf8('deleted'), 118 self.trUtf8('deleted'),
118 self.trUtf8('modified'), 119 self.trUtf8('modified'),
119 ] 120 ]
120 121
121 self.missingIndicators = [ 122 self.missingIndicators = [
122 self.trUtf8('missing'), 123 self.trUtf8('missing'),
123 ] 124 ]
124 125
125 self.unversionedIndicators = [ 126 self.unversionedIndicators = [
126 self.trUtf8('unversioned'), 127 self.trUtf8('unversioned'),
127 ] 128 ]
128 129
129 self.lockedIndicators = [ 130 self.lockedIndicators = [
130 self.trUtf8('locked'), 131 self.trUtf8('locked'),
131 ] 132 ]
132 133
133 self.stealBreakLockIndicators = [ 134 self.stealBreakLockIndicators = [
134 self.trUtf8('other lock'), 135 self.trUtf8('other lock'),
135 self.trUtf8('stolen lock'), 136 self.trUtf8('stolen lock'),
136 self.trUtf8('broken lock'), 137 self.trUtf8('broken lock'),
137 ] 138 ]
138 139
139 self.unlockedIndicators = [ 140 self.unlockedIndicators = [
140 self.trUtf8('not locked'), 141 self.trUtf8('not locked'),
141 ] 142 ]
142 143
143 self.status = { 144 self.status = {
144 ' ' : self.trUtf8('normal'), 145 ' ': self.trUtf8('normal'),
145 'A' : self.trUtf8('added'), 146 'A': self.trUtf8('added'),
146 'D' : self.trUtf8('deleted'), 147 'D': self.trUtf8('deleted'),
147 'M' : self.trUtf8('modified'), 148 'M': self.trUtf8('modified'),
148 'R' : self.trUtf8('replaced'), 149 'R': self.trUtf8('replaced'),
149 'C' : self.trUtf8('conflict'), 150 'C': self.trUtf8('conflict'),
150 'X' : self.trUtf8('external'), 151 'X': self.trUtf8('external'),
151 'I' : self.trUtf8('ignored'), 152 'I': self.trUtf8('ignored'),
152 '?' : self.trUtf8('unversioned'), 153 '?': self.trUtf8('unversioned'),
153 '!' : self.trUtf8('missing'), 154 '!': self.trUtf8('missing'),
154 '~' : self.trUtf8('type error'), 155 '~': self.trUtf8('type error'),
155 } 156 }
156 self.propStatus = { 157 self.propStatus = {
157 ' ' : self.trUtf8('normal'), 158 ' ': self.trUtf8('normal'),
158 'M' : self.trUtf8('modified'), 159 'M': self.trUtf8('modified'),
159 'C' : self.trUtf8('conflict'), 160 'C': self.trUtf8('conflict'),
160 } 161 }
161 self.locked = { 162 self.locked = {
162 ' ' : self.trUtf8('no'), 163 ' ': self.trUtf8('no'),
163 'L' : self.trUtf8('yes'), 164 'L': self.trUtf8('yes'),
164 } 165 }
165 self.history = { 166 self.history = {
166 ' ' : self.trUtf8('no'), 167 ' ': self.trUtf8('no'),
167 '+' : self.trUtf8('yes'), 168 '+': self.trUtf8('yes'),
168 } 169 }
169 self.switched = { 170 self.switched = {
170 ' ' : self.trUtf8('no'), 171 ' ': self.trUtf8('no'),
171 'S' : self.trUtf8('yes'), 172 'S': self.trUtf8('yes'),
172 } 173 }
173 self.lockinfo = { 174 self.lockinfo = {
174 ' ' : self.trUtf8('not locked'), 175 ' ': self.trUtf8('not locked'),
175 'K' : self.trUtf8('locked'), 176 'K': self.trUtf8('locked'),
176 'O' : self.trUtf8('other lock'), 177 'O': self.trUtf8('other lock'),
177 'T' : self.trUtf8('stolen lock'), 178 'T': self.trUtf8('stolen lock'),
178 'B' : self.trUtf8('broken lock'), 179 'B': self.trUtf8('broken lock'),
179 } 180 }
180 self.uptodate = { 181 self.uptodate = {
181 ' ' : self.trUtf8('yes'), 182 ' ': self.trUtf8('yes'),
182 '*' : self.trUtf8('no'), 183 '*': self.trUtf8('no'),
183 } 184 }
184 185
185 self.rx_status = \ 186 self.rx_status = \
186 QRegExp('(.{8})\\s+([0-9-]+)\\s+([0-9?]+)\\s+([\\w?]+)\\s+(.+)\\s*') 187 QRegExp('(.{8})\\s+([0-9-]+)\\s+([0-9?]+)\\s+([\\w?]+)\\s+(.+)\\s*')
187 # flags (8 anything), revision, changed rev, author, path 188 # flags (8 anything), revision, changed rev, author, path
197 198
198 def __resort(self): 199 def __resort(self):
199 """ 200 """
200 Private method to resort the tree. 201 Private method to resort the tree.
201 """ 202 """
202 self.statusList.sortItems(self.statusList.sortColumn(), 203 self.statusList.sortItems(self.statusList.sortColumn(),
203 self.statusList.header().sortIndicatorOrder()) 204 self.statusList.header().sortIndicatorOrder())
204 205
205 def __resizeColumns(self): 206 def __resizeColumns(self):
206 """ 207 """
207 Private method to resize the list columns. 208 Private method to resize the list columns.
237 self.currentChangelist == "": 238 self.currentChangelist == "":
238 return 239 return
239 240
240 statusText = self.status[status] 241 statusText = self.status[status]
241 itm = QTreeWidgetItem(self.statusList, [ 242 itm = QTreeWidgetItem(self.statusList, [
242 self.currentChangelist, 243 self.currentChangelist,
243 statusText, 244 statusText,
244 self.propStatus[propStatus], 245 self.propStatus[propStatus],
245 self.locked[locked], 246 self.locked[locked],
246 self.history[history], 247 self.history[history],
247 self.switched[switched], 248 self.switched[switched],
248 self.lockinfo[lockinfo], 249 self.lockinfo[lockinfo],
249 self.uptodate[uptodate], 250 self.uptodate[uptodate],
250 "{0:7}".format(str(revision)), 251 "{0:7}".format(str(revision)),
251 "{0:7}".format(str(change)), 252 "{0:7}".format(str(change)),
252 author, 253 author,
253 path, 254 path,
254 ]) 255 ])
255 256
256 itm.setTextAlignment(1, Qt.AlignLeft) 257 itm.setTextAlignment(1, Qt.AlignLeft)
257 itm.setTextAlignment(2, Qt.AlignHCenter) 258 itm.setTextAlignment(2, Qt.AlignHCenter)
258 itm.setTextAlignment(3, Qt.AlignHCenter) 259 itm.setTextAlignment(3, Qt.AlignHCenter)
401 402
402 self.statusList.doItemsLayout() 403 self.statusList.doItemsLayout()
403 self.__resort() 404 self.__resort()
404 self.__resizeColumns() 405 self.__resizeColumns()
405 406
406 self.statusList.setColumnHidden(self.__changelistColumn, 407 self.statusList.setColumnHidden(self.__changelistColumn,
407 not self.changelistFound) 408 not self.changelistFound)
408 self.statusList.setColumnHidden(self.__propStatusColumn, 409 self.statusList.setColumnHidden(self.__propStatusColumn,
409 self.hidePropertyStatusColumn) 410 self.hidePropertyStatusColumn)
410 self.statusList.setColumnHidden(self.__lockedColumn, 411 self.statusList.setColumnHidden(self.__lockedColumn,
411 self.hideLockColumns) 412 self.hideLockColumns)
412 self.statusList.setColumnHidden(self.__lockinfoColumn, 413 self.statusList.setColumnHidden(self.__lockinfoColumn,
413 self.hideLockColumns) 414 self.hideLockColumns)
414 self.statusList.setColumnHidden(self.__upToDateColumn, 415 self.statusList.setColumnHidden(self.__upToDateColumn,
415 self.hideUpToDateColumn) 416 self.hideUpToDateColumn)
416 self.statusList.setColumnHidden(self.__historyColumn, 417 self.statusList.setColumnHidden(self.__historyColumn,
417 self.hideHistoryColumn) 418 self.hideHistoryColumn)
418 self.statusList.setColumnHidden(self.__switchedColumn, 419 self.statusList.setColumnHidden(self.__switchedColumn,
419 self.hideSwitchedColumn) 420 self.hideSwitchedColumn)
420 421
421 self.__updateButtons() 422 self.__updateButtons()
422 self.__updateCommitButton() 423 self.__updateCommitButton()
423 424
452 """ 453 """
453 if self.process is not None: 454 if self.process is not None:
454 self.process.setReadChannel(QProcess.StandardOutput) 455 self.process.setReadChannel(QProcess.StandardOutput)
455 456
456 while self.process.canReadLine(): 457 while self.process.canReadLine():
457 s = str(self.process.readLine(), 458 s = str(self.process.readLine(),
458 Preferences.getSystem("IOEncoding"), 459 Preferences.getSystem("IOEncoding"),
459 'replace') 460 'replace')
460 if self.rx_status.exactMatch(s): 461 if self.rx_status.exactMatch(s):
461 flags = self.rx_status.cap(1) 462 flags = self.rx_status.cap(1)
462 rev = self.rx_status.cap(2) 463 rev = self.rx_status.cap(2)
463 change = self.rx_status.cap(3) 464 change = self.rx_status.cap(3)
485 It reads the error output of the process and inserts it into the 486 It reads the error output of the process and inserts it into the
486 error pane. 487 error pane.
487 """ 488 """
488 if self.process is not None: 489 if self.process is not None:
489 self.errorGroup.show() 490 self.errorGroup.show()
490 s = str(self.process.readAllStandardError(), 491 s = str(self.process.readAllStandardError(),
491 Preferences.getSystem("IOEncoding"), 492 Preferences.getSystem("IOEncoding"),
492 'replace') 493 'replace')
493 self.errors.insertPlainText(s) 494 self.errors.insertPlainText(s)
494 self.errors.ensureCursorVisible() 495 self.errors.ensureCursorVisible()
495 496
496 def on_passwordCheckBox_toggled(self, isOn): 497 def on_passwordCheckBox_toggled(self, isOn):
776 self.trUtf8("Lock"), 777 self.trUtf8("Lock"),
777 self.trUtf8("""There are no unlocked files""" 778 self.trUtf8("""There are no unlocked files"""
778 """ available/selected.""")) 779 """ available/selected."""))
779 return 780 return
780 781
781 self.vcs.svnLock(names, parent = self) 782 self.vcs.svnLock(names, parent=self)
782 self.on_refreshButton_clicked() 783 self.on_refreshButton_clicked()
783 784
784 def __unlock(self): 785 def __unlock(self):
785 """ 786 """
786 Private slot to handle the Unlock context menu entry. 787 Private slot to handle the Unlock context menu entry.
792 self.trUtf8("Unlock"), 793 self.trUtf8("Unlock"),
793 self.trUtf8("""There are no locked files""" 794 self.trUtf8("""There are no locked files"""
794 """ available/selected.""")) 795 """ available/selected."""))
795 return 796 return
796 797
797 self.vcs.svnUnlock(names, parent = self) 798 self.vcs.svnUnlock(names, parent=self)
798 self.on_refreshButton_clicked() 799 self.on_refreshButton_clicked()
799 800
800 def __breakLock(self): 801 def __breakLock(self):
801 """ 802 """
802 Private slot to handle the Break Lock context menu entry. 803 Private slot to handle the Break Lock context menu entry.
809 self.trUtf8("Break Lock"), 810 self.trUtf8("Break Lock"),
810 self.trUtf8("""There are no locked files""" 811 self.trUtf8("""There are no locked files"""
811 """ available/selected.""")) 812 """ available/selected."""))
812 return 813 return
813 814
814 self.vcs.svnUnlock(names, parent = self, breakIt = True) 815 self.vcs.svnUnlock(names, parent=self, breakIt=True)
815 self.on_refreshButton_clicked() 816 self.on_refreshButton_clicked()
816 817
817 def __stealLock(self): 818 def __stealLock(self):
818 """ 819 """
819 Private slot to handle the Break Lock context menu entry. 820 Private slot to handle the Break Lock context menu entry.

eric ide

mercurial