[PATCH 8 of 8] hbisect: use tryreadlines to load state
Bryan O'Sullivan
bos at serpentine.com
Wed Dec 23 00:24:46 CST 2015
# HG changeset patch
# User Bryan O'Sullivan <bos at serpentine.com>
# Date 1450851054 28800
# Tue Dec 22 22:10:54 2015 -0800
# Node ID 89a92700bdb96b8f6477d8bf59e268f7db0a13c1
# Parent 8c45e1eed7390cab1f3aaa4e16ac4a63e2d1703b
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.
diff --git a/mercurial/hbisect.py b/mercurial/hbisect.py
--- a/mercurial/hbisect.py
+++ b/mercurial/hbisect.py
@@ -143,13 +143,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
More information about the Mercurial-devel
mailing list