py3: delete b'' prefix from safehasattr arguments
authorMartin von Zweigbergk <martinvonz@google.com>
Sun, 06 Oct 2019 20:17:41 -0700
changeset 43115 4aa72cdf616f
parent 43114 8197b395710e
child 43116 defabf63e969
py3: delete b'' prefix from safehasattr arguments Differential Revision: https://phab.mercurial-scm.org/D7029
hgext/absorb.py
hgext/bugzilla.py
hgext/commitextras.py
hgext/fastannotate/commands.py
hgext/fsmonitor/watchmanclient.py
hgext/journal.py
hgext/lfs/wireprotolfsserver.py
hgext/narrow/narrowbundle2.py
hgext/remotefilelog/connectionpool.py
hgext/remotefilelog/fileserverclient.py
hgext/remotefilelog/repack.py
hgext/remotefilelog/shallowrepo.py
mercurial/bundle2.py
mercurial/bundlerepo.py
mercurial/pvec.py
mercurial/registrar.py
mercurial/utils/procutil.py
--- a/hgext/absorb.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/absorb.py	Sun Oct 06 20:17:41 2019 -0700
@@ -862,7 +862,7 @@
         # be slow. in absorb's case, no need to invalidate fsmonitorstate.
         noop = lambda: 0
         restore = noop
-        if util.safehasattr(dirstate, b'_fsmonitorstate'):
+        if util.safehasattr(dirstate, '_fsmonitorstate'):
             bak = dirstate._fsmonitorstate.invalidate
 
             def restore():
--- a/hgext/bugzilla.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/bugzilla.py	Sun Oct 06 20:17:41 2019 -0700
@@ -731,13 +731,13 @@
 # inheritance with a new-style class.
 class cookietransport(cookietransportrequest, xmlrpclib.Transport):
     def __init__(self, use_datetime=0):
-        if util.safehasattr(xmlrpclib.Transport, b"__init__"):
+        if util.safehasattr(xmlrpclib.Transport, "__init__"):
             xmlrpclib.Transport.__init__(self, use_datetime)
 
 
 class cookiesafetransport(cookietransportrequest, xmlrpclib.SafeTransport):
     def __init__(self, use_datetime=0):
-        if util.safehasattr(xmlrpclib.Transport, b"__init__"):
+        if util.safehasattr(xmlrpclib.Transport, "__init__"):
             xmlrpclib.SafeTransport.__init__(self, use_datetime)
 
 
--- a/hgext/commitextras.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/commitextras.py	Sun Oct 06 20:17:41 2019 -0700
@@ -53,7 +53,7 @@
 
 
 def _commit(orig, ui, repo, *pats, **opts):
-    if util.safehasattr(repo, b'unfiltered'):
+    if util.safehasattr(repo, 'unfiltered'):
         repo = repo.unfiltered()
 
     class repoextra(repo.__class__):
--- a/hgext/fastannotate/commands.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/fastannotate/commands.py	Sun Oct 06 20:17:41 2019 -0700
@@ -218,7 +218,7 @@
     paths = list(_matchpaths(repo, rev, pats, opts, aopts))
 
     # for client, prefetch from the server
-    if util.safehasattr(repo, b'prefetchfastannotate'):
+    if util.safehasattr(repo, 'prefetchfastannotate'):
         repo.prefetchfastannotate(paths)
 
     for path in paths:
@@ -273,7 +273,7 @@
 
     # check if we need to do prefetch (client-side)
     rev = opts.get(r'rev')
-    if util.safehasattr(repo, b'prefetchfastannotate') and rev is not None:
+    if util.safehasattr(repo, 'prefetchfastannotate') and rev is not None:
         paths = list(_matchpaths(repo, rev, pats, pycompat.byteskwargs(opts)))
         repo.prefetchfastannotate(paths)
 
@@ -320,7 +320,7 @@
     ctx = scmutil.revsingle(repo, rev)
     m = scmutil.match(ctx, pats, opts)
     paths = list(ctx.walk(m))
-    if util.safehasattr(repo, b'prefetchfastannotate'):
+    if util.safehasattr(repo, 'prefetchfastannotate'):
         # client
         if opts.get(b'REV'):
             raise error.Abort(_(b'--rev cannot be used for client'))
