[PATCH 5 of 6] bookmarks: make _readactive safe when readlines raises ENOENT

Augie Fackler raf at durin42.com
Wed Dec 2 10:19:11 CST 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1448993285 18000
#      Tue Dec 01 13:08:05 2015 -0500
# Node ID 32b95ec9058de8565b64ddcae4f8d44b915c87ce
# Parent  293c2a5543cbe1243e89592c80d24b634f6c99c7
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.

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -164,6 +164,10 @@ def readactive(repo):
         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


More information about the Mercurial-devel mailing list