From 6d56e2235c568a1b4b51b5039d1c8f5c350c6120 Mon Sep 17 00:00:00 2001 From: Bryan O'Sullivan Date: Sun, 27 Dec 2015 23:55:54 +0900 Subject: [PATCH] hbisect: use tryreadlines to load state This closes the file handle after reading, which stops PyPy from leaking open file handles and thus failing test-bisect3.t. --- mercurial/hbisect.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py index 9728f06c1f..d7c9867aab 100644 --- a/mercurial/hbisect.py +++ b/mercurial/hbisect.py @@ -11,7 +11,6 @@ from __future__ import absolute_import import collections -import os from .i18n import _ from .node import ( @@ -143,13 +142,12 @@ def bisect(changelog, state): def load_state(repo): state = {'current': [], 'good': [], 'bad': [], 'skip': []} - if os.path.exists(repo.join("bisect.state")): - for l in repo.vfs("bisect.state"): - kind, node = l[:-1].split() - node = repo.lookup(node) - if kind not in state: - raise error.Abort(_("unknown bisect kind %s") % kind) - state[kind].append(node) + for l in repo.vfs.tryreadlines("bisect.state"): + kind, node = l[:-1].split() + node = repo.lookup(node) + if kind not in state: + raise error.Abort(_("unknown bisect kind %s") % kind) + state[kind].append(node) return state