--- a/hgext/fsmonitor/watchmanclient.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/fsmonitor/watchmanclient.py	Sun Oct 06 20:17:41 2019 -0700
@@ -61,7 +61,7 @@
 
     def getcurrentclock(self):
         result = self.command(b'clock')
-        if not util.safehasattr(result, b'clock'):
+        if not util.safehasattr(result, 'clock'):
             raise Unavailable(
                 b'clock result is missing clock value', invalidate=True
             )
--- a/hgext/journal.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/journal.py	Sun Oct 06 20:17:41 2019 -0700
@@ -102,7 +102,7 @@
 def wrapdirstate(orig, repo):
     """Make journal storage available to the dirstate object"""
     dirstate = orig(repo)
-    if util.safehasattr(repo, b'journal'):
+    if util.safehasattr(repo, 'journal'):
         _setupdirstate(repo, dirstate)
     return dirstate
 
@@ -111,7 +111,7 @@
     """Records all dirstate parent changes in the journal."""
     old = list(old)
     new = list(new)
-    if util.safehasattr(dirstate, b'journalstorage'):
+    if util.safehasattr(dirstate, 'journalstorage'):
         # only record two hashes if there was a merge
         oldhashes = old[:1] if old[1] == node.nullid else old
         newhashes = new[:1] if new[1] == node.nullid else new
@@ -124,7 +124,7 @@
 def recordbookmarks(orig, store, fp):
     """Records all bookmark changes in the journal."""
     repo = store._repo
-    if util.safehasattr(repo, b'journal'):
+    if util.safehasattr(repo, 'journal'):
         oldmarks = bookmarks.bmstore(repo)
         for mark, value in pycompat.iteritems(store):
             oldvalue = oldmarks.get(mark, node.nullid)
@@ -186,7 +186,7 @@
     if (
         repo.path == repopath
         and repo.shared()
-        and util.safehasattr(repo, b'journal')
+        and util.safehasattr(repo, 'journal')
     ):
         sharedrepo = hg.sharedreposource(repo)
         sharedfeatures = _readsharedfeatures(repo)
--- a/hgext/lfs/wireprotolfsserver.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/lfs/wireprotolfsserver.py	Sun Oct 06 20:17:41 2019 -0700
@@ -45,7 +45,7 @@
     if not rctx.repo.ui.configbool(b'experimental', b'lfs.serve'):
         return False
 
-    if not util.safehasattr(rctx.repo.svfs, b'lfslocalblobstore'):
+    if not util.safehasattr(rctx.repo.svfs, 'lfslocalblobstore'):
         return False
 
     if not req.dispatchpath:
--- a/hgext/narrow/narrowbundle2.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/narrow/narrowbundle2.py	Sun Oct 06 20:17:41 2019 -0700
@@ -266,7 +266,7 @@
     # will currently always be there when using the core+narrowhg server, but
     # other servers may include a changespec part even when not widening (e.g.
     # because we're deepening a shallow repo).
-    if util.safehasattr(repo, b'setnewnarrowpats'):
+    if util.safehasattr(repo, 'setnewnarrowpats'):
         repo.setnewnarrowpats()
 
 
@@ -348,9 +348,9 @@
 
     def wrappedcghandler(op, inpart):
         origcghandler(op, inpart)
-        if util.safehasattr(op, b'_widen_bundle'):
+        if util.safehasattr(op, '_widen_bundle'):
             handlechangegroup_widen(op, inpart)
-        if util.safehasattr(op, b'_bookmarksbackup'):
+        if util.safehasattr(op, '_bookmarksbackup'):
             localrepo.localrepository._bookmarks.set(
                 op.repo, op._bookmarksbackup
             )
--- a/hgext/remotefilelog/connectionpool.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/remotefilelog/connectionpool.py	Sun Oct 06 20:17:41 2019 -0700
@@ -47,12 +47,12 @@
                 # close pipee first so peer.cleanup reading it won't deadlock,
                 # if there are other processes with pipeo open (i.e. us).
                 peer = orig.im_self
