/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.54.61 by Jeff Licquia
Assign copyright to Canonical.
1
# Copyright (C) 2008 Canonical Ltd
2
#
0.54.34 by Jeff Licquia
Add copyright/license info.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
0.54.61 by Jeff Licquia
Assign copyright to Canonical.
6
# (at your option) any later version.
0.54.57 by Jeff Licquia
Check and fix more PEP 8 failures.
7
#
0.54.34 by Jeff Licquia
Add copyright/license info.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
0.54.57 by Jeff Licquia
Check and fix more PEP 8 failures.
12
#
0.54.34 by Jeff Licquia
Add copyright/license info.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
0.54.38 by Jeff Licquia
Add plugin description docstring.
17
"Support for git-style bisection."
18
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
19
import sys
0.54.4 by Jeff Licquia
Add test setup and dummy test.
20
import os
0.54.12 by Jeff Licquia
Add some bzr functionality.
21
import bzrlib.bzrdir
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
22
from bzrlib.commands import Command, register_command
0.54.3 by Jeff Licquia
Add test suite and get plugin to load.
23
from bzrlib.errors import BzrCommandError
0.54.37 by Jeff Licquia
Import the proper things for Option to work.
24
from bzrlib.option import Option
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
25
0.54.60 by Jeff Licquia
Move plugin metadata to its own package, and redo versioning.
26
from meta import *
27
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
28
bisect_info_path = ".bzr/bisect"
0.54.25 by Jeff Licquia
Change name of revid file.
29
bisect_rev_path = ".bzr/bisect_revid"
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
30
0.54.52 by Jeff Licquia
PEP 8 fixes.
31
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
32
class BisectCurrent(object):
33
    "Bisect class for managing the current revision."
34
35
    def __init__(self, filename = bisect_rev_path):
36
        self._filename = filename
37
        self._bzrdir = bzrlib.bzrdir.BzrDir.open_containing(".")[0]
0.54.16 by Jeff Licquia
Fix revision ID handling in BisectCurrent.
38
        self._bzrbranch = self._bzrdir.open_branch()
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
39
        if os.path.exists(filename):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
40
            revid_file = open(filename)
41
            self._revid = revid_file.read().strip()
42
            revid_file.close()
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
43
        else:
