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

login
register
mail settings
Submitter Augie Fackler
Date Dec. 2, 2015, 4:19 p.m.
Message ID <32b95ec9058de8565b64.1449073151@imladris.local>
Download mbox | patch
Permalink /patch/11753/
State Superseded
Headers show

Comments

Augie Fackler - Dec. 2, 2015, 4:19 p.m.
# HG changeset patch
# User Augie Fackler <augie@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.

Patch

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