eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py

changeset 7771
787a6b3f8c9f
parent 7360
9190402e4505
child 7774
9eed155411f0
equal deleted inserted replaced
7770:49f3377aebf1 7771:787a6b3f8c9f
12 import os 12 import os
13 13
14 import pysvn 14 import pysvn
15 15
16 from PyQt5.QtCore import QMutexLocker, Qt, pyqtSlot 16 from PyQt5.QtCore import QMutexLocker, Qt, pyqtSlot
17 from PyQt5.QtGui import QCursor
18 from PyQt5.QtWidgets import ( 17 from PyQt5.QtWidgets import (
19 QWidget, QHeaderView, QApplication, QMenu, QDialogButtonBox, 18 QWidget, QHeaderView, QApplication, QMenu, QDialogButtonBox,
20 QTreeWidgetItem 19 QTreeWidgetItem
21 ) 20 )
22 21
23 from E5Gui.E5Application import e5App 22 from E5Gui.E5Application import e5App
24 from E5Gui import E5MessageBox 23 from E5Gui import E5MessageBox
24 from E5Gui.E5OverrideCursor import E5OverrideCursor
25 25
26 from .SvnConst import svnStatusMap 26 from .SvnConst import svnStatusMap
27 from .SvnDialogMixin import SvnDialogMixin 27 from .SvnDialogMixin import SvnDialogMixin
28 28
29 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog 29 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog
283 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 283 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
284 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 284 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
285 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 285 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
286 self.refreshButton.setEnabled(False) 286 self.refreshButton.setEnabled(False)
287 287
288 QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
289 QApplication.processEvents()
290
291 self.args = fn 288 self.args = fn
292 289
293 self.setWindowTitle(self.tr('Subversion Status')) 290 self.setWindowTitle(self.tr('Subversion Status'))
294 self.activateWindow() 291 self.activateWindow()
295 self.raise_() 292 self.raise_()
310 hideLockColumns = True 307 hideLockColumns = True
311 hideUpToDateColumn = True 308 hideUpToDateColumn = True
312 hideHistoryColumn = True 309 hideHistoryColumn = True
313 hideSwitchedColumn = True 310 hideSwitchedColumn = True
314 311
315 locker = QMutexLocker(self.vcs.vcsExecutionMutex) 312 with E5OverrideCursor():
316 cwd = os.getcwd() 313 locker = QMutexLocker(self.vcs.vcsExecutionMutex)
317 os.chdir(self.dname) 314 cwd = os.getcwd()
318 try: 315 os.chdir(self.dname)
319 for name in fnames: 316 try:
320 # step 1: determine changelists and their files 317 for name in fnames:
321 changelistsDict = {} 318 # step 1: determine changelists and their files
322 if hasattr(self.client, 'get_changelist'): 319 changelistsDict = {}
323 if recurse: 320 if hasattr(self.client, 'get_changelist'):
324 depth = pysvn.depth.infinity 321 if recurse:
325 else: 322 depth = pysvn.depth.infinity
326 depth = pysvn.depth.immediate 323 else:
327 changelists = self.client.get_changelist(name, depth=depth) 324 depth = pysvn.depth.immediate
328 for fpath, changelist in changelists: 325 changelists = self.client.get_changelist(
329 fpath = Utilities.normcasepath(fpath) 326 name, depth=depth)
330 changelistsDict[fpath] = changelist 327 for fpath, changelist in changelists:
331 hideChangelistColumn = ( 328 fpath = Utilities.normcasepath(fpath)
332 hideChangelistColumn and len(changelistsDict) == 0 329 changelistsDict[fpath] = changelist
333 ) 330 hideChangelistColumn = (
334 331 hideChangelistColumn and len(changelistsDict) == 0
335 # step 2: determine status of files
336 allFiles = self.client.status(name, recurse=recurse,
337 get_all=verbose, ignore=True,
338 update=update)
339 counter = 0
340 for file in allFiles:
341 uptodate = True
342 if file.repos_text_status != pysvn.wc_status_kind.none:
343 uptodate = (
344 uptodate and
345 file.repos_text_status !=
346 pysvn.wc_status_kind.modified
347 )
348 if file.repos_prop_status != pysvn.wc_status_kind.none:
349 uptodate = (
350 uptodate and
351 file.repos_prop_status !=
352 pysvn.wc_status_kind.modified
353 )
354
355 lockState = " "
356 if (
357 file.entry is not None and
358 hasattr(file.entry, 'lock_token') and
359 file.entry.lock_token is not None
360 ):
361 lockState = "L"
362 if hasattr(file, 'repos_lock') and update:
363 if lockState == "L" and file.repos_lock is None:
364 lockState = "B"
365 elif lockState == " " and file.repos_lock is not None:
366 lockState = "O"
367 elif (
368 lockState == "L" and
369 file.repos_lock is not None and
370 file.entry.lock_token !=
371 file.repos_lock["token"]
372 ):
373 lockState = "S"
374
375 fpath = Utilities.normcasepath(
376 os.path.join(self.dname, file.path))
377 if fpath in changelistsDict:
378 changelist = changelistsDict[fpath]
379 else:
380 changelist = ""
381
382 hidePropertyStatusColumn = (
383 hidePropertyStatusColumn and
384 file.prop_status in [
385 pysvn.wc_status_kind.none,
386 pysvn.wc_status_kind.normal
387 ]
388 )
389 hideLockColumns = (
390 hideLockColumns and
391 not file.is_locked and
392 lockState == " "
393 )
394 hideUpToDateColumn = hideUpToDateColumn and uptodate
395 hideHistoryColumn = (
396 hideHistoryColumn and
397 not file.is_copied
398 )
399 hideSwitchedColumn = (
400 hideSwitchedColumn and
401 not file.is_switched
402 ) 332 )
403 333
404 self.__generateItem( 334 # step 2: determine status of files
405 changelist, 335 allFiles = self.client.status(name, recurse=recurse,
406 file.text_status, 336 get_all=verbose, ignore=True,
407 file.prop_status, 337 update=update)
408 file.is_locked, 338 counter = 0
409 file.is_copied, 339 for file in allFiles:
410 file.is_switched, 340 uptodate = True
411 lockState, 341 if file.repos_text_status != pysvn.wc_status_kind.none:
412 uptodate, 342 uptodate = (
413 file.entry and file.entry.revision.number or "", 343 uptodate and
414 file.entry and file.entry.commit_revision.number or "", 344 file.repos_text_status !=
415 file.entry and file.entry.commit_author or "", 345 pysvn.wc_status_kind.modified
416 file.path 346 )
417 ) 347 if file.repos_prop_status != pysvn.wc_status_kind.none:
418 counter += 1 348 uptodate = (
419 if counter == 30: 349 uptodate and
420 # check for cancel every 30 items 350 file.repos_prop_status !=
421 counter = 0 351 pysvn.wc_status_kind.modified
422 if self._clientCancelCallback(): 352 )
423 break 353
424 if self._clientCancelCallback(): 354 lockState = " "
425 break 355 if (
426 except pysvn.ClientError as e: 356 file.entry is not None and
427 self.__showError(e.args[0] + '\n') 357 hasattr(file.entry, 'lock_token') and
428 358 file.entry.lock_token is not None
429 self.statusList.setColumnHidden(self.__propStatusColumn, 359 ):
430 hidePropertyStatusColumn) 360 lockState = "L"
431 self.statusList.setColumnHidden(self.__lockedColumn, 361 if hasattr(file, 'repos_lock') and update:
432 hideLockColumns) 362 if lockState == "L" and file.repos_lock is None:
433 self.statusList.setColumnHidden(self.__lockinfoColumn, 363 lockState = "B"
434 hideLockColumns) 364 elif (
435 self.statusList.setColumnHidden(self.__upToDateColumn, 365 lockState == " " and
436 hideUpToDateColumn) 366 file.repos_lock is not None
437 self.statusList.setColumnHidden(self.__historyColumn, 367 ):
438 hideHistoryColumn) 368 lockState = "O"
439 self.statusList.setColumnHidden(self.__switchedColumn, 369 elif (
440 hideSwitchedColumn) 370 lockState == "L" and
441 self.statusList.setColumnHidden(self.__changelistColumn, 371 file.repos_lock is not None and
442 hideChangelistColumn) 372 file.entry.lock_token !=
443 373 file.repos_lock["token"]
444 locker.unlock() 374 ):
375 lockState = "S"
376
377 fpath = Utilities.normcasepath(
378 os.path.join(self.dname, file.path))
379 if fpath in changelistsDict:
380 changelist = changelistsDict[fpath]
381 else:
382 changelist = ""
383
384 hidePropertyStatusColumn = (
385 hidePropertyStatusColumn and
386 file.prop_status in [
387 pysvn.wc_status_kind.none,
388 pysvn.wc_status_kind.normal
389 ]
390 )
391 hideLockColumns = (
392 hideLockColumns and
393 not file.is_locked and
394 lockState == " "
395 )
396 hideUpToDateColumn = hideUpToDateColumn and uptodate
397 hideHistoryColumn = (
398 hideHistoryColumn and
399 not file.is_copied
400 )
401 hideSwitchedColumn = (
402 hideSwitchedColumn and
403 not file.is_switched
404 )
405
406 self.__generateItem(
407 changelist,
408 file.text_status,
409 file.prop_status,
410 file.is_locked,
411 file.is_copied,
412 file.is_switched,
413 lockState,
414 uptodate,
415 file.entry.revision.number if file.entry else "",
416 file.entry.commit_revision.number
417 if file.entry else "",
418 file.entry.commit_author if file.entry else "",
419 file.path
420 )
421 counter += 1
422 if counter == 30:
423 # check for cancel every 30 items
424 counter = 0
425 if self._clientCancelCallback():
426 break
427 if self._clientCancelCallback():
428 break
429 except pysvn.ClientError as e:
430 self.__showError(e.args[0] + '\n')
431
432 self.statusList.setColumnHidden(self.__propStatusColumn,
433 hidePropertyStatusColumn)
434 self.statusList.setColumnHidden(self.__lockedColumn,
435 hideLockColumns)
436 self.statusList.setColumnHidden(self.__lockinfoColumn,
437 hideLockColumns)
438 self.statusList.setColumnHidden(self.__upToDateColumn,
439 hideUpToDateColumn)
440 self.statusList.setColumnHidden(self.__historyColumn,
441 hideHistoryColumn)
442 self.statusList.setColumnHidden(self.__switchedColumn,
443 hideSwitchedColumn)
444 self.statusList.setColumnHidden(self.__changelistColumn,
445 hideChangelistColumn)
446
447 locker.unlock()
445 self.__finish() 448 self.__finish()
446 os.chdir(cwd) 449 os.chdir(cwd)
447 450
448 def __finish(self): 451 def __finish(self):
449 """ 452 """
450 Private slot called when the process finished or the user pressed 453 Private slot called when the process finished or the user pressed
451 the button. 454 the button.
452 """ 455 """
453 QApplication.restoreOverrideCursor()
454
455 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 456 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True)
456 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 457 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
457 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 458 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True)
458 459
459 self.refreshButton.setEnabled(True) 460 self.refreshButton.setEnabled(True)

eric ide

mercurial