hgext3rd/evolve/obscache.py
changeset 4814 48b30ff742cb
parent 4804 079dbf36e884
child 4929 bb2b4f6c99dc
--- a/hgext3rd/evolve/obscache.py	Tue Aug 06 15:06:27 2019 +0200
+++ b/hgext3rd/evolve/obscache.py	Tue Aug 06 15:06:38 2019 +0200
@@ -50,10 +50,10 @@
             length, cachekey will be set to None."""
             # default value
             obsstoresize = 0
-            keydata = ''
+            keydata = b''
             # try to get actual data from the obsstore
             try:
-                with self.svfs('obsstore') as obsfile:
+                with self.svfs(b'obsstore') as obsfile:
                     obsfile.seek(0, 2)
                     obsstoresize = obsfile.tell()
                     if index is None:
@@ -86,7 +86,7 @@
         # if the data are in memory, just use that
         return obsstore._all[firstmarker:]
     else:
-        obsdata = obsstore.svfs.tryread('obsstore')
+        obsdata = obsstore.svfs.tryread(b'obsstore')
         return obsolete._readmarkers(obsdata, byteoffset)[1]
 
 
@@ -178,7 +178,7 @@
 
         reset, revs, obsmarkers, obskeypair = upgrade
         if reset or self._cachekey is None:
-            repo.ui.log('evoext-cache', 'strip detected, %s cache reset\n' % self._cachename)
+            repo.ui.log(b'evoext-cache', b'strip detected, %s cache reset\n' % self._cachename)
             self.clear(reset=True)
 
         starttime = util.timer()
@@ -186,7 +186,7 @@
         obsmarkers = list(obsmarkers)
         self._updatefrom(repo, revs, obsmarkers)
         duration = util.timer() - starttime
-        repo.ui.log('evoext-cache', 'updated %s in %.4f seconds (%dr, %do)\n',
+        repo.ui.log(b'evoext-cache', b'updated %s in %.4f seconds (%dr, %do)\n',
                     self._cachename, duration, len(revs), len(obsmarkers))
 
         # update the key from the new data
@@ -314,10 +314,10 @@
         zero. That would be especially useful for the '.pending' overlay.
     """
 
-    _filepath = 'evoext-obscache-00'
-    _headerformat = '>q20sQQ20s'
+    _filepath = b'evoext-obscache-00'
+    _headerformat = b'>q20sQQ20s'
 
-    _cachename = 'evo-ext-obscache' # used for error message
+    _cachename = b'evo-ext-obscache' # used for error message
 
     def __init__(self, repo):
         super(obscache, self).__init__()
@@ -403,15 +403,15 @@
             return
 
         try:
-            cachefile = repo.cachevfs(self._filepath, 'w', atomictemp=True)
+            cachefile = repo.cachevfs(self._filepath, b'w', atomictemp=True)
             headerdata = struct.pack(self._headerformat, *self._cachekey)
             cachefile.write(headerdata)
             cachefile.write(self._data)
             cachefile.close()
             self._ondiskkey = self._cachekey
         except (IOError, OSError) as exc:
-            repo.ui.log('obscache', 'could not write update %s\n' % exc)
-            repo.ui.debug('obscache: could not write update %s\n' % exc)
+            repo.ui.log(b'obscache', b'could not write update %s\n' % exc)
+            repo.ui.debug(b'obscache: could not write update %s\n' % exc)
 
     def load(self, repo):
         """load data from disk"""
@@ -447,10 +447,10 @@
         # will be about as fast...
         if not obscache.uptodate(repo):
             if repo.currenttransaction() is None:
-                repo.ui.log('evoext-cache',
-                            'obscache is out of date, '
-                            'falling back to slower obsstore version\n')
-                repo.ui.debug('obscache is out of date\n')
+                repo.ui.log(b'evoext-cache',
+                            b'obscache is out of date, '
+                            b'falling back to slower obsstore version\n')
+                repo.ui.debug(b'obscache is out of date\n')
                 return orig(repo)
             else:
                 # If a transaction is open, it is worthwhile to update and use
@@ -465,9 +465,9 @@
 
 @eh.uisetup
 def cachefuncs(ui):
-    orig = obsolete.cachefuncs['obsolete']
+    orig = obsolete.cachefuncs[b'obsolete']
     wrapped = lambda repo: _computeobsoleteset(orig, repo)
-    obsolete.cachefuncs['obsolete'] = wrapped
+    obsolete.cachefuncs[b'obsolete'] = wrapped
 
 @eh.reposetup
 def setupcache(ui, repo):