stablesortcache: ignore permission and OS errors when writing stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 13 Sep 2018 19:22:39 +0200
branchstable
changeset 4103 1c0a09668709
parent 4102 3895f6fcd35c
child 4104 a023abd12f3b
stablesortcache: ignore permission and OS errors when writing This cache is related to the obshashrange one and we update it lazily by default. This can be an issue when pulling locally from a read only repository that was not configured for a more aggressive cache warming. The raised permission error was uncaught and could crash the whole process. Errors during cache update should not block Mercurial operations.
hgext3rd/evolve/stablesort.py
--- a/hgext3rd/evolve/stablesort.py	Thu Sep 13 19:09:48 2018 +0200
+++ b/hgext3rd/evolve/stablesort.py	Thu Sep 13 19:22:39 2018 +0200
@@ -634,21 +634,24 @@
         """
         if self._cachekey is None or self._cachekey == self._ondiskkey:
             return
-        cachevfs = compat.getcachevfs(repo)
-        cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
+        try:
+            cachevfs = compat.getcachevfs(repo)
+            cachefile = cachevfs(self._filepath, 'w', atomictemp=True)
 
-        # data to write
-        headerdata = self._serializecachekey()
-        indexdata = self._index.tostring()
-        data = self._data.tostring()
-        indexsize = S_INDEXSIZE.pack(len(indexdata))
+            # data to write
+            headerdata = self._serializecachekey()
+            indexdata = self._index.tostring()
+            data = self._data.tostring()
+            indexsize = S_INDEXSIZE.pack(len(indexdata))
 
-        # writing
-        cachefile.write(headerdata)
-        cachefile.write(indexsize)
-        cachefile.write(indexdata)
-        cachefile.write(data)
-        cachefile.close()
+            # writing
+            cachefile.write(headerdata)
+            cachefile.write(indexsize)
+            cachefile.write(indexdata)
+            cachefile.write(data)
+            cachefile.close()
+        except (IOError, OSError) as exc:
+            repo.ui.debug('stablesortcache: could not write update %s\n' % exc)
 
 @eh.reposetup
 def setupcache(ui, repo):