eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py

branch
maintenance
changeset 8273
698ae46f40a4
parent 8176
31965986ecd1
parent 8259
2bbec88047dd
--- a/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py	Fri Apr 02 11:59:41 2021 +0200
+++ b/eric6/Plugins/VcsPlugins/vcsPySvn/subversion.py	Sat May 01 14:27:20 2021 +0200
@@ -12,6 +12,7 @@
 import shutil
 import time
 from urllib.parse import quote
+import contextlib
 
 from PyQt5.QtCore import pyqtSignal, Qt, QDateTime, QCoreApplication
 from PyQt5.QtWidgets import QLineEdit, QDialog, QInputDialog, QApplication
@@ -584,14 +585,15 @@
             QApplication.processEvents()
         try:
             with E5MutexLocker(self.vcsExecutionMutex):
-                if changelists:
-                    rev = client.checkin(fnames, msg,
-                                         recurse=recurse, keep_locks=keeplocks,
-                                         keep_changelist=keepChangelists,
-                                         changelists=changelists)
-                else:
-                    rev = client.checkin(fnames, msg,
-                                         recurse=recurse, keep_locks=keeplocks)
+                rev = (
+                    client.checkin(
+                        fnames, msg, recurse=recurse, keep_locks=keeplocks,
+                        keep_changelist=keepChangelists,
+                        changelists=changelists)
+                    if changelists else
+                    client.checkin(
+                        fnames, msg, recurse=recurse, keep_locks=keeplocks)
+                )
         except pysvn.ClientError as e:
             rev = None
             if not noDialog:
@@ -934,10 +936,8 @@
             if not target:
                 return False
         
-        if rx_prot.fullmatch(target) is None:
-            isDir = os.path.isdir(name)
-        else:
-            isDir = False
+        isDir = (os.path.isdir(name) if rx_prot.fullmatch(target) is None
+                 else False)
         
         if accepted:
             client = self.getClient()
@@ -992,10 +992,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -1049,10 +1046,11 @@
                     """ will be aborted"""))
             return
         
-        if self.otherData["standardLayout"]:
-            url = None
-        else:
-            url = self.svnNormalizeURL(reposURL)
+        url = (
+            None
+            if self.otherData["standardLayout"] else
+            self.svnNormalizeURL(reposURL)
+        )
         from .SvnTagDialog import SvnTagDialog
         dlg = SvnTagDialog(self.allTagsBranchesList, url,
                            self.otherData["standardLayout"])
@@ -1191,10 +1189,11 @@
                     """ operation will be aborted"""))
             return False
         
-        if self.otherData["standardLayout"]:
-            url = None
-        else:
-            url = self.svnNormalizeURL(reposURL)
+        url = (
+            None
+            if self.otherData["standardLayout"] else
+            self.svnNormalizeURL(reposURL)
+        )
         from .SvnSwitchDialog import SvnSwitchDialog
         dlg = SvnSwitchDialog(self.allTagsBranchesList, url,
                               self.otherData["standardLayout"])
@@ -1463,7 +1462,7 @@
         dname = os.path.normcase(dname)
         
         found = False
-        for name in self.statusCache.keys():
+        for name in self.statusCache:
             if name in names:
                 found = True
                 names[name] = self.statusCache[name]
@@ -1484,7 +1483,7 @@
                 mixin._clientSslServerTrustPromptCallback
             )
             
-            try:
+            with contextlib.suppress(pysvn.ClientError):
                 with E5MutexLocker(self.vcsExecutionMutex):
                     allFiles = client.status(dname, recurse=True, get_all=True,
                                              ignore=True, update=False)
@@ -1517,9 +1516,6 @@
                                     break
                     else:
                         self.statusCache[name] = self.canBeAdded
-            except pysvn.ClientError:
-                # ignore pysvn errors
-                pass
         
         return names
         
@@ -1564,7 +1560,7 @@
                 mixin._clientSslServerTrustPromptCallback
             )
             
-            try:
+            with contextlib.suppress(pysvn.ClientError):
                 with E5MutexLocker(self.vcsExecutionMutex):
                     allFiles = client.status(dname, recurse=True, get_all=True,
                                              ignore=True, update=False)
@@ -1576,9 +1572,6 @@
                         self.statusCache[name] = self.canBeCommitted
                     else:
                         self.statusCache[name] = self.canBeAdded
-            except pysvn.ClientError:
-                # ignore pysvn errors
-                pass
         
         return names
         
@@ -1719,12 +1712,13 @@
         except pysvn.ClientError as e:
             return e.args[0]
         
-        if hasattr(pysvn, 'svn_api_version'):
-            apiVersion = "{0} {1}".format(
+        apiVersion = (
+            "{0} {1}".format(
                 ".".join([str(v) for v in pysvn.svn_api_version[:3]]),
                 pysvn.svn_api_version[3])
-        else:
-            apiVersion = QCoreApplication.translate('subversion', "unknown")
+            if hasattr(pysvn, 'svn_api_version') else
+            QCoreApplication.translate('subversion', "unknown")
+        )
         
         hmsz = time.strftime("%H:%M:%S %Z", time.localtime(entry.commit_time))
         return QCoreApplication.translate(
@@ -2036,10 +2030,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2075,10 +2066,7 @@
         
         @param name file/directory name to be diffed (string)
         """
-        if isinstance(name, list):
-            names = name[:]
-        else:
-            names = [name]
+        names = name[:] if isinstance(name, list) else [name]
         for nam in names:
             if os.path.isfile(nam):
                 editor = e5App().getObject("ViewManager").getOpenEditor(nam)
@@ -2364,11 +2352,7 @@
         
         @param projectPath path name of the project (string)
         """
-        if projectPath:
-            url = self.svnGetReposName(projectPath)
-        else:
-            url = None
-        
+        url = self.svnGetReposName(projectPath) if projectPath else None
         if url is None:
             url, ok = QInputDialog.getText(
                 None,
@@ -2470,7 +2454,7 @@
         client = self.getClient()
         if hasattr(client, 'get_changelist'):
             ppath = e5App().getObject("Project").getProjectPath()
-            try:
+            with contextlib.suppress(pysvn.ClientError):
                 with E5MutexLocker(self.vcsExecutionMutex):
                     entries = client.get_changelist(
                         ppath, depth=pysvn.depth.infinity)
@@ -2478,8 +2462,6 @@
                     changelist = entry[1]
                     if changelist not in changelists:
                         changelists.append(changelist)
-            except pysvn.ClientError:
-                pass
         
         return changelists
         

eric ide

mercurial