Show More
@@ -1,11 +1,10 b'' | |||
|
1 | #!/usr/bin/env python | |
|
1 | # bisect extension for mercurial | |
|
2 | 2 | # |
|
3 | 3 | # This software may be used and distributed according to the terms |
|
4 | 4 | # of the GNU General Public License, incorporated herein by reference. |
|
5 | 5 | |
|
6 | 6 | from mercurial.demandload import demandload |
|
7 | demandload(globals(), "os sys sets") | |
|
8 | from mercurial import hg | |
|
7 | demandload(globals(), "os sys sets mercurial:hg,util") | |
|
9 | 8 | |
|
10 | 9 | versionstr = "0.0.3" |
|
11 | 10 | |
@@ -30,33 +29,32 b' class bisect(object):' | |||
|
30 | 29 | """dichotomic search in the DAG of changesets""" |
|
31 | 30 | def __init__(self, ui, repo): |
|
32 | 31 | self.repo = repo |
|
33 |
self.path = |
|
|
32 | self.path = repo.join("bisect") | |
|
33 | self.opener = util.opener(self.path) | |
|
34 | 34 | self.ui = ui |
|
35 | 35 | self.goodrevs = [] |
|
36 | 36 | self.badrev = None |
|
37 | 37 | self.good_dirty = 0 |
|
38 | 38 | self.bad_dirty = 0 |
|
39 |
self.good_path = |
|
|
40 |
self.bad_path = |
|
|
39 | self.good_path = "good" | |
|
40 | self.bad_path = "bad" | |
|
41 | 41 | |
|
42 | s = self.good_path | |
|
43 | if os.path.exists(s): | |
|
44 | self.goodrevs = self.repo.opener(s).read().splitlines() | |
|
42 | if os.path.exists(os.path.join(self.path, self.good_path)): | |
|
43 | self.goodrevs = self.opener(self.good_path).read().splitlines() | |
|
45 | 44 | self.goodrevs = [hg.bin(x) for x in self.goodrevs] |
|
46 | s = self.bad_path | |
|
47 | if os.path.exists(s): | |
|
48 | r = self.repo.opener(s).read().splitlines() | |
|
45 | if os.path.exists(os.path.join(self.path, self.bad_path)): | |
|
46 | r = self.opener(self.bad_path).read().splitlines() | |
|
49 | 47 | if r: |
|
50 | 48 | self.badrev = hg.bin(r.pop(0)) |
|
51 | 49 | |
|
52 | 50 | def __del__(self): |
|
53 | 51 | if not os.path.isdir(self.path): |
|
54 | 52 | return |
|
55 |
f = self |
|
|
53 | f = self.opener(self.good_path, "w") | |
|
56 | 54 | f.write("\n".join([hg.hex(r) for r in self.goodrevs])) |
|
57 | 55 | if len(self.goodrevs) > 0: |
|
58 | 56 | f.write("\n") |
|
59 |
f = self |
|
|
57 | f = self.opener(self.bad_path, "w") | |
|
60 | 58 | if self.badrev: |
|
61 | 59 | f.write(hg.hex(self.badrev) + "\n") |
|
62 | 60 | |
@@ -72,7 +70,8 b' class bisect(object):' | |||
|
72 | 70 | def reset(self): |
|
73 | 71 | """finish a bisection""" |
|
74 | 72 | if os.path.isdir(self.path): |
|
75 |
sl = [self. |
|
|
73 | sl = [os.path.join(self.path, p) | |
|
74 | for p in [self.bad_path, self.good_path]] | |
|
76 | 75 | for s in sl: |
|
77 | 76 | if os.path.exists(s): |
|
78 | 77 | os.unlink(s) |
@@ -114,7 +113,8 b' class bisect(object):' | |||
|
114 | 113 | cl = self.repo.changelog |
|
115 | 114 | if not stop: |
|
116 | 115 | stop = sets.Set([]) |
|
117 |
for |
|
|
116 | for i in xrange(len(self.goodrevs)-1, -1, -1): | |
|
117 | g = self.goodrevs[i] | |
|
118 | 118 | if g in stop: |
|
119 | 119 | continue |
|
120 | 120 | stop.update(cl.reachable(g)) |
@@ -162,7 +162,8 b' class bisect(object):' | |||
|
162 | 162 | if not self.goodrevs: |
|
163 | 163 | self.ui.warn("No good revision given\n") |
|
164 | 164 | self.ui.warn("Assuming the first revision is good\n") |
|
165 |
ancestors, num_ancestors = self.__ancestors_and_nb_ancestors( |
|
|
165 | ancestors, num_ancestors = self.__ancestors_and_nb_ancestors( | |
|
166 | self.badrev) | |
|
166 | 167 | tot = len(ancestors) |
|
167 | 168 | if tot == 1: |
|
168 | 169 | if ancestors.pop() != self.badrev: |
@@ -281,7 +282,6 b' for subcommands see "hg bisect help\\"' | |||
|
281 | 282 | return bisectcmdtable[cmd][0](*args) |
|
282 | 283 | |
|
283 | 284 | cmdtable = { |
|
284 | "bisect": (bisect_run, [], | |
|
285 | "hg bisect [help|init|reset|next|good|bad]"), | |
|
285 | "bisect": (bisect_run, [], "hg bisect [help|init|reset|next|good|bad]"), | |
|
286 | 286 | #"bisect-test": (test, [], "hg bisect-test rev"), |
|
287 | 287 | } |
General Comments 0
You need to be logged in to leave comments.
Login now