eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py

changeset 7774
9eed155411f0
parent 7771
787a6b3f8c9f
child 7780
41420f82c0ac
equal deleted inserted replaced
7773:fe42bd17d4fe 7774:9eed155411f0
11 11
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 Qt, pyqtSlot
17 from PyQt5.QtWidgets import ( 17 from PyQt5.QtWidgets import (
18 QWidget, QHeaderView, QApplication, QMenu, QDialogButtonBox, 18 QWidget, QHeaderView, QApplication, QMenu, QDialogButtonBox,
19 QTreeWidgetItem 19 QTreeWidgetItem
20 ) 20 )
21 21
22 from E5Gui.E5Application import e5App 22 from E5Gui.E5Application import e5App
23 from E5Gui import E5MessageBox 23 from E5Gui import E5MessageBox
24 from E5Gui.E5OverrideCursor import E5OverrideCursor 24 from E5Gui.E5OverrideCursor import E5OverrideCursor
25
26 from E5Utilities.E5MutexLocker import E5MutexLocker
25 27
26 from .SvnConst import svnStatusMap 28 from .SvnConst import svnStatusMap
27 from .SvnDialogMixin import SvnDialogMixin 29 from .SvnDialogMixin import SvnDialogMixin
28 30
29 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog 31 from .Ui_SvnStatusDialog import Ui_SvnStatusDialog
308 hideUpToDateColumn = True 310 hideUpToDateColumn = True
309 hideHistoryColumn = True 311 hideHistoryColumn = True
310 hideSwitchedColumn = True 312 hideSwitchedColumn = True
311 313
312 with E5OverrideCursor(): 314 with E5OverrideCursor():
313 locker = QMutexLocker(self.vcs.vcsExecutionMutex)
314 cwd = os.getcwd() 315 cwd = os.getcwd()
315 os.chdir(self.dname) 316 os.chdir(self.dname)
316 try: 317 try:
317 for name in fnames: 318 with E5MutexLocker(self.vcs.vcsExecutionMutex):
318 # step 1: determine changelists and their files 319 for name in fnames:
319 changelistsDict = {} 320 # step 1: determine changelists and their files
320 if hasattr(self.client, 'get_changelist'): 321 changelistsDict = {}
321 if recurse: 322 if hasattr(self.client, 'get_changelist'):
322 depth = pysvn.depth.infinity 323 if recurse:
323 else: 324 depth = pysvn.depth.infinity
324 depth = pysvn.depth.immediate 325 else:
325 changelists = self.client.get_changelist( 326 depth = pysvn.depth.immediate
326 name, depth=depth) 327 changelists = self.client.get_changelist(
327 for fpath, changelist in changelists: 328 name, depth=depth)
328 fpath = Utilities.normcasepath(fpath) 329 for fpath, changelist in changelists:
329 changelistsDict[fpath] = changelist 330 fpath = Utilities.normcasepath(fpath)
330 hideChangelistColumn = ( 331 changelistsDict[fpath] = changelist
331 hideChangelistColumn and len(changelistsDict) == 0 332 hideChangelistColumn = (
332 ) 333 hideChangelistColumn and len(changelistsDict) == 0
333
334 # step 2: determine status of files
335 allFiles = self.client.status(name, recurse=recurse,
336 get_all=verbose, ignore=True,
337 update=update)
338 counter = 0
339 for file in allFiles:
340 uptodate = True
341 if file.repos_text_status != pysvn.wc_status_kind.none:
342 uptodate = (
343 uptodate and
344 file.repos_text_status !=
345 pysvn.wc_status_kind.modified
346 )
347 if file.repos_prop_status != pysvn.wc_status_kind.none:
348 uptodate = (
349 uptodate and
350 file.repos_prop_status !=
351 pysvn.wc_status_kind.modified
352 )
353
354 lockState = " "
355 if (
356 file.entry is not None and
357 hasattr(file.entry, 'lock_token') and
358 file.entry.lock_token is not None
359 ):
360 lockState = "L"
361 if hasattr(file, 'repos_lock') and update:
362 if lockState == "L" and file.repos_lock is None:
363 lockState = "B"
364 elif (
365 lockState == " " and
366 file.repos_lock is not None
367 ):
368 lockState = "O"
369 elif (
370 lockState == "L" and
371 file.repos_lock is not None and
372 file.entry.lock_token !=
373 file.repos_lock["token"]
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 ) 334 )
405 335
406 self.__generateItem( 336 # step 2: determine status of files
407 changelist, 337 allFiles = self.client.status(
408 file.text_status, 338 name, recurse=recurse, get_all=verbose,
409 file.prop_status, 339 ignore=True, update=update)
410 file.is_locked, 340 counter = 0
411 file.is_copied, 341 for file in allFiles:
412 file.is_switched, 342 uptodate = True
413 lockState, 343 if (
414 uptodate, 344 file.repos_text_status !=
415 file.entry.revision.number if file.entry else "", 345 pysvn.wc_status_kind.none
416 file.entry.commit_revision.number 346 ):
417 if file.entry else "", 347 uptodate = (
418 file.entry.commit_author if file.entry else "", 348 uptodate and
419 file.path 349 file.repos_text_status !=
420 ) 350 pysvn.wc_status_kind.modified
421 counter += 1 351 )
422 if counter == 30: 352 if (
423 # check for cancel every 30 items 353 file.repos_prop_status !=
424 counter = 0 354 pysvn.wc_status_kind.none
425 if self._clientCancelCallback(): 355 ):
426 break 356 uptodate = (
427 if self._clientCancelCallback(): 357 uptodate and
428 break 358 file.repos_prop_status !=
359 pysvn.wc_status_kind.modified
360 )
361
362 lockState = " "
363 if (
364 file.entry is not None and
365 hasattr(file.entry, 'lock_token') and
366 file.entry.lock_token is not None
367 ):
368 lockState = "L"
369 if hasattr(file, 'repos_lock') and update:
370 if (
371 lockState == "L" and
372 file.repos_lock is None
373 ):
374 lockState = "B"
375 elif (
376 lockState == " " and
377 file.repos_lock is not None
378 ):
379 lockState = "O"
380 elif (
381 lockState == "L" and
382 file.repos_lock is not None and
383 file.entry.lock_token !=
384 file.repos_lock["token"]
385 ):
386 lockState = "S"
387
388 fpath = Utilities.normcasepath(
389 os.path.join(self.dname, file.path))
390 if fpath in changelistsDict:
391 changelist = changelistsDict[fpath]
392 else:
393 changelist = ""
394
395 hidePropertyStatusColumn = (
396 hidePropertyStatusColumn and
397 file.prop_status in [
398 pysvn.wc_status_kind.none,
399 pysvn.wc_status_kind.normal
400 ]
401 )
402 hideLockColumns = (
403 hideLockColumns and
404 not file.is_locked and
405 lockState == " "
406 )
407 hideUpToDateColumn = (
408 hideUpToDateColumn and uptodate
409 )
410 hideHistoryColumn = (
411 hideHistoryColumn and
412 not file.is_copied
413 )
414 hideSwitchedColumn = (
415 hideSwitchedColumn and
416 not file.is_switched
417 )
418
419 self.__generateItem(
420 changelist,
421 file.text_status,
422 file.prop_status,
423 file.is_locked,
424 file.is_copied,
425 file.is_switched,
426 lockState,
427 uptodate,
428 file.entry.revision.number if file.entry
429 else "",
430 file.entry.commit_revision.number
431 if file.entry else "",
432 file.entry.commit_author if file.entry else "",
433 file.path
434 )
435 counter += 1
436 if counter == 30:
437 # check for cancel every 30 items
438 counter = 0
439 if self._clientCancelCallback():
440 break
441 if self._clientCancelCallback():
442 break
429 except pysvn.ClientError as e: 443 except pysvn.ClientError as e:
430 self.__showError(e.args[0] + '\n') 444 self.__showError(e.args[0] + '\n')
431 445
432 self.statusList.setColumnHidden(self.__propStatusColumn, 446 self.statusList.setColumnHidden(self.__propStatusColumn,
433 hidePropertyStatusColumn) 447 hidePropertyStatusColumn)
441 hideHistoryColumn) 455 hideHistoryColumn)
442 self.statusList.setColumnHidden(self.__switchedColumn, 456 self.statusList.setColumnHidden(self.__switchedColumn,
443 hideSwitchedColumn) 457 hideSwitchedColumn)
444 self.statusList.setColumnHidden(self.__changelistColumn, 458 self.statusList.setColumnHidden(self.__changelistColumn,
445 hideChangelistColumn) 459 hideChangelistColumn)
446
447 locker.unlock()
448 self.__finish() 460 self.__finish()
449 os.chdir(cwd) 461 os.chdir(cwd)
450 462
451 def __finish(self): 463 def __finish(self):
452 """ 464 """

eric ide

mercurial