Patchwork [2,of,4,stable] tags: silence hgtagsfnodes reading failures

login
register
mail settings
Submitter Matt Mackall
Date April 28, 2016, 9:54 p.m.
Message ID <369f16a0fbd46c826ee7.1461880468@ruin.waste.org>
Download mbox | patch
Permalink /patch/14827/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Matt Mackall - April 28, 2016, 9:54 p.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1461876043 18000
#      Thu Apr 28 15:40:43 2016 -0500
# Branch stable
# Node ID 369f16a0fbd46c826ee75eff85f7db51099e0d17
# Parent  30ea1355f34f85f4d7b5b0f4c8816fa44a35a8ed
tags: silence hgtagsfnodes reading failures

tryread() doesn't handle "is a directory" errors and presumably
others. We might not want to globally swallow such tryread errors, so
we replace with our own try/except handling.

An upcoming test will use directories as a portable stand-in for
various bizarre circumstances that cache read/write code should be
robust to.

Patch

diff -r 30ea1355f34f -r 369f16a0fbd4 mercurial/tags.py
--- a/mercurial/tags.py	Thu Apr 28 15:35:54 2016 -0500
+++ b/mercurial/tags.py	Thu Apr 28 15:40:43 2016 -0500
@@ -433,7 +433,10 @@ 
 
         self._raw = array('c')
 
-        data = repo.vfs.tryread(_fnodescachefile)
+        try:
+            data = repo.vfs.read(_fnodescachefile)
+        except (OSError, IOError):
+            data = ""
         self._raw.fromstring(data)
 
         # The end state of self._raw is an array that is of the exact length