0.54.27 by Jeff Licquia
Use the -r parameter when setting the bisect status, instead of setting
44
            self._revid = self._bzrbranch.last_revision()
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
45
46
    def _save(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
47
        "Save the current revision."
48
49
        revid_file = open(self._filename, "w")
50
        revid_file.write(self._revid + "\n")
51
        revid_file.close()
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
52
0.54.27 by Jeff Licquia
Use the -r parameter when setting the bisect status, instead of setting
53
    def get_current_revid(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
54
        "Return the current revision id."
0.54.27 by Jeff Licquia
Use the -r parameter when setting the bisect status, instead of setting
55
        return self._revid
56
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
57
    def get_parent_revids(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
58
        "Return the IDs of the current revision's predecessors."
0.54.55 by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility.
59
        repo = self._bzrbranch.repository
60
        repo.lock_read()
0.56.2 by Daniel Watkins
Fixed use of deprecated Repository.get_parents interface.
61
        retval = repo.get_parent_map([self._revid]).get(self._revid, None)
0.54.55 by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility.
62
        repo.unlock()
63
        return retval
0.54.44 by Jeff Licquia
Implement is_merge_point().
64
0.54.43 by Jeff Licquia
Add non-functioning is_merge_point() method to BisectCurrent.
65
    def is_merge_point(self):
66
        "Is the current revision a merge point?"
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
67
        return len(self.get_parent_revids()) > 1
0.54.43 by Jeff Licquia
Add non-functioning is_merge_point() method to BisectCurrent.
68
0.54.32 by Jeff Licquia
When changing revisions, print information about the revision.
69
    def show_rev_log(self, out = sys.stdout):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
70
        "Write the current revision's log entry to a file."
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
71
        rev = self._bzrbranch.repository.get_revision(self._revid)
0.54.56 by Jeff Licquia
Fix some pylint complaints.
72
        out.write("On revision ?? (%s):\n%s\n" % (rev.revision_id,
73
                                                  rev.message))
0.54.32 by Jeff Licquia
When changing revisions, print information about the revision.
74
0.54.22 by Jeff Licquia
Get BisectCurrent working.
75
    def switch(self, revid):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
76
        "Switch the current revision to the given revid."
77
        working = self._bzrdir.open_workingtree()
0.54.22 by Jeff Licquia
Get BisectCurrent working.
78
        if isinstance(revid, int):
79
            revid = self._bzrbranch.get_rev_id(revid)
0.54.31 by Jeff Licquia
Do revision specs properly with "bisect move".
80
        elif isinstance(revid, list):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
81
            revid = revid[0].in_history(working.branch).rev_id
0.56.1 by Daniel Watkins
Fixed use of deprecated WT.revert behaviour.
82
        working.revert(None, working.branch.repository.revision_tree(revid),
0.54.56 by Jeff Licquia
Fix some pylint complaints.
83
                       False)
0.54.22 by Jeff Licquia
Get BisectCurrent working.
84
        self._revid = revid
0.54.14 by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class
85
        self._save()
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
86
0.54.22 by Jeff Licquia
Get BisectCurrent working.
87
    def reset(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
88
        "Revert bisection, setting the working tree to normal."
89
        working = self._bzrdir.open_workingtree()
90
        last_rev = working.branch.last_revision()
91
        rev_tree = working.branch.repository.revision_tree(last_rev)
0.56.1 by Daniel Watkins
Fixed use of deprecated WT.revert behaviour.
92
        working.revert(None, rev_tree, False)
0.54.24 by Jeff Licquia
Only remove the bzr revno file if it exists.
93
        if os.path.exists(bisect_rev_path):
94
            os.unlink(bisect_rev_path)
0.54.22 by Jeff Licquia
Get BisectCurrent working.
95
0.54.52 by Jeff Licquia
PEP 8 fixes.
96
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
97
class BisectLog(object):
98
    "Bisect log file handler."
99
100
    def __init__(self, filename = bisect_info_path):
101
        self._items = []
0.54.16 by Jeff Licquia
Fix revision ID handling in BisectCurrent.
102
        self._current = BisectCurrent()
0.54.12 by Jeff Licquia
Add some bzr functionality.
103
        self._bzrdir = None
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
104
        self._high_revid = None
105
        self._low_revid = None
0.54.45 by Jeff Licquia
Refactor finding range and middle; store the middle revid, not revno.
106
        self._middle_revid = None
0.54.56 by Jeff Licquia
Fix some pylint complaints.
107
        self._filename = filename
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
108
        self.load()
109
110
    def _open_for_read(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
111
        "Open log file for reading."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
112
        if self._filename:
113
            return open(self._filename)
114
        else:
115
            return sys.stdin
116
117
    def _open_for_write(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
118
        "Open log file for writing."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
119
        if self._filename:
120
            return open(self._filename, "w")
121
        else:
122
            return sys.stdout
123
0.54.12 by Jeff Licquia
Add some bzr functionality.
124
    def _load_bzr_tree(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
125
        "Load bzr information."
0.54.12 by Jeff Licquia
Add some bzr functionality.
126
        if not self._bzrdir:
127
            self._bzrdir = bzrlib.bzrdir.BzrDir.open_containing('.')[0]
128
            self._bzrbranch = self._bzrdir.open_branch()
129
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
130
    def _find_range_and_middle(self, branch_last_rev = None):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
131
        "Find the current revision range, and the midpoint."
0.54.12 by Jeff Licquia
Add some bzr functionality.
132
        self._load_bzr_tree()
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
133
        self._middle_revid = None
0.54.21 by Jeff Licquia
The bisect call should detect a missing range, and just silently return.
134
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
135
        if not branch_last_rev:
136
            last_revid = self._bzrbranch.last_revision()
137
        else:
138
            last_revid = branch_last_rev
139
0.54.52 by Jeff Licquia
PEP 8 fixes.
140
        repo = self._bzrbranch.repository
0.54.55 by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility.
141
        repo.lock_read()
0.54.52 by Jeff Licquia
PEP 8 fixes.
142
        rev_sequence = repo.iter_reverse_revision_history(last_revid)
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
143
        high_revid = None
144
        low_revid = None
145
        between_revs = []
0.54.48 by Jeff Licquia
More refactoring: go backwards from a high revision when finding the
146
        for revision in rev_sequence:
147
            between_revs.insert(0, revision)
0.54.52 by Jeff Licquia
PEP 8 fixes.
148
            matches = [x[1] for x in self._items
0.54.20 by Jeff Licquia
When looking for range, only use revision entries that have been
149
                       if x[0] == revision and x[1] in ('yes', 'no')]
0.54.12 by Jeff Licquia
Add some bzr functionality.
150
            if not matches:
151
                continue
152
            if len(matches) > 1:
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
153
                raise RuntimeError("revision %s duplicated" % revision)
0.54.12 by Jeff Licquia
Add some bzr functionality.
154
            if matches[0] == "yes":
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
155
                high_revid = revision
0.54.48 by Jeff Licquia
More refactoring: go backwards from a high revision when finding the
156
                between_revs = []
0.54.12 by Jeff Licquia
Add some bzr functionality.
157
            elif matches[0] == "no":
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
158
                low_revid = revision
0.54.48 by Jeff Licquia
More refactoring: go backwards from a high revision when finding the
159
                del between_revs[0]
160
                break
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
161
162
        if not high_revid:
163
            high_revid = last_revid
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
164
        if not low_revid:
165
            low_revid = self._bzrbranch.get_rev_id(1)
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
166
0.54.55 by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility.
167
        repo.unlock()
168
0.54.47 by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of
169
        # The spread must include the high revision, to bias
170
        # odd numbers of intervening revisions towards the high
171
        # side.
172
173
        spread = len(between_revs) + 1
174
        if spread < 2:
175
            middle_index = 0
176
        else:
177
            middle_index = (spread / 2) - 1
178
179
        if len(between_revs) > 0:
180
            self._middle_revid = between_revs[middle_index]
181
        else:
182
            self._middle_revid = high_revid
0.54.12 by Jeff Licquia
Add some bzr functionality.
183
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
184
        self._high_revid = high_revid
185
        self._low_revid = low_revid
186
0.54.12 by Jeff Licquia
Add some bzr functionality.
187
    def _switch_wc_to_revno(self, revno):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
188
        "Move the working tree to the given revno."
0.54.18 by Jeff Licquia
Incorporate use of new BisectCurrent objects where appropriate.
189
        self._current.switch(revno)
0.54.32 by Jeff Licquia
When changing revisions, print information about the revision.
190
        self._current.show_rev_log()
0.54.12 by Jeff Licquia
Add some bzr functionality.
191
0.54.30 by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right
192
    def _set_status(self, revid, status):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
193
        "Set the bisect status for the given revid."
0.54.46 by Jeff Licquia
Report a proper error when trying to mark the same revid twice.
194
        if revid in [x[0] for x in self._items if x[1] in ['yes', 'no']]:
0.54.52 by Jeff Licquia
PEP 8 fixes.
195
            raise RuntimeError("attempting to add revid %s twice" % revid)
0.54.30 by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right
196
        self._items.append((revid, status))
197
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
198
    def change_file_name(self, filename):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
199
        "Switch log files."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
200
        self._filename = filename
201
202
    def load(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
203
        "Load the bisection log."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
204
        self._items = []
205
        if os.path.exists(self._filename):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
206
            revlog = self._open_for_read()
207
            for line in revlog:
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
208
                (revid, status) = line.split()
209
                self._items.append((revid, status))
210
211
    def save(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
212
        "Save the bisection log."
213
        revlog = self._open_for_write()
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
214
        for (revid, status) in self._items:
0.54.56 by Jeff Licquia
Fix some pylint complaints.
215
            revlog.write("%s %s\n" % (revid, status))
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
216
0.54.30 by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right
217
    def set_status_from_revspec(self, revspec, status):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
218
        "Set the bisection status for the revision in revspec."
0.54.30 by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right
219
        self._load_bzr_tree()
220
        revid = revspec[0].in_history(self._bzrbranch).rev_id
221
        self._set_status(revid, status)
0.54.27 by Jeff Licquia
Use the -r parameter when setting the bisect status, instead of setting
222
0.54.12 by Jeff Licquia
Add some bzr functionality.
223
    def set_current(self, status):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
224
        "Set the current revision to the given bisection status."
0.54.30 by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right
225
        self._set_status(self._current.get_current_revid(), status)
0.54.12 by Jeff Licquia
Add some bzr functionality.
226
227
    def bisect(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
228
        "Using the current revision's status, do a bisection."
0.54.51 by Jeff Licquia
Get subtree traversal working properly at last.
229
        self._find_range_and_middle()
230
        self._switch_wc_to_revno(self._middle_revid)
231
232
        # If we've found the "final" revision, check for a
233
        # merge point.
234
235
        if self._middle_revid == self._high_revid and \
236
           self._current.is_merge_point():
237
            for parent in self._current.get_parent_revids():
238
                if parent == self._low_revid:
239
                    continue
240
                else:
241
                    self._find_range_and_middle(parent)
242
                    self._switch_wc_to_revno(self._middle_revid)
243
                    break
0.54.12 by Jeff Licquia
Add some bzr functionality.
244
0.54.52 by Jeff Licquia
PEP 8 fixes.
245
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
246
class cmd_bisect(Command):
247
    """Find an interesting commit using a binary search.
248
249
    Bisecting, in a nutshell, is a way to find the commit at which
250
    some testable change was made, such as the introduction of a bug
251
    or feature.  By identifying a version which did not have the
252
    interesting change and a later version which did, a developer
253
    can test for the presence of the change at various points in
254
    the history, eventually ending up at the precise commit when
255
    the change was first introduced.
256
257
    This command uses subcommands to implement the search, each
258
    of which changes the state of the bisection.  The
259
    subcommands are:
260
261
    bzr bisect start
262
        Start a bisect, possibly clearing out a previous bisect.
263
264
    bzr bisect yes [-r rev]
265
        The specified revision (or the current revision, if not given)
266
        has the characteristic we're looking for,
267
268
    bzr bisect no [-r rev]
269
        The specified revision (or the current revision, if not given)
0.55.1 by Doug Lee
Minor spello fix.
270
        does not have the characteristic we're looking for,
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
271
0.54.13 by Jeff Licquia
Since bzr does not store a "current revision" other than the last
272
    bzr bisect move -r rev
273
        Switch to a different revision manually.  Use if the bisect
274
        algorithm chooses a revision that is not suitable.  Try to
275
        move as little as possible.
276
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
277
    bzr bisect reset
278
        Clear out a bisection in progress.
279
0.54.36 by Jeff Licquia
Add -o for log, and use it in the tests to capture the log.
280
    bzr bisect log [-o file]
281
        Output a log of the current bisection to standard output, or
282
        to the specified file.
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
283
284
    bzr bisect replay <logfile>
285
        Replay a previously-saved bisect log, forgetting any bisection
286
        that might be in progress.
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
287
    """
288
289
    takes_args = ['subcommand', 'args*']
0.54.36 by Jeff Licquia
Add -o for log, and use it in the tests to capture the log.
290
    takes_options = [Option('output', short_name='o',
291
                            help='Write log to this file.', type=unicode),
292
                     'revision']
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
293
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
294
    def _check(self):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
295
        "Check preconditions for most operations to work."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
296
        if not os.path.exists(bisect_info_path):
297
            raise BzrCommandError("No bisect info found")
298
0.54.29 by Jeff Licquia
Oops! Mark start of method properly.
299
    def _set_state(self, revspec, state):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
300
        "Set the state of the given revspec and bisecting."
301
        bisect_log = BisectLog()
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
302
        if revspec:
0.54.56 by Jeff Licquia
Fix some pylint complaints.
303
            bisect_log.set_status_from_revspec(revspec, state)
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
304
        else:
0.54.56 by Jeff Licquia
Fix some pylint complaints.
305
            bisect_log.set_current(state)
306
        bisect_log.bisect()
307
        bisect_log.save()
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
308
0.54.36 by Jeff Licquia
Add -o for log, and use it in the tests to capture the log.
309
    def run(self, subcommand, args_list, revision=None, output=None):
0.54.56 by Jeff Licquia
Fix some pylint complaints.
310
        "Handle the bisect command."
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
311
312
        log_fn = None
0.54.13 by Jeff Licquia
Since bzr does not store a "current revision" other than the last
313
        if subcommand in ('yes', 'no', 'move') and revision:
0.54.8 by Jeff Licquia
Fix dispatcher.
314
            pass
0.54.57 by Jeff Licquia
Check and fix more PEP 8 failures.
315
        elif subcommand in ('replay', ) and args_list and len(args_list) == 1:
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
316
            log_fn = args_list[0]
0.54.57 by Jeff Licquia
Check and fix more PEP 8 failures.
317
        elif subcommand in ('move', ) and not revision:
0.54.52 by Jeff Licquia
PEP 8 fixes.
318
            raise BzrCommandError(
319
                "The 'bisect move' command requires a revision.")
0.54.8 by Jeff Licquia
Fix dispatcher.
320
        elif args_list or revision:
0.54.52 by Jeff Licquia
PEP 8 fixes.
321
            raise BzrCommandError(
322
                "Improper arguments to bisect " + subcommand)
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
323
324
        # Dispatch.
325
326
        if subcommand == "start":
327
            self.start()
328
        elif subcommand == "yes":
329
            self.yes(revision)
330
        elif subcommand == "no":
331
            self.no(revision)
0.54.13 by Jeff Licquia
Since bzr does not store a "current revision" other than the last
332
        elif subcommand == "move":
333
            self.move(revision)
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
334
        elif subcommand == "reset":
335
            self.reset()
336
        elif subcommand == "log":
0.54.36 by Jeff Licquia
Add -o for log, and use it in the tests to capture the log.
337
            self.log(output)
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
338
        elif subcommand == "replay":
339
            self.replay(log_fn)
340
341
    def reset(self):
342
        "Reset the bisect state to no state."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
343
0.54.22 by Jeff Licquia
Get BisectCurrent working.
344
        BisectCurrent().reset()
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
345
        if os.path.exists(bisect_info_path):
346
            os.unlink(bisect_info_path)
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
347
348
    def start(self):
349
        "Reset the bisect state, then prepare for a new bisection."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
350
351
        self.reset()
0.54.56 by Jeff Licquia
Fix some pylint complaints.
352
        bisect_log = BisectLog()
353
        bisect_log.set_current("start")
354
        bisect_log.save()
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
355
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
356
    def yes(self, revspec):
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
357
        "Mark that a given revision has the state we're looking for."
0.54.12 by Jeff Licquia
Add some bzr functionality.
358
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
359
        self._set_state(revspec, "yes")
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
360
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
361
    def no(self, revspec):
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
362
        "Mark that a given revision does not have the state we're looking for."
0.54.12 by Jeff Licquia
Add some bzr functionality.
363
0.54.28 by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors.
364
        self._set_state(revspec, "no")
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
365
0.54.31 by Jeff Licquia
Do revision specs properly with "bisect move".
366
    def move(self, revspec):
0.54.13 by Jeff Licquia
Since bzr does not store a "current revision" other than the last
367
        "Move to a different revision manually."
368
0.54.56 by Jeff Licquia
Fix some pylint complaints.
369
        current = BisectCurrent()
370
        current.switch(revspec)
371
        current.show_rev_log()
0.54.13 by Jeff Licquia
Since bzr does not store a "current revision" other than the last
372
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
373
    def log(self, filename):
374
        "Write the current bisect log to a file."
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
375
376
        self._check()
377
0.54.56 by Jeff Licquia
Fix some pylint complaints.
378
        bisect_log = BisectLog()
379
        bisect_log.change_file_name(filename)
380
        bisect_log.save()
0.54.2 by Jeff Licquia
Set up the subcommand dispatcher.
381
382
    def replay(self, filename):
383
        """Apply the given log file to a clean state, so the state is
384
        exactly as it was when the log was saved."""
0.54.11 by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it.
385
386
        self.reset()
387
0.54.56 by Jeff Licquia
Fix some pylint complaints.
388
        bisect_log = BisectLog(filename)
389
        bisect_log.change_file_name(bisect_info_path)
390
        bisect_log.save()
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
391
0.54.56 by Jeff Licquia
Fix some pylint complaints.
392
        bisect_log.bisect()
0.54.12 by Jeff Licquia
Add some bzr functionality.
393
0.54.1 by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for
394
register_command(cmd_bisect)
0.54.3 by Jeff Licquia
Add test suite and get plugin to load.
395
0.54.52 by Jeff Licquia
PEP 8 fixes.
396
0.54.3 by Jeff Licquia
Add test suite and get plugin to load.
397
def test_suite():
0.54.56 by Jeff Licquia
Fix some pylint complaints.
398
    "Set up the test suite for the plugin."
0.54.40 by Jeff Licquia
Move the tests to their own module.
399
    from bzrlib.plugins.bisect import tests
0.54.53 by Jeff Licquia
Move test suite detection function to the test module.
400
    return tests.test_suite()