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.59.2
by Jeff Licquia
Report revision numbers on each bisection. |
72 |
revno = self._bzrbranch.revision_id_to_revno(rev.revision_id) |
73 |
out.write("On revision %d (%s):\n%s\n" % (revno, rev.revision_id, |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
74 |
rev.message)) |
|
0.54.32
by Jeff Licquia
When changing revisions, print information about the revision. |
75 |
|
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
76 |
def switch(self, revid): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
77 |
"Switch the current revision to the given revid."
|
78 |
working = self._bzrdir.open_workingtree() |
|
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
79 |
if isinstance(revid, int): |
80 |
revid = self._bzrbranch.get_rev_id(revid) |
|
|
0.54.31
by Jeff Licquia
Do revision specs properly with "bisect move". |
81 |
elif isinstance(revid, list): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
82 |
revid = revid[0].in_history(working.branch).rev_id |
|
0.56.1
by Daniel Watkins
Fixed use of deprecated WT.revert behaviour. |
83 |
working.revert(None, working.branch.repository.revision_tree(revid), |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
84 |
False) |
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
85 |
self._revid = revid |
|
0.54.14
by Jeff Licquia
Create a parent for the test classes, and add a BisectCurrent class |
86 |
self._save() |
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
87 |
|
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
88 |
def reset(self): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
89 |
"Revert bisection, setting the working tree to normal."
|
90 |
working = self._bzrdir.open_workingtree() |
|
91 |
last_rev = working.branch.last_revision() |
|
92 |
rev_tree = working.branch.repository.revision_tree(last_rev) |
|
|
0.56.1
by Daniel Watkins
Fixed use of deprecated WT.revert behaviour. |
93 |
working.revert(None, rev_tree, False) |
|
0.54.24
by Jeff Licquia
Only remove the bzr revno file if it exists. |
94 |
if os.path.exists(bisect_rev_path): |
95 |
os.unlink(bisect_rev_path) |
|
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
96 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
97 |
|
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
98 |
class BisectLog(object): |
99 |
"Bisect log file handler."
|
|
100 |
||
101 |
def __init__(self, filename = bisect_info_path): |
|
102 |
self._items = [] |
|
|
0.54.16
by Jeff Licquia
Fix revision ID handling in BisectCurrent. |
103 |
self._current = BisectCurrent() |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
104 |
self._bzrdir = None |
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
105 |
self._high_revid = None |
106 |
self._low_revid = None |
|
|
0.54.45
by Jeff Licquia
Refactor finding range and middle; store the middle revid, not revno. |
107 |
self._middle_revid = None |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
108 |
self._filename = filename |
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
109 |
self.load() |
110 |
||
111 |
def _open_for_read(self): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
112 |
"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. |
113 |
if self._filename: |
114 |
return open(self._filename) |
|
115 |
else: |
|
116 |
return sys.stdin |
|
117 |
||
118 |
def _open_for_write(self): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
119 |
"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. |
120 |
if self._filename: |
121 |
return open(self._filename, "w") |
|
122 |
else: |
|
123 |
return sys.stdout |
|
124 |
||
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
125 |
def _load_bzr_tree(self): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
126 |
"Load bzr information."
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
127 |
if not self._bzrdir: |
128 |
self._bzrdir = bzrlib.bzrdir.BzrDir.open_containing('.')[0] |
|
129 |
self._bzrbranch = self._bzrdir.open_branch() |
|
130 |
||
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
131 |
def _find_range_and_middle(self, branch_last_rev = None): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
132 |
"Find the current revision range, and the midpoint."
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
133 |
self._load_bzr_tree() |
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
134 |
self._middle_revid = None |
|
0.54.21
by Jeff Licquia
The bisect call should detect a missing range, and just silently return. |
135 |
|
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
136 |
if not branch_last_rev: |
137 |
last_revid = self._bzrbranch.last_revision() |
|
138 |
else: |
|
139 |
last_revid = branch_last_rev |
|
140 |
||
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
141 |
repo = self._bzrbranch.repository |
|
0.54.55
by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility. |
142 |
repo.lock_read() |
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
143 |
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 |
144 |
high_revid = None |
145 |
low_revid = None |
|
146 |
between_revs = [] |
|
|
0.54.48
by Jeff Licquia
More refactoring: go backwards from a high revision when finding the |
147 |
for revision in rev_sequence: |
148 |
between_revs.insert(0, revision) |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
149 |
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 |
150 |
if x[0] == revision and x[1] in ('yes', 'no')] |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
151 |
if not matches: |
152 |
continue
|
|
153 |
if len(matches) > 1: |
|
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
154 |
raise RuntimeError("revision %s duplicated" % revision) |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
155 |
if matches[0] == "yes": |
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
156 |
high_revid = revision |
|
0.54.48
by Jeff Licquia
More refactoring: go backwards from a high revision when finding the |
157 |
between_revs = [] |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
158 |
elif matches[0] == "no": |
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
159 |
low_revid = revision |
|
0.54.48
by Jeff Licquia
More refactoring: go backwards from a high revision when finding the |
160 |
del between_revs[0] |
161 |
break
|
|
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
162 |
|
163 |
if not high_revid: |
|
164 |
high_revid = last_revid |
|
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
165 |
if not low_revid: |
166 |
low_revid = self._bzrbranch.get_rev_id(1) |
|
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
167 |
|
|
0.54.55
by Jeff Licquia
Fix more missing locks, found in testing bzr 1.0 compatibility. |
168 |
repo.unlock() |
169 |
||
|
0.54.47
by Jeff Licquia
Refactor: when finding the middle, iterate over revids instead of |
170 |
# The spread must include the high revision, to bias
|
171 |
# odd numbers of intervening revisions towards the high
|
|
172 |
# side.
|
|
173 |
||
174 |
spread = len(between_revs) + 1 |
|
175 |
if spread < 2: |
|
176 |
middle_index = 0 |
|
177 |
else: |
|
178 |
middle_index = (spread / 2) - 1 |
|
179 |
||
180 |
if len(between_revs) > 0: |
|
181 |
self._middle_revid = between_revs[middle_index] |
|
182 |
else: |
|
183 |
self._middle_revid = high_revid |
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
184 |
|
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
185 |
self._high_revid = high_revid |
186 |
self._low_revid = low_revid |
|
187 |
||
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
188 |
def _switch_wc_to_revno(self, revno): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
189 |
"Move the working tree to the given revno."
|
|
0.54.18
by Jeff Licquia
Incorporate use of new BisectCurrent objects where appropriate. |
190 |
self._current.switch(revno) |
|
0.54.32
by Jeff Licquia
When changing revisions, print information about the revision. |
191 |
self._current.show_rev_log() |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
192 |
|
|
0.54.30
by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right |
193 |
def _set_status(self, revid, status): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
194 |
"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. |
195 |
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. |
196 |
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 |
197 |
self._items.append((revid, status)) |
198 |
||
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
199 |
def change_file_name(self, filename): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
200 |
"Switch log files."
|
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
201 |
self._filename = filename |
202 |
||
203 |
def load(self): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
204 |
"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. |
205 |
self._items = [] |
206 |
if os.path.exists(self._filename): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
207 |
revlog = self._open_for_read() |
208 |
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. |
209 |
(revid, status) = line.split() |
210 |
self._items.append((revid, status)) |
|
211 |
||
212 |
def save(self): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
213 |
"Save the bisection log."
|
214 |
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. |
215 |
for (revid, status) in self._items: |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
216 |
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. |
217 |
|
|
0.54.30
by Jeff Licquia
Distinguish between revision specs and revision ids, and do the right |
218 |
def set_status_from_revspec(self, revspec, status): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
219 |
"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 |
220 |
self._load_bzr_tree() |
221 |
revid = revspec[0].in_history(self._bzrbranch).rev_id |
|
222 |
self._set_status(revid, status) |
|
|
0.54.27
by Jeff Licquia
Use the -r parameter when setting the bisect status, instead of setting |
223 |
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
224 |
def set_current(self, status): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
225 |
"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 |
226 |
self._set_status(self._current.get_current_revid(), status) |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
227 |
|
228 |
def bisect(self): |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
229 |
"Using the current revision's status, do a bisection."
|
|
0.54.51
by Jeff Licquia
Get subtree traversal working properly at last. |
230 |
self._find_range_and_middle() |
231 |
self._switch_wc_to_revno(self._middle_revid) |
|
232 |
||
233 |
# If we've found the "final" revision, check for a
|
|
234 |
# merge point.
|
|
235 |
||
236 |
if self._middle_revid == self._high_revid and \ |
|
237 |
self._current.is_merge_point(): |
|
238 |
for parent in self._current.get_parent_revids(): |
|
239 |
if parent == self._low_revid: |
|
240 |
continue
|
|
241 |
else: |
|
242 |
self._find_range_and_middle(parent) |
|
243 |
self._switch_wc_to_revno(self._middle_revid) |
|
244 |
break
|
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
245 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
246 |
|
|
0.54.1
by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for |
247 |
class cmd_bisect(Command): |
248 |
"""Find an interesting commit using a binary search. |
|
249 |
||
250 |
Bisecting, in a nutshell, is a way to find the commit at which
|
|
251 |
some testable change was made, such as the introduction of a bug
|
|
252 |
or feature. By identifying a version which did not have the
|
|
253 |
interesting change and a later version which did, a developer
|
|
254 |
can test for the presence of the change at various points in
|
|
255 |
the history, eventually ending up at the precise commit when
|
|
256 |
the change was first introduced.
|
|
257 |
||
258 |
This command uses subcommands to implement the search, each
|
|
259 |
of which changes the state of the bisection. The
|
|
260 |
subcommands are:
|
|
261 |
||
262 |
bzr bisect start
|
|
263 |
Start a bisect, possibly clearing out a previous bisect.
|
|
264 |
||
265 |
bzr bisect yes [-r rev]
|
|
266 |
The specified revision (or the current revision, if not given)
|
|
267 |
has the characteristic we're looking for,
|
|
268 |
||
269 |
bzr bisect no [-r rev]
|
|
270 |
The specified revision (or the current revision, if not given)
|
|
|
0.55.1
by Doug Lee
Minor spello fix. |
271 |
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 |
272 |
|
|
0.54.13
by Jeff Licquia
Since bzr does not store a "current revision" other than the last |
273 |
bzr bisect move -r rev
|
274 |
Switch to a different revision manually. Use if the bisect
|
|
275 |
algorithm chooses a revision that is not suitable. Try to
|
|
276 |
move as little as possible.
|
|
277 |
||
|
0.54.1
by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for |
278 |
bzr bisect reset
|
279 |
Clear out a bisection in progress.
|
|
280 |
||
|
0.54.36
by Jeff Licquia
Add -o for log, and use it in the tests to capture the log. |
281 |
bzr bisect log [-o file]
|
282 |
Output a log of the current bisection to standard output, or
|
|
283 |
to the specified file.
|
|
|
0.54.1
by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for |
284 |
|
285 |
bzr bisect replay <logfile>
|
|
286 |
Replay a previously-saved bisect log, forgetting any bisection
|
|
287 |
that might be in progress.
|
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
288 |
"""
|
289 |
||
290 |
takes_args = ['subcommand', 'args*'] |
|
|
0.54.36
by Jeff Licquia
Add -o for log, and use it in the tests to capture the log. |
291 |
takes_options = [Option('output', short_name='o', |
292 |
help='Write log to this file.', type=unicode), |
|
293 |
'revision'] |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
294 |
|
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
295 |
def _check(self): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
296 |
"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. |
297 |
if not os.path.exists(bisect_info_path): |
298 |
raise BzrCommandError("No bisect info found") |
|
299 |
||
|
0.54.29
by Jeff Licquia
Oops! Mark start of method properly. |
300 |
def _set_state(self, revspec, state): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
301 |
"Set the state of the given revspec and bisecting."
|
302 |
bisect_log = BisectLog() |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
303 |
if revspec: |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
304 |
bisect_log.set_status_from_revspec(revspec, state) |
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
305 |
else: |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
306 |
bisect_log.set_current(state) |
307 |
bisect_log.bisect() |
|
308 |
bisect_log.save() |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
309 |
|
|
0.54.36
by Jeff Licquia
Add -o for log, and use it in the tests to capture the log. |
310 |
def run(self, subcommand, args_list, revision=None, output=None): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
311 |
"Handle the bisect command."
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
312 |
|
313 |
log_fn = None |
|
|
0.54.13
by Jeff Licquia
Since bzr does not store a "current revision" other than the last |
314 |
if subcommand in ('yes', 'no', 'move') and revision: |
|
0.54.8
by Jeff Licquia
Fix dispatcher. |
315 |
pass
|
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
316 |
elif subcommand in ('replay', ) and args_list and len(args_list) == 1: |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
317 |
log_fn = args_list[0] |
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
318 |
elif subcommand in ('move', ) and not revision: |
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
319 |
raise BzrCommandError( |
320 |
"The 'bisect move' command requires a revision.") |
|
|
0.54.8
by Jeff Licquia
Fix dispatcher. |
321 |
elif args_list or revision: |
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
322 |
raise BzrCommandError( |
323 |
"Improper arguments to bisect " + subcommand) |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
324 |
|
325 |
# Dispatch.
|
|
326 |
||
327 |
if subcommand == "start": |
|
328 |
self.start() |
|
329 |
elif subcommand == "yes": |
|
330 |
self.yes(revision) |
|
331 |
elif subcommand == "no": |
|
332 |
self.no(revision) |
|
|
0.54.13
by Jeff Licquia
Since bzr does not store a "current revision" other than the last |
333 |
elif subcommand == "move": |
334 |
self.move(revision) |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
335 |
elif subcommand == "reset": |
336 |
self.reset() |
|
337 |
elif subcommand == "log": |
|
|
0.54.36
by Jeff Licquia
Add -o for log, and use it in the tests to capture the log. |
338 |
self.log(output) |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
339 |
elif subcommand == "replay": |
340 |
self.replay(log_fn) |
|
341 |
||
342 |
def reset(self): |
|
343 |
"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. |
344 |
|
|
0.54.22
by Jeff Licquia
Get BisectCurrent working. |
345 |
BisectCurrent().reset() |
|
0.54.11
by Jeff Licquia
Add log file handler, give it basic I/O, and write first tests for it. |
346 |
if os.path.exists(bisect_info_path): |
347 |
os.unlink(bisect_info_path) |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
348 |
|
349 |
def start(self): |
|
350 |
"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. |
351 |
|
352 |
self.reset() |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
353 |
bisect_log = BisectLog() |
354 |
bisect_log.set_current("start") |
|
355 |
bisect_log.save() |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
356 |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
357 |
def yes(self, revspec): |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
358 |
"Mark that a given revision has the state we're looking for."
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
359 |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
360 |
self._set_state(revspec, "yes") |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
361 |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
362 |
def no(self, revspec): |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
363 |
"Mark that a given revision does not have the state we're looking for."
|
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
364 |
|
|
0.54.28
by Jeff Licquia
Refactor shared code to prevent cut-n-paste errors. |
365 |
self._set_state(revspec, "no") |
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
366 |
|
|
0.54.31
by Jeff Licquia
Do revision specs properly with "bisect move". |
367 |
def move(self, revspec): |
|
0.54.13
by Jeff Licquia
Since bzr does not store a "current revision" other than the last |
368 |
"Move to a different revision manually."
|
369 |
||
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
370 |
current = BisectCurrent() |
371 |
current.switch(revspec) |
|
372 |
current.show_rev_log() |
|
|
0.54.13
by Jeff Licquia
Since bzr does not store a "current revision" other than the last |
373 |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
374 |
def log(self, filename): |
375 |
"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. |
376 |
|
377 |
self._check() |
|
378 |
||
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
379 |
bisect_log = BisectLog() |
380 |
bisect_log.change_file_name(filename) |
|
381 |
bisect_log.save() |
|
|
0.54.2
by Jeff Licquia
Set up the subcommand dispatcher. |
382 |
|
383 |
def replay(self, filename): |
|
384 |
"""Apply the given log file to a clean state, so the state is |
|
385 |
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. |
386 |
|
387 |
self.reset() |
|
388 |
||
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
389 |
bisect_log = BisectLog(filename) |
390 |
bisect_log.change_file_name(bisect_info_path) |
|
391 |
bisect_log.save() |
|
|
0.54.1
by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for |
392 |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
393 |
bisect_log.bisect() |
|
0.54.12
by Jeff Licquia
Add some bzr functionality. |
394 |
|
|
0.54.1
by Jeff Licquia
Initial revision. The plugin skeleton is made, along with a spec for |
395 |
register_command(cmd_bisect) |
|
0.54.3
by Jeff Licquia
Add test suite and get plugin to load. |
396 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
397 |
|
|
0.54.3
by Jeff Licquia
Add test suite and get plugin to load. |
398 |
def test_suite(): |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
399 |
"Set up the test suite for the plugin."
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
400 |
from bzrlib.plugins.bisect import tests |
|
0.54.53
by Jeff Licquia
Move test suite detection function to the test module. |
401 |
return tests.test_suite() |