changeset 50901:6543469a351e

lfs: use sysstr to check for attribute presence We do not need bytes here.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 30 Aug 2023 12:51:27 +0200
parents a99e62dae4c8
children defd2b3eafdb
files hgext/lfs/blobstore.py hgext/lfs/wrapper.py
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/lfs/blobstore.py	Wed Aug 30 12:38:02 2023 +0200
+++ b/hgext/lfs/blobstore.py	Wed Aug 30 12:51:27 2023 +0200
@@ -271,7 +271,7 @@
     if isinstance(urlerror.reason, Exception):
         inst = urlerror.reason
 
-    if util.safehasattr(inst, b'reason'):
+    if util.safehasattr(inst, 'reason'):
         try:  # usually it is in the form (errno, strerror)
             reason = inst.reason.args[1]
         except (AttributeError, IndexError):
@@ -751,7 +751,7 @@
     if lfsurl is None:
         if remote:
             path = remote
-        elif util.safehasattr(repo, b'_subtoppath'):
+        elif util.safehasattr(repo, '_subtoppath'):
             # The pull command sets this during the optional update phase, which
             # tells exactly where the pull originated, whether 'paths.default'
             # or explicit.
--- a/hgext/lfs/wrapper.py	Wed Aug 30 12:38:02 2023 +0200
+++ b/hgext/lfs/wrapper.py	Wed Aug 30 12:51:27 2023 +0200
@@ -72,7 +72,7 @@
 def _capabilities(orig, repo, proto):
     '''Wrap server command to announce lfs server capability'''
     caps = orig(repo, proto)
-    if util.safehasattr(repo.svfs, b'lfslocalblobstore'):
+    if util.safehasattr(repo.svfs, 'lfslocalblobstore'):
         # Advertise a slightly different capability when lfs is *required*, so
         # that the client knows it MUST load the extension.  If lfs is not
         # required on the server, there's no reason to autoload the extension
@@ -334,7 +334,7 @@
             self.options[k] = v
     # also copy lfs blobstores. note: this can run before reposetup, so lfs
     # blobstore attributes are not always ready at this time.
-    for name in [b'lfslocalblobstore', b'lfsremoteblobstore']:
+    for name in ['lfslocalblobstore', 'lfsremoteblobstore']:
         if util.safehasattr(othervfs, name):
             setattr(self, name, getattr(othervfs, name))
 
@@ -342,7 +342,7 @@
 def _prefetchfiles(repo, revmatches):
     """Ensure that required LFS blobs are present, fetching them as a group if
     needed."""
-    if not util.safehasattr(repo.svfs, b'lfslocalblobstore'):
+    if not util.safehasattr(repo.svfs, 'lfslocalblobstore'):
         return
 
     pointers = []
@@ -366,7 +366,7 @@
 
 def _canskipupload(repo):
     # Skip if this hasn't been passed to reposetup()
-    if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'):
+    if not util.safehasattr(repo.svfs, 'lfsremoteblobstore'):
         return True
 
     # if remotestore is a null store, upload is a no-op and can be skipped
@@ -375,7 +375,7 @@
 
 def candownload(repo):
     # Skip if this hasn't been passed to reposetup()
-    if not util.safehasattr(repo.svfs, b'lfsremoteblobstore'):
+    if not util.safehasattr(repo.svfs, 'lfsremoteblobstore'):
         return False
 
     # if remotestore is a null store, downloads will lead to nothing
@@ -524,9 +524,9 @@
     orig(ui, srcrepo, dstrepo, requirements)
 
     # Skip if this hasn't been passed to reposetup()
-    if util.safehasattr(
-        srcrepo.svfs, b'lfslocalblobstore'
-    ) and util.safehasattr(dstrepo.svfs, b'lfslocalblobstore'):
+    if util.safehasattr(srcrepo.svfs, 'lfslocalblobstore') and util.safehasattr(
+        dstrepo.svfs, 'lfslocalblobstore'
+    ):
         srclfsvfs = srcrepo.svfs.lfslocalblobstore.vfs
         dstlfsvfs = dstrepo.svfs.lfslocalblobstore.vfs