[Updated] D8512: manifest-cache: ignore IOError while writing

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Mon May 11 23:37:49 UTC 2020


Closed by commit rHG92054972f035: manifest-cache: ignore IOError while writing (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D8512?vs=21330&id=21347

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D8512/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D8512

AFFECTED FILES
  mercurial/manifest.py

CHANGE DETAILS

diff --git a/mercurial/manifest.py b/mercurial/manifest.py
--- a/mercurial/manifest.py
+++ b/mercurial/manifest.py
@@ -1455,18 +1455,29 @@
         if not self._dirty or self._opener is None:
             return
         # rotate backwards to the first used node
-        with self._opener(
-            self._file, b'w', atomictemp=True, checkambig=True
-        ) as fp:
-            node = self._head.prev
-            while True:
-                if node.key in self._cache:
-                    fp.write(node.key)
-                    fp.write(struct.pack(b'>L', len(node.value)))
-                    fp.write(node.value)
-                if node is self._head:
-                    break
-                node = node.prev
+        try:
+            with self._opener(
+                self._file, b'w', atomictemp=True, checkambig=True
+            ) as fp:
+                node = self._head.prev
+                while True:
+                    if node.key in self._cache:
+                        fp.write(node.key)
+                        fp.write(struct.pack(b'>L', len(node.value)))
+                        fp.write(node.value)
+                    if node is self._head:
+                        break
+                    node = node.prev
+        except IOError:
+            # We could not write the cache (eg: permission error)
+            # the content can be missing.
+            #
+            # We could try harder and see if we could recreate a wcache
+            # directory were we coudl write too.
+            #
+            # XXX the error pass silently, having some way to issue an error
+            # log `ui.log` would be nice.
+            pass
 
     def __len__(self):
         if not self._read:



To: marmoute, #hg-reviewers
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20200511/08c96fc5/attachment-0002.html>


More information about the Mercurial-patches mailing list