-                if util.safehasattr(peer, b'pipee'):
+                if util.safehasattr(peer, 'pipee'):
                     peer.pipee.close()
                 return orig()
 
             peer = hg.peer(self._repo.ui, {}, path)
-            if util.safehasattr(peer, b'cleanup'):
+            if util.safehasattr(peer, 'cleanup'):
                 extensions.wrapfunction(peer, b'cleanup', _cleanup)
 
             conn = connection(pathpool, peer)
@@ -84,5 +84,5 @@
             self.close()
 
     def close(self):
-        if util.safehasattr(self.peer, b'cleanup'):
+        if util.safehasattr(self.peer, 'cleanup'):
             self.peer.cleanup()
--- a/hgext/remotefilelog/fileserverclient.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/remotefilelog/fileserverclient.py	Sun Oct 06 20:17:41 2019 -0700
@@ -89,7 +89,7 @@
                 not in self.capabilities()
             ):
                 return
-            if not util.safehasattr(self, b'_localrepo'):
+            if not util.safehasattr(self, '_localrepo'):
                 return
             if (
                 constants.SHALLOWREPO_REQUIREMENT
@@ -129,7 +129,7 @@
 
         def _callstream(self, command, **opts):
             supertype = super(remotefilepeer, self)
-            if not util.safehasattr(supertype, b'_sendrequest'):
+            if not util.safehasattr(supertype, '_sendrequest'):
                 self._updatecallstreamopts(command, pycompat.byteskwargs(opts))
             return super(remotefilepeer, self)._callstream(command, **opts)
 
--- a/hgext/remotefilelog/repack.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/remotefilelog/repack.py	Sun Oct 06 20:17:41 2019 -0700
@@ -54,7 +54,7 @@
 def fullrepack(repo, options=None):
     """If ``packsonly`` is True, stores creating only loose objects are skipped.
     """
-    if util.safehasattr(repo, b'shareddatastores'):
+    if util.safehasattr(repo, 'shareddatastores'):
         datasource = contentstore.unioncontentstore(*repo.shareddatastores)
         historysource = metadatastore.unionmetadatastore(
             *repo.sharedhistorystores, allowincomplete=True
@@ -72,7 +72,7 @@
             options=options,
         )
 
-    if util.safehasattr(repo.manifestlog, b'datastore'):
+    if util.safehasattr(repo.manifestlog, 'datastore'):
         localdata, shareddata = _getmanifeststores(repo)
         lpackpath, ldstores, lhstores = localdata
         spackpath, sdstores, shstores = shareddata
@@ -112,7 +112,7 @@
     """This repacks the repo by looking at the distribution of pack files in the
     repo and performing the most minimal repack to keep the repo in good shape.
     """
-    if util.safehasattr(repo, b'shareddatastores'):
+    if util.safehasattr(repo, 'shareddatastores'):
         packpath = shallowutil.getcachepackpath(
             repo, constants.FILEPACK_CATEGORY
         )
@@ -125,7 +125,7 @@
             options=options,
         )
 
-    if util.safehasattr(repo.manifestlog, b'datastore'):
+    if util.safehasattr(repo.manifestlog, 'datastore'):
         localdata, shareddata = _getmanifeststores(repo)
         lpackpath, ldstores, lhstores = localdata
         spackpath, sdstores, shstores = shareddata
@@ -901,7 +901,7 @@
 
 
 def repacklockvfs(repo):
