Mercurial > public > mercurial-scm > hg
comparison mercurial/hbisect.py @ 27525:cba62f996780
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.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sun, 27 Dec 2015 23:55:54 +0900 |
parents | 56b2bcea2529 |
children | 9b8a5c6ac176 |
comparison
equal
deleted
inserted
replaced
27524:f5b6b4e574c1 | 27525:cba62f996780 |
---|---|
9 # GNU General Public License version 2 or any later version. | 9 # GNU General Public License version 2 or any later version. |
10 | 10 |
11 from __future__ import absolute_import | 11 from __future__ import absolute_import |
12 | 12 |
13 import collections | 13 import collections |
14 import os | |
15 | 14 |
16 from .i18n import _ | 15 from .i18n import _ |
17 from .node import ( | 16 from .node import ( |
18 hex, | 17 hex, |
19 short, | 18 short, |
141 return ([best_node], tot, good) | 140 return ([best_node], tot, good) |
142 | 141 |
143 | 142 |
144 def load_state(repo): | 143 def load_state(repo): |
145 state = {'current': [], 'good': [], 'bad': [], 'skip': []} | 144 state = {'current': [], 'good': [], 'bad': [], 'skip': []} |
146 if os.path.exists(repo.join("bisect.state")): | 145 for l in repo.vfs.tryreadlines("bisect.state"): |
147 for l in repo.vfs("bisect.state"): | 146 kind, node = l[:-1].split() |
148 kind, node = l[:-1].split() | 147 node = repo.lookup(node) |
149 node = repo.lookup(node) | 148 if kind not in state: |
150 if kind not in state: | 149 raise error.Abort(_("unknown bisect kind %s") % kind) |
151 raise error.Abort(_("unknown bisect kind %s") % kind) | 150 state[kind].append(node) |
152 state[kind].append(node) | |
153 return state | 151 return state |
154 | 152 |
155 | 153 |
156 def save_state(repo, state): | 154 def save_state(repo, state): |
157 f = repo.vfs("bisect.state", "w", atomictemp=True) | 155 f = repo.vfs("bisect.state", "w", atomictemp=True) |