changeset 27685:9fbae70faf65

bookmarks: make _readactive safe when readlines raises ENOENT When reading over static http, the file isn't actually opened until the readlines() call, so we have to check for ENOENT IOErrors here too. This is necessary so that we can use the bmstore everywhere for managing the active bookmark, which will be true in the next change.
author Augie Fackler <augie@google.com>
date Tue, 01 Dec 2015 13:08:05 -0500
parents e9857fbfd072
children df142b77b4c2
files mercurial/bookmarks.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bookmarks.py	Thu Dec 17 21:24:08 2015 -0500
+++ b/mercurial/bookmarks.py	Tue Dec 01 13:08:05 2015 -0500
@@ -165,10 +165,19 @@
             raise
         return None
     try:
-        # No readline() in osutil.posixfile, reading everything is cheap
+        # No readline() in osutil.posixfile, reading everything is
+        # cheap.
+        # Note that it's possible for readlines() here to raise
+        # IOError, since we might be reading the active mark over
+        # static-http which only tries to load the file when we try
+        # to read from it.
         mark = encoding.tolocal((file.readlines() or [''])[0])
         if mark == '' or mark not in repo._bookmarks:
             mark = None
+    except IOError as inst:
+        if inst.errno != errno.ENOENT:
+            raise
+        return None
     finally:
         file.close()
     return mark