-    if util.safehasattr(repo, b'name'):
+    if util.safehasattr(repo, 'name'):
         # Lock in the shared cache so repacks across multiple copies of the same
         # repo are coordinated.
         sharedcachepath = shallowutil.getcachepackpath(
--- a/hgext/remotefilelog/shallowrepo.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/hgext/remotefilelog/shallowrepo.py	Sun Oct 06 20:17:41 2019 -0700
@@ -345,7 +345,7 @@
     repo.excludepattern = repo.ui.configlist(
         b"remotefilelog", b"excludepattern", None
     )
-    if not util.safehasattr(repo, b'connectionpool'):
+    if not util.safehasattr(repo, 'connectionpool'):
         repo.connectionpool = connectionpool.connectionpool(repo)
 
     if repo.includepattern or repo.excludepattern:
--- a/mercurial/bundle2.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/mercurial/bundle2.py	Sun Oct 06 20:17:41 2019 -0700
@@ -936,7 +936,7 @@
 
     def close(self):
         """close underlying file"""
-        if util.safehasattr(self._fp, b'close'):
+        if util.safehasattr(self._fp, 'close'):
             return self._fp.close()
 
 
@@ -1024,7 +1024,7 @@
 
         The new part have the very same content but no partid assigned yet.
         Parts with generated data cannot be copied."""
-        assert not util.safehasattr(self.data, b'next')
+        assert not util.safehasattr(self.data, 'next')
         return self.__class__(
             self.type,
             self._mandatoryparams,
@@ -1093,7 +1093,7 @@
                 msg.append(b')')
             if not self.data:
                 msg.append(b' empty payload')
-            elif util.safehasattr(self.data, b'next') or util.safehasattr(
+            elif util.safehasattr(self.data, 'next') or util.safehasattr(
                 self.data, b'__next__'
             ):
                 msg.append(b' streamed payload')
@@ -1189,7 +1189,7 @@
         Exists to handle the different methods to provide data to a part."""
         # we only support fixed size data now.
         # This will be improved in the future.
-        if util.safehasattr(self.data, b'next') or util.safehasattr(
+        if util.safehasattr(self.data, 'next') or util.safehasattr(
             self.data, b'__next__'
         ):
             buff = util.chunkbuffer(self.data)
@@ -1336,7 +1336,7 @@
 
     def __init__(self, ui, header, fp):
         super(unbundlepart, self).__init__(fp)
-        self._seekable = util.safehasattr(fp, b'seek') and util.safehasattr(
+        self._seekable = util.safehasattr(fp, 'seek') and util.safehasattr(
             fp, b'tell'
         )
         self.ui = ui
--- a/mercurial/bundlerepo.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/mercurial/bundlerepo.py	Sun Oct 06 20:17:41 2019 -0700
@@ -212,7 +212,7 @@
 class bundlephasecache(phases.phasecache):
     def __init__(self, *args, **kwargs):
         super(bundlephasecache, self).__init__(*args, **kwargs)
-        if util.safehasattr(self, b'opener'):
+        if util.safehasattr(self, 'opener'):
             self.opener = vfsmod.readonlyvfs(self.opener)
 
     def write(self):
--- a/mercurial/pvec.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/mercurial/pvec.py	Sun Oct 06 20:17:41 2019 -0700
@@ -159,7 +159,7 @@
 def ctxpvec(ctx):
     '''construct a pvec for ctx while filling in the cache'''
     r = ctx.repo()
-    if not util.safehasattr(r, b"_pveccache"):
+    if not util.safehasattr(r, "_pveccache"):
         r._pveccache = {}
     pvc = r._pveccache
     if ctx.rev() not in pvc:
--- a/mercurial/registrar.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/mercurial/registrar.py	Sun Oct 06 20:17:41 2019 -0700
@@ -65,7 +65,7 @@
             msg = b'duplicate registration for name: "%s"' % name
             raise error.ProgrammingError(msg)
 
-        if func.__doc__ and not util.safehasattr(func, b'_origdoc'):
+        if func.__doc__ and not util.safehasattr(func, '_origdoc'):
             func._origdoc = func.__doc__.strip()
             doc = pycompat.sysbytes(func._origdoc)
             func.__doc__ = pycompat.sysstr(self._formatdoc(decl, doc))
--- a/mercurial/utils/procutil.py	Tue Oct 08 19:35:30 2019 -0700
+++ b/mercurial/utils/procutil.py	Sun Oct 06 20:17:41 2019 -0700
@@ -259,8 +259,8 @@
     (portable, not much used).
     """
     return (
-        pycompat.safehasattr(sys, b"frozen")
-        or pycompat.safehasattr(sys, b"importers")  # new py2exe
+        pycompat.safehasattr(sys, "frozen")
+        or pycompat.safehasattr(sys, "importers")  # new py2exe
         or imp.is_frozen(r"__main__")  # old py2exe
     )  # tools/freeze