eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py

changeset 7774
9eed155411f0
parent 7771
787a6b3f8c9f
child 7780
41420f82c0ac
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py	Sat Oct 10 15:17:29 2020 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/SvnStatusDialog.py	Sat Oct 10 16:03:53 2020 +0200
@@ -13,7 +13,7 @@
 
 import pysvn
 
-from PyQt5.QtCore import QMutexLocker, Qt, pyqtSlot
+from PyQt5.QtCore import Qt, pyqtSlot
 from PyQt5.QtWidgets import (
     QWidget, QHeaderView, QApplication, QMenu, QDialogButtonBox,
     QTreeWidgetItem
@@ -23,6 +23,8 @@
 from E5Gui import E5MessageBox
 from E5Gui.E5OverrideCursor import E5OverrideCursor
 
+from E5Utilities.E5MutexLocker import E5MutexLocker
+
 from .SvnConst import svnStatusMap
 from .SvnDialogMixin import SvnDialogMixin
 
@@ -310,122 +312,134 @@
         hideSwitchedColumn = True
         
         with E5OverrideCursor():
-            locker = QMutexLocker(self.vcs.vcsExecutionMutex)
             cwd = os.getcwd()
             os.chdir(self.dname)
             try:
-                for name in fnames:
-                    # step 1: determine changelists and their files
-                    changelistsDict = {}
-                    if hasattr(self.client, 'get_changelist'):
-                        if recurse:
-                            depth = pysvn.depth.infinity
-                        else:
-                            depth = pysvn.depth.immediate
-                        changelists = self.client.get_changelist(
-                            name, depth=depth)
-                        for fpath, changelist in changelists:
-                            fpath = Utilities.normcasepath(fpath)
-                            changelistsDict[fpath] = changelist
-                    hideChangelistColumn = (
-                        hideChangelistColumn and len(changelistsDict) == 0
-                    )
-                    
-                    # step 2: determine status of files
-                    allFiles = self.client.status(name, recurse=recurse,
-                                                  get_all=verbose, ignore=True,
-                                                  update=update)
-                    counter = 0
-                    for file in allFiles:
-                        uptodate = True
-                        if file.repos_text_status != pysvn.wc_status_kind.none:
-                            uptodate = (
-                                uptodate and
-                                file.repos_text_status !=
-                                pysvn.wc_status_kind.modified
-                            )
-                        if file.repos_prop_status != pysvn.wc_status_kind.none:
-                            uptodate = (
-                                uptodate and
-                                file.repos_prop_status !=
-                                pysvn.wc_status_kind.modified
-                            )
-                        
-                        lockState = " "
-                        if (
-                            file.entry is not None and
-                            hasattr(file.entry, 'lock_token') and
-                            file.entry.lock_token is not None
-                        ):
-                            lockState = "L"
-                        if hasattr(file, 'repos_lock') and update:
-                            if lockState == "L" and file.repos_lock is None:
-                                lockState = "B"
-                            elif (
-                                lockState == " " and
-                                file.repos_lock is not None
-                            ):
-                                lockState = "O"
-                            elif (
-                                lockState == "L" and
-                                file.repos_lock is not None and
-                                file.entry.lock_token !=
-                                    file.repos_lock["token"]
-                            ):
-                                lockState = "S"
-                        
-                        fpath = Utilities.normcasepath(
-                            os.path.join(self.dname, file.path))
-                        if fpath in changelistsDict:
-                            changelist = changelistsDict[fpath]
-                        else:
-                            changelist = ""
-                        
-                        hidePropertyStatusColumn = (
-                            hidePropertyStatusColumn and
-                            file.prop_status in [
-                                pysvn.wc_status_kind.none,
-                                pysvn.wc_status_kind.normal
-                            ]
-                        )
-                        hideLockColumns = (
-                            hideLockColumns and
-                            not file.is_locked and
-                            lockState == " "
-                        )
-                        hideUpToDateColumn = hideUpToDateColumn and uptodate
-                        hideHistoryColumn = (
-                            hideHistoryColumn and
-                            not file.is_copied
-                        )
-                        hideSwitchedColumn = (
-                            hideSwitchedColumn and
-                            not file.is_switched
+                with E5MutexLocker(self.vcs.vcsExecutionMutex):
+                    for name in fnames:
+                        # step 1: determine changelists and their files
+                        changelistsDict = {}
+                        if hasattr(self.client, 'get_changelist'):
+                            if recurse:
+                                depth = pysvn.depth.infinity
+                            else:
+                                depth = pysvn.depth.immediate
+                            changelists = self.client.get_changelist(
+                                name, depth=depth)
+                            for fpath, changelist in changelists:
+                                fpath = Utilities.normcasepath(fpath)
+                                changelistsDict[fpath] = changelist
+                        hideChangelistColumn = (
+                            hideChangelistColumn and len(changelistsDict) == 0
                         )
                         
-                        self.__generateItem(
-                            changelist,
-                            file.text_status,
-                            file.prop_status,
-                            file.is_locked,
-                            file.is_copied,
-                            file.is_switched,
-                            lockState,
-                            uptodate,
-                            file.entry.revision.number if file.entry else "",
-                            file.entry.commit_revision.number
-                            if file.entry else "",
-                            file.entry.commit_author if file.entry else "",
-                            file.path
-                        )
-                        counter += 1
-                        if counter == 30:
-                            # check for cancel every 30 items
-                            counter = 0
-                            if self._clientCancelCallback():
-                                break
-                    if self._clientCancelCallback():
-                        break
+                        # step 2: determine status of files
+                        allFiles = self.client.status(
+                            name, recurse=recurse, get_all=verbose,
+                            ignore=True, update=update)
+                        counter = 0
+                        for file in allFiles:
+                            uptodate = True
+                            if (
+                                file.repos_text_status !=
+                                pysvn.wc_status_kind.none
+                            ):
+                                uptodate = (
+                                    uptodate and
+                                    file.repos_text_status !=
+                                    pysvn.wc_status_kind.modified
+                                )
+                            if (
+                                file.repos_prop_status !=
+                                pysvn.wc_status_kind.none
+                            ):
+                                uptodate = (
+                                    uptodate and
+                                    file.repos_prop_status !=
+                                    pysvn.wc_status_kind.modified
+                                )
+                            
+                            lockState = " "
+                            if (
+                                file.entry is not None and
+                                hasattr(file.entry, 'lock_token') and
+                                file.entry.lock_token is not None
+                            ):
+                                lockState = "L"
+                            if hasattr(file, 'repos_lock') and update:
+                                if (
+                                    lockState == "L" and
+                                    file.repos_lock is None
+                                ):
+                                    lockState = "B"
+                                elif (
+                                    lockState == " " and
+                                    file.repos_lock is not None
+                                ):
+                                    lockState = "O"
+                                elif (
+                                    lockState == "L" and
+                                    file.repos_lock is not None and
+                                    file.entry.lock_token !=
+                                        file.repos_lock["token"]
+                                ):
+                                    lockState = "S"
+                            
+                            fpath = Utilities.normcasepath(
+                                os.path.join(self.dname, file.path))
+                            if fpath in changelistsDict:
+                                changelist = changelistsDict[fpath]
+                            else:
+                                changelist = ""
+                            
+                            hidePropertyStatusColumn = (
+                                hidePropertyStatusColumn and
+                                file.prop_status in [
+                                    pysvn.wc_status_kind.none,
+                                    pysvn.wc_status_kind.normal
+                                ]
+                            )
+                            hideLockColumns = (
+                                hideLockColumns and
+                                not file.is_locked and
+                                lockState == " "
+                            )
+                            hideUpToDateColumn = (
+                                hideUpToDateColumn and uptodate
+                            )
+                            hideHistoryColumn = (
+                                hideHistoryColumn and
+                                not file.is_copied
+                            )
+                            hideSwitchedColumn = (
+                                hideSwitchedColumn and
+                                not file.is_switched
+                            )
+                            
+                            self.__generateItem(
+                                changelist,
+                                file.text_status,
+                                file.prop_status,
+                                file.is_locked,
+                                file.is_copied,
+                                file.is_switched,
+                                lockState,
+                                uptodate,
+                                file.entry.revision.number if file.entry
+                                else "",
+                                file.entry.commit_revision.number
+                                if file.entry else "",
+                                file.entry.commit_author if file.entry else "",
+                                file.path
+                            )
+                            counter += 1
+                            if counter == 30:
+                                # check for cancel every 30 items
+                                counter = 0
+                                if self._clientCancelCallback():
+                                    break
+                        if self._clientCancelCallback():
+                            break
             except pysvn.ClientError as e:
                 self.__showError(e.args[0] + '\n')
             
@@ -443,8 +457,6 @@
                                             hideSwitchedColumn)
             self.statusList.setColumnHidden(self.__changelistColumn,
                                             hideChangelistColumn)
-            
-            locker.unlock()
         self.__finish()
         os.chdir(cwd)
         

eric ide

mercurial