/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Jeff Licquia
  • Date: 2008-04-05 16:11:53 UTC
  • mto: (0.54.69 automated)
  • mto: This revision was merged to the branch mainline in revision 6630.
  • Revision ID: jeff@licquia.org-20080405161153-56i2qzlha5opaivp
Tests for detecting "done" status, plus a first run at implementation.
One test still fails.

Show diffs side-by-side

added added

removed removed

Lines of Context:
197
197
 
198
198
    def _set_status(self, revid, status):
199
199
        "Set the bisect status for the given revid."
200
 
        if revid in [x[0] for x in self._items if x[1] in ['yes', 'no']]:
201
 
            raise RuntimeError("attempting to add revid %s twice" % revid)
202
 
        self._items.append((revid, status))
 
200
        if not self.is_done():
 
201
            if status != "done" and revid in [x[0] for x in self._items 
 
202
                                              if x[1] in ['yes', 'no']]:
 
203
                raise RuntimeError("attempting to add revid %s twice" % revid)
 
204
            self._items.append((revid, status))
203
205
 
204
206
    def change_file_name(self, filename):
205
207
        "Switch log files."
220
222
        for (revid, status) in self._items:
221
223
            revlog.write("%s %s\n" % (revid, status))
222
224
 
 
225
    def is_done(self):
 
226
        "Report whether we've found the right revision."
 
227
        return len(self._items) > 0 and self._items[-1][1] == "done"
 
228
 
223
229
    def set_status_from_revspec(self, revspec, status):
224
230
        "Set the bisection status for the revision in revspec."
225
231
        self._load_bzr_tree()
238
244
        # If we've found the "final" revision, check for a
239
245
        # merge point.
240
246
 
241
 
        if self._middle_revid == self._high_revid and \
242
 
           self._current.is_merge_point():
243
 
            sys.stderr.write("final found!\n")
244
 
            for parent in self._current.get_parent_revids():
245
 
                if parent == self._low_revid:
246
 
                    continue
247
 
                else:
248
 
                    self._find_range_and_middle(parent)
249
 
                    self._switch_wc_to_revno(self._middle_revid)
250
 
                    break
 
247
        if self._middle_revid == self._high_revid or \
 
248
           self._middle_revid == self._low_revid:
 
249
            if self._current.is_merge_point():
 
250
                for parent in self._current.get_parent_revids():
 
251
                    if parent == self._low_revid:
 
252
                        continue
 
253
                    else:
 
254
                        self._find_range_and_middle(parent)
 
255
                        self._switch_wc_to_revno(self._middle_revid)
 
256
                        break
 
257
            else:
 
258
                self.set_current("done")
251
259
 
252
260
 
253
261
class cmd_bisect(Command):
306
314
    def _set_state(self, revspec, state):
307
315
        "Set the state of the given revspec and bisecting."
308
316
        bisect_log = BisectLog()
 
317
        if bisect_log.is_done():
 
318
            sys.stdout.write("No further bisection is possible.\n")
 
319
            bisect_log._current.show_rev_log(sys.stdout)
 
320
            return
 
321
 
309
322
        if revspec:
310
323
            bisect_log.set_status_from_revspec(revspec, state)
311
324
        else: