comparison mercurial/hbisect.py @ 15136:18219c0789ae

revset.bisect: add new 'range' set to the bisect keyword The 'range' set is made of all changesets that make the bisection range, that is - csets that are ancestors of bad csets and descendants of good csets or - csets that are ancestors of good csets and descendants of bad csets That is, roughly equivalent of: bisect(good)::bisect(bad) | bisect(bad)::bisect(good) Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
author "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
date Sat, 17 Sep 2011 17:33:34 +0200
parents f19de58af225
children 91f93dcd72aa
comparison
equal deleted inserted replaced
15135:f19de58af225 15136:18219c0789ae
157 def get(repo, status): 157 def get(repo, status):
158 """ 158 """
159 Return a list of revision(s) that match the given status: 159 Return a list of revision(s) that match the given status:
160 160
161 - ``good``, ``bad``, ``skip``: as the names imply 161 - ``good``, ``bad``, ``skip``: as the names imply
162 - ``range`` : all csets taking part in the bisection
162 """ 163 """
163 state = load_state(repo) 164 state = load_state(repo)
164 if status in ('good', 'bad', 'skip'): 165 if status in ('good', 'bad', 'skip'):
165 return [repo.changelog.rev(n) for n in state[status]] 166 return [repo.changelog.rev(n) for n in state[status]]
166 else: 167 else:
167 raise error.ParseError(_('invalid bisect state')) 168 # Build sets of good, bad, and skipped csets
169 goods = set(repo.changelog.rev(n) for n in state['good'])
170 bads = set(repo.changelog.rev(n) for n in state['bad'])
171 skips = set(repo.changelog.rev(n) for n in state['skip'])
172
173 # Build kinship of good csets
174 ga = goods.copy() # Goods' Ancestors
175 gd = goods.copy() # Goods' Descendants
176 for g in goods:
177 ga |= set(repo.changelog.ancestors(g))
178 gd |= set(repo.changelog.descendants(g))
179
180 # Build kinship of bad csets
181 ba = bads.copy() # Bads' Ancestors
182 bd = bads.copy() # Bads' Descendants
183 for b in bads:
184 ba |= set(repo.changelog.ancestors(b))
185 bd |= set(repo.changelog.descendants(b))
186
187 # Build the range of the bisection
188 range = set(c for c in ba if c in gd)
189 range |= set(c for c in ga if c in bd)
190
191 if status == 'range':
192 return [c for c in range]
193
194 else:
195 raise error.ParseError(_('invalid bisect state'))