comparison mercurial/hbisect.py @ 7227:e1afb50ec2aa

bisect: ability to check revision with command
author Alexander Solovyov <piranha@piranha.org.ua>
date Fri, 10 Oct 2008 16:58:14 +0300
parents 0b6f2fa5e03f
children 21233de9c053
comparison
equal deleted inserted replaced
7226:b71a52f101dc 7227:e1afb50ec2aa
5 # Inspired by git bisect, extension skeleton taken from mq.py. 5 # Inspired by git bisect, extension skeleton taken from mq.py.
6 # 6 #
7 # This software may be used and distributed according to the terms 7 # This software may be used and distributed according to the terms
8 # of the GNU General Public License, incorporated herein by reference. 8 # of the GNU General Public License, incorporated herein by reference.
9 9
10 import os
10 from i18n import _ 11 from i18n import _
11 from node import short 12 from node import short, hex
12 import util 13 import util
13 14
14 def bisect(changelog, state): 15 def bisect(changelog, state):
15 """find the next node (if any) for testing during a bisect search. 16 """find the next node (if any) for testing during a bisect search.
16 returns a (nodes, number, good) tuple. 17 returns a (nodes, number, good) tuple.
114 115
115 assert best_rev is not None 116 assert best_rev is not None
116 best_node = changelog.node(best_rev) 117 best_node = changelog.node(best_rev)
117 118
118 return ([best_node], tot, good) 119 return ([best_node], tot, good)
120
121
122 def load_state(repo):
123 state = {'good': [], 'bad': [], 'skip': []}
124 if os.path.exists(repo.join("bisect.state")):
125 for l in repo.opener("bisect.state"):
126 kind, node = l[:-1].split()
127 node = repo.lookup(node)
128 if kind not in state:
129 raise util.Abort(_("unknown bisect kind %s") % kind)
130 state[kind].append(node)
131 return state
132
133
134 def save_state(repo, state):
135 f = repo.opener("bisect.state", "w", atomictemp=True)
136 wlock = repo.wlock()
137 try:
138 for kind in state:
139 for node in state[kind]:
140 f.write("%s %s\n" % (kind, hex(node)))
141 f.rename()
142 finally:
143 del wlock
144