py3: pass unicode strings to hasattr() throughout stable
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 13 Nov 2023 09:19:11 -0800
branchstable
changeset 51146 de9cbc5a1450
parent 51132 d45afa07564c
child 51147 4ed9efb25bc7
py3: pass unicode strings to hasattr() throughout I guess we missed these instances because they're not covered by tests. This is a graft of 1625fe807c04a490f9516bc8e14140e570c06146 that landed on default.
hgext/convert/cvsps.py
hgext/fsmonitor/__init__.py
hgext/remotefilelog/basestore.py
hgext/remotefilelog/fileserverclient.py
--- a/hgext/convert/cvsps.py	Tue Nov 21 16:20:58 2023 +0100
+++ b/hgext/convert/cvsps.py	Mon Nov 13 09:19:11 2023 -0800
@@ -198,9 +198,9 @@
             oldlog = pickle.load(open(cachefile, b'rb'))
             for e in oldlog:
                 if not (
-                    hasattr(e, b'branchpoints')
-                    and hasattr(e, b'commitid')
-                    and hasattr(e, b'mergepoint')
+                    hasattr(e, 'branchpoints')
+                    and hasattr(e, 'commitid')
+                    and hasattr(e, 'mergepoint')
                 ):
                     ui.status(_(b'ignoring old cache\n'))
                     oldlog = []
--- a/hgext/fsmonitor/__init__.py	Tue Nov 21 16:20:58 2023 +0100
+++ b/hgext/fsmonitor/__init__.py	Mon Nov 13 09:19:11 2023 -0800
@@ -332,7 +332,7 @@
     matchfn = match.matchfn
     matchalways = match.always()
     dmap = self._map
-    if hasattr(dmap, b'_map'):
+    if hasattr(dmap, '_map'):
         # for better performance, directly access the inner dirstate map if the
         # standard dirstate implementation is in use.
         dmap = dmap._map
@@ -744,7 +744,7 @@
 def wrapdirstate(orig, self):
     ds = orig(self)
     # only override the dirstate when Watchman is available for the repo
-    if hasattr(self, b'_fsmonitorstate'):
+    if hasattr(self, '_fsmonitorstate'):
         makedirstate(self, ds)
     return ds
 
@@ -811,7 +811,7 @@
             self.oldnode = self.repo[b'.'].node()
 
         if self.repo.currentwlock() is None:
-            if hasattr(self.repo, b'wlocknostateupdate'):
+            if hasattr(self.repo, 'wlocknostateupdate'):
                 self._lock = self.repo.wlocknostateupdate()
             else:
                 self._lock = self.repo.wlock()
@@ -839,7 +839,7 @@
                 self._lock.release()
 
     def _state(self, cmd, commithash, status=b'ok'):
-        if not hasattr(self.repo, b'_watchmanclient'):
+        if not hasattr(self.repo, '_watchmanclient'):
             return False
         try:
             self.repo._watchmanclient.command(
--- a/hgext/remotefilelog/basestore.py	Tue Nov 21 16:20:58 2023 +0100
+++ b/hgext/remotefilelog/basestore.py	Mon Nov 13 09:19:11 2023 -0800
@@ -415,7 +415,7 @@
 
     def markforrefresh(self):
         for store in self.stores:
-            if hasattr(store, b'markforrefresh'):
+            if hasattr(store, 'markforrefresh'):
                 store.markforrefresh()
 
     @staticmethod
--- a/hgext/remotefilelog/fileserverclient.py	Tue Nov 21 16:20:58 2023 +0100
+++ b/hgext/remotefilelog/fileserverclient.py	Mon Nov 13 09:19:11 2023 -0800
@@ -641,7 +641,7 @@
             self._lfsprefetch(fileids)
 
     def _lfsprefetch(self, fileids):
-        if not _lfsmod or not hasattr(self.repo.svfs, b'lfslocalblobstore'):
+        if not _lfsmod or not hasattr(self.repo.svfs, 'lfslocalblobstore'):
             return
         if not _lfsmod.wrapper.candownload(self.repo):
             return