Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py

changeset 945
8cd4d08fa9f6
parent 917
746c54b643eb
child 1112
8a7d1b9d18db
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
23 from .SvnDiffDialog import SvnDiffDialog 23 from .SvnDiffDialog import SvnDiffDialog
24 24
25 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog 25 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog
26 26
27 import Preferences 27 import Preferences
28
28 29
29 class SvnStatusDialog(QWidget, SvnDialogMixin, Ui_SvnStatusDialog): 30 class SvnStatusDialog(QWidget, SvnDialogMixin, Ui_SvnStatusDialog):
30 """ 31 """
31 Class implementing a dialog to show the output of the svn status command 32 Class implementing a dialog to show the output of the svn status command
32 process. 33 process.
33 """ 34 """
34 def __init__(self, vcs, parent = None): 35 def __init__(self, vcs, parent=None):
35 """ 36 """
36 Constructor 37 Constructor
37 38
38 @param vcs reference to the vcs object 39 @param vcs reference to the vcs object
39 @param parent parent widget (QWidget) 40 @param parent parent widget (QWidget)
53 self.__upToDateColumn = 8 54 self.__upToDateColumn = 8
54 self.__pathColumn = 12 55 self.__pathColumn = 12
55 self.__lastColumn = self.statusList.columnCount() 56 self.__lastColumn = self.statusList.columnCount()
56 57
57 self.refreshButton = \ 58 self.refreshButton = \
58 self.buttonBox.addButton(self.trUtf8("Refresh"), 59 self.buttonBox.addButton(self.trUtf8("Refresh"),
59 QDialogButtonBox.ActionRole) 60 QDialogButtonBox.ActionRole)
60 self.refreshButton.setToolTip( 61 self.refreshButton.setToolTip(
61 self.trUtf8("Press to refresh the status display")) 62 self.trUtf8("Press to refresh the status display"))
62 self.refreshButton.setEnabled(False) 63 self.refreshButton.setEnabled(False)
63 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 64 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
115 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu) 116 self.statusList.setContextMenuPolicy(Qt.CustomContextMenu)
116 self.statusList.customContextMenuRequested.connect( 117 self.statusList.customContextMenuRequested.connect(
117 self.__showContextMenu) 118 self.__showContextMenu)
118 119
119 self.modifiedIndicators = [ 120 self.modifiedIndicators = [
120 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.added]), 121 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.added]),
121 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.deleted]), 122 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.deleted]),
122 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.modified]) 123 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.modified])
123 ] 124 ]
124 125
125 self.missingIndicators = [ 126 self.missingIndicators = [
126 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.missing]), 127 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.missing]),
127 ] 128 ]
128 129
129 self.unversionedIndicators = [ 130 self.unversionedIndicators = [
130 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.unversioned]), 131 self.trUtf8(svnStatusMap[pysvn.wc_status_kind.unversioned]),
131 ] 132 ]
132 133
133 self.lockedIndicators = [ 134 self.lockedIndicators = [
134 self.trUtf8('locked'), 135 self.trUtf8('locked'),
135 ] 136 ]
136 137
137 self.stealBreakLockIndicators = [ 138 self.stealBreakLockIndicators = [
138 self.trUtf8('other lock'), 139 self.trUtf8('other lock'),
139 self.trUtf8('stolen lock'), 140 self.trUtf8('stolen lock'),
140 self.trUtf8('broken lock'), 141 self.trUtf8('broken lock'),
141 ] 142 ]
142 143
143 self.unlockedIndicators = [ 144 self.unlockedIndicators = [
144 self.trUtf8('not locked'), 145 self.trUtf8('not locked'),
145 ] 146 ]
146 147
147 self.lockinfo = { 148 self.lockinfo = {
148 ' ' : self.trUtf8('not locked'), 149 ' ': self.trUtf8('not locked'),
149 'L' : self.trUtf8('locked'), 150 'L': self.trUtf8('locked'),
150 'O' : self.trUtf8('other lock'), 151 'O': self.trUtf8('other lock'),
151 'S' : self.trUtf8('stolen lock'), 152 'S': self.trUtf8('stolen lock'),
152 'B' : self.trUtf8('broken lock'), 153 'B': self.trUtf8('broken lock'),
153 } 154 }
154 self.yesno = [ 155 self.yesno = [
155 self.trUtf8('no'), 156 self.trUtf8('no'),
156 self.trUtf8('yes'), 157 self.trUtf8('yes'),
157 ] 158 ]
158 159
159 self.client = self.vcs.getClient() 160 self.client = self.vcs.getClient()
160 self.client.callback_cancel = \ 161 self.client.callback_cancel = \
161 self._clientCancelCallback 162 self._clientCancelCallback
169 170
170 def __resort(self): 171 def __resort(self):
171 """ 172 """
172 Private method to resort the tree. 173 Private method to resort the tree.
173 """ 174 """
174 self.statusList.sortItems(self.statusList.sortColumn(), 175 self.statusList.sortItems(self.statusList.sortColumn(),
175 self.statusList.header().sortIndicatorOrder()) 176 self.statusList.header().sortIndicatorOrder())
176 177
177 def __resizeColumns(self): 178 def __resizeColumns(self):
178 """ 179 """
179 Private method to resize the list columns. 180 Private method to resize the list columns.
200 @param author author of the last change (string) 201 @param author author of the last change (string)
201 @param path path of the file or directory (string) 202 @param path path of the file or directory (string)
202 """ 203 """
203 statusText = self.trUtf8(svnStatusMap[status]) 204 statusText = self.trUtf8(svnStatusMap[status])
204 itm = QTreeWidgetItem(self.statusList, [ 205 itm = QTreeWidgetItem(self.statusList, [
205 "", 206 "",
206 changelist, 207 changelist,
207 statusText, 208 statusText,
208 self.trUtf8(svnStatusMap[propStatus]), 209 self.trUtf8(svnStatusMap[propStatus]),
209 self.yesno[locked], 210 self.yesno[locked],
210 self.yesno[history], 211 self.yesno[history],
211 self.yesno[switched], 212 self.yesno[switched],
212 self.lockinfo[lockinfo], 213 self.lockinfo[lockinfo],
213 self.yesno[uptodate], 214 self.yesno[uptodate],
214 "{0:7}".format(str(revision)), 215 "{0:7}".format(str(revision)),
215 "{0:7}".format(str(change)), 216 "{0:7}".format(str(change)),
216 author, 217 author,
217 path, 218 path,
218 ]) 219 ])
219 220
220 itm.setTextAlignment(1, Qt.AlignLeft) 221 itm.setTextAlignment(1, Qt.AlignLeft)
221 itm.setTextAlignment(2, Qt.AlignHCenter) 222 itm.setTextAlignment(2, Qt.AlignHCenter)
222 itm.setTextAlignment(3, Qt.AlignHCenter) 223 itm.setTextAlignment(3, Qt.AlignHCenter)
306 changelistsDict[entry[0]] = entry[1] 307 changelistsDict[entry[0]] = entry[1]
307 hideChangelistColumn = hideChangelistColumn and \ 308 hideChangelistColumn = hideChangelistColumn and \
308 len(changelistsDict) == 0 309 len(changelistsDict) == 0
309 310
310 # step 2: determine status of files 311 # step 2: determine status of files
311 allFiles = self.client.status(name, recurse = recurse, 312 allFiles = self.client.status(name, recurse=recurse,
312 get_all=verbose, ignore=True, 313 get_all=verbose, ignore=True,
313 update = update) 314 update=update)
314 counter = 0 315 counter = 0
315 for file in allFiles: 316 for file in allFiles:
316 uptodate = True 317 uptodate = True
317 if file.repos_text_status != pysvn.wc_status_kind.none: 318 if file.repos_text_status != pysvn.wc_status_kind.none:
318 uptodate = uptodate and \ 319 uptodate = uptodate and \
341 else: 342 else:
342 changelist = "" 343 changelist = ""
343 344
344 hidePropertyStatusColumn = hidePropertyStatusColumn and \ 345 hidePropertyStatusColumn = hidePropertyStatusColumn and \
345 file.prop_status in [ 346 file.prop_status in [
346 pysvn.wc_status_kind.none, 347 pysvn.wc_status_kind.none,
347 pysvn.wc_status_kind.normal 348 pysvn.wc_status_kind.normal
348 ] 349 ]
349 hideLockColumns = hideLockColumns and \ 350 hideLockColumns = hideLockColumns and \
350 not file.is_locked and lockState == " " 351 not file.is_locked and lockState == " "
351 hideUpToDateColumn = hideUpToDateColumn and uptodate 352 hideUpToDateColumn = hideUpToDateColumn and uptodate
353 not file.is_copied 354 not file.is_copied
354 hideSwitchedColumn = hideSwitchedColumn and \ 355 hideSwitchedColumn = hideSwitchedColumn and \
355 not file.is_switched 356 not file.is_switched
356 357
357 self.__generateItem( 358 self.__generateItem(
358 changelist, 359 changelist,
359 file.text_status, 360 file.text_status,
360 file.prop_status, 361 file.prop_status,
361 file.is_locked, 362 file.is_locked,
362 file.is_copied, 363 file.is_copied,
363 file.is_switched, 364 file.is_switched,
364 lockState, 365 lockState,
375 if self._clientCancelCallback(): 376 if self._clientCancelCallback():
376 break 377 break
377 if self._clientCancelCallback(): 378 if self._clientCancelCallback():
378 break 379 break
379 except pysvn.ClientError as e: 380 except pysvn.ClientError as e:
380 self.__showError(e.args[0]+'\n') 381 self.__showError(e.args[0] + '\n')
381 382
382 self.statusList.setColumnHidden(self.__propStatusColumn, 383 self.statusList.setColumnHidden(self.__propStatusColumn,
383 hidePropertyStatusColumn) 384 hidePropertyStatusColumn)
384 self.statusList.setColumnHidden(self.__lockedColumn, 385 self.statusList.setColumnHidden(self.__lockedColumn,
385 hideLockColumns) 386 hideLockColumns)
682 self.trUtf8("Lock"), 683 self.trUtf8("Lock"),
683 self.trUtf8("""There are no unlocked files""" 684 self.trUtf8("""There are no unlocked files"""
684 """ available/selected.""")) 685 """ available/selected."""))
685 return 686 return
686 687
687 self.vcs.svnLock(names, parent = self) 688 self.vcs.svnLock(names, parent=self)
688 self.on_refreshButton_clicked() 689 self.on_refreshButton_clicked()
689 690
690 def __unlock(self): 691 def __unlock(self):
691 """ 692 """
692 Private slot to handle the Unlock context menu entry. 693 Private slot to handle the Unlock context menu entry.
698 self.trUtf8("Unlock"), 699 self.trUtf8("Unlock"),
699 self.trUtf8("""There are no locked files""" 700 self.trUtf8("""There are no locked files"""
700 """ available/selected.""")) 701 """ available/selected."""))
701 return 702 return
702 703
703 self.vcs.svnUnlock(names, parent = self) 704 self.vcs.svnUnlock(names, parent=self)
704 self.on_refreshButton_clicked() 705 self.on_refreshButton_clicked()
705 706
706 def __breakLock(self): 707 def __breakLock(self):
707 """ 708 """
708 Private slot to handle the Break Lock context menu entry. 709 Private slot to handle the Break Lock context menu entry.
715 self.trUtf8("Break Lock"), 716 self.trUtf8("Break Lock"),
716 self.trUtf8("""There are no locked files""" 717 self.trUtf8("""There are no locked files"""
717 """ available/selected.""")) 718 """ available/selected."""))
718 return 719 return
719 720
720 self.vcs.svnUnlock(names, parent = self, breakIt = True) 721 self.vcs.svnUnlock(names, parent=self, breakIt=True)
721 self.on_refreshButton_clicked() 722 self.on_refreshButton_clicked()
722 723
723 def __stealLock(self): 724 def __stealLock(self):
724 """ 725 """
725 Private slot to handle the Break Lock context menu entry. 726 Private slot to handle the Break Lock context menu entry.

eric ide

mercurial