89 not in stop. |
89 not in stop. |
90 """ |
90 """ |
91 if head is None: |
91 if head is None: |
92 head = self.badrev |
92 head = self.badrev |
93 return self.__ancestors_and_nb_ancestors(head, stop)[1] |
93 return self.__ancestors_and_nb_ancestors(head, stop)[1] |
94 |
94 |
95 def ancestors(self, head=None, stop=None): |
95 def ancestors(self, head=None, stop=None): |
96 """ |
96 """ |
97 returns the set of the ancestors of head (self included) |
97 returns the set of the ancestors of head (self included) |
98 who are not in stop. |
98 who are not in stop. |
99 """ |
99 """ |
100 if head is None: |
100 if head is None: |
101 head = self.badrev |
101 head = self.badrev |
102 return self.__ancestors_and_nb_ancestors(head, stop)[0] |
102 return self.__ancestors_and_nb_ancestors(head, stop)[0] |
103 |
103 |
104 def __ancestors_and_nb_ancestors(self, head, stop=None): |
104 def __ancestors_and_nb_ancestors(self, head, stop=None): |
105 """ |
105 """ |
106 if stop is None then ancestors of goodrevs are used as |
106 if stop is None then ancestors of goodrevs are used as |
107 lower limit. |
107 lower limit. |
108 |
108 |
159 self.ui.warn("You should give at least one bad\n") |
159 self.ui.warn("You should give at least one bad\n") |
160 sys.exit(1) |
160 sys.exit(1) |
161 if not self.goodrevs: |
161 if not self.goodrevs: |
162 self.ui.warn("No good revision given\n") |
162 self.ui.warn("No good revision given\n") |
163 self.ui.warn("Assuming the first revision is good\n") |
163 self.ui.warn("Assuming the first revision is good\n") |
164 ancestors, num_ancestors = self.__ancestors_and_nb_ancestors(self.badrev) |
164 ancestors, num_ancestors = self.__ancestors_and_nb_ancestors( |
|
165 self.badrev) |
165 tot = len(ancestors) |
166 tot = len(ancestors) |
166 if tot == 1: |
167 if tot == 1: |
167 if ancestors.pop() != self.badrev: |
168 if ancestors.pop() != self.badrev: |
168 self.ui.warn("Could not find the first bad revision\n") |
169 self.ui.warn("Could not find the first bad revision\n") |
169 sys.exit(1) |
170 sys.exit(1) |
258 cmds.sort() |
259 cmds.sort() |
259 m = max([len(c) for c in cmds]) |
260 m = max([len(c) for c in cmds]) |
260 for cmd in cmds: |
261 for cmd in cmds: |
261 doc = cmdtable[cmd][0].__doc__.splitlines(0)[0].rstrip() |
262 doc = cmdtable[cmd][0].__doc__.splitlines(0)[0].rstrip() |
262 ui.write(" %-*s %s\n" % (m, cmd, doc)) |
263 ui.write(" %-*s %s\n" % (m, cmd, doc)) |
263 |
264 |
264 b = bisect(ui, repo) |
265 b = bisect(ui, repo) |
265 bisectcmdtable = { |
266 bisectcmdtable = { |
266 "init": (b.init, 0, "hg bisect init"), |
267 "init": (b.init, 0, "hg bisect init"), |
267 "bad": (b.autobad, 1, "hg bisect bad [<rev>]"), |
268 "bad": (b.autobad, 1, "hg bisect bad [<rev>]"), |
268 "good": (b.autogood, 1, "hg bisect good [<rev>]"), |
269 "good": (b.autogood, 1, "hg bisect good [<rev>]"), |
269 "next": (b.autonext, 0, "hg bisect next"), |
270 "next": (b.autonext, 0, "hg bisect next"), |
270 "reset": (b.reset, 0, "hg bisect reset"), |
271 "reset": (b.reset, 0, "hg bisect reset"), |
271 "help": (help_, 1, "hg bisect help [<subcommand>]"), |
272 "help": (help_, 1, "hg bisect help [<subcommand>]"), |
272 } |
273 } |
273 |
274 |
274 if not bisectcmdtable.has_key(cmd): |
275 if not bisectcmdtable.has_key(cmd): |
275 ui.warn("bisect: Unknown sub-command\n") |
276 ui.warn("bisect: Unknown sub-command\n") |
276 return help_() |
277 return help_() |
277 if len(args) > bisectcmdtable[cmd][1]: |
278 if len(args) > bisectcmdtable[cmd][1]: |
278 ui.warn("bisect: Too many arguments\n") |
279 ui.warn("bisect: Too many arguments\n") |
279 return help_() |
280 return help_() |
280 return bisectcmdtable[cmd][0](*args) |
281 return bisectcmdtable[cmd][0](*args) |
281 |
282 |
282 cmdtable = { |
283 cmdtable = { |
283 "bisect": (bisect_run, [], |
284 "bisect": (bisect_run, [], "hg bisect [help|init|reset|next|good|bad]"), |
284 "hg bisect [help|init|reset|next|good|bad]"), |
|
285 #"bisect-test": (test, [], "hg bisect-test rev"), |
285 #"bisect-test": (test, [], "hg bisect-test rev"), |
286 } |
286 } |