Mercurial > hg
annotate hgext/hbisect.py @ 5736:6e79d5e0e541
bisect: keep history of all bad revisions
- use a single state dict
- find the minimum bad revision
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 27 Dec 2007 23:55:40 -0600 |
parents | 9079081b8982 |
children | 6c8df073c3ee |
rev | line source |
---|---|
1855
0ba9dee8cfbd
Fixed spacing/indentation, removed #! script header, added short description.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1854
diff
changeset
|
1 # bisect extension for mercurial |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
2 # |
1861
65949d1c9bf7
Added copyright information to hbisect.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1856
diff
changeset
|
3 # Copyright 2005, 2006 Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
65949d1c9bf7
Added copyright information to hbisect.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1856
diff
changeset
|
4 # Inspired by git bisect, extension skeleton taken from mq.py. |
65949d1c9bf7
Added copyright information to hbisect.py
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1856
diff
changeset
|
5 # |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
7 # of the GNU General Public License, incorporated herein by reference. |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
8 |
3891 | 9 from mercurial.i18n import _ |
5731
19691160d7f5
bisect: remove unused imports
Matt Mackall <mpm@selenic.com>
parents:
5730
diff
changeset
|
10 from mercurial import hg, util, cmdutil |
19691160d7f5
bisect: remove unused imports
Matt Mackall <mpm@selenic.com>
parents:
5730
diff
changeset
|
11 import os, array |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
12 |
1559
59b3639df0a9
Convert all classes to new-style classes by deriving them from object.
Eric Hopper <hopper@omnifarious.org>
parents:
1367
diff
changeset
|
13 class bisect(object): |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
14 """dichotomic search in the DAG of changesets""" |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
15 def __init__(self, ui, repo): |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
16 self.repo = repo |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
17 self.ui = ui |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
18 self.state = {'good': [], 'bad': [], 'skip': []} |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
19 |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
20 p = self.repo.join("bisect.state") |
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
21 if os.path.exists(p): |
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
22 for l in self.repo.opener("bisect.state"): |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
23 kind, node = l[:-1].split() |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
24 node = self.repo.lookup(node) |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
25 if kind not in self.state: |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
26 raise util.Abort(_("unknown bisect kind %s") % kind) |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
27 self.state[kind].append(node) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
28 |
2735
07026da25ed8
hbisect.py: don't rely on __del__ to write the current state.
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
2348
diff
changeset
|
29 def write(self): |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
30 f = self.repo.opener("bisect.state", "w") |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
31 for kind in self.state: |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
32 for node in self.state[kind]: |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
33 f.write("%s %s\n" % (kind, hg.hex(node))) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
34 |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
35 def init(self): |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
36 """start a new bisection""" |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
37 p = self.repo.join("bisect.state") |
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
38 if os.path.exists(p): |
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
39 os.unlink(p) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
40 |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
41 def bisect(self): |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
42 cl = self.repo.changelog |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
43 clparents = cl.parentrevs |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
44 # only the earliest bad revision matters |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
45 badrev = min([cl.rev(n) for n in self.state['bad']]) |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
46 bad = cl.node(badrev) |
5719
7edf0501f643
bisect: remove usage of sets
Matt Mackall <mpm@selenic.com>
parents:
5718
diff
changeset
|
47 |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
48 # build ancestors array |
5726
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
49 ancestors = [[]] * (cl.count() + 1) # an extra for [-1] |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
50 |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
51 # clear good revs from array |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
52 for node in self.state['good']: |
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
53 ancestors[cl.rev(node)] = None |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
54 for rev in xrange(cl.count(), -1, -1): |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
55 if ancestors[rev] is None: |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
56 for prev in clparents(rev): |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
57 ancestors[prev] = None |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
58 |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
59 if ancestors[badrev] is None: |
4481
50a46ae14efb
hbisect: fix a typo in error message
TK Soh <teekaysoh@yahoo.com>
parents:
3643
diff
changeset
|
60 raise util.Abort(_("Inconsistent state, %s:%s is good and bad") |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
61 % (badrev, hg.short(bad))) |
5720
bd86c9f2f697
bisect: inline num_children function
Matt Mackall <mpm@selenic.com>
parents:
5719
diff
changeset
|
62 |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
63 # accumulate ancestor lists |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
64 for rev in xrange(badrev + 1): |
5726
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
65 if ancestors[rev] == []: |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
66 p1, p2 = clparents(rev) |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
67 a1, a2 = ancestors[p1], ancestors[p2] |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
68 if a1: |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
69 if a2: |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
70 # merge ancestor lists |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
71 a = dict.fromkeys(a2) |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
72 a.update(dict.fromkeys(a1)) |
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
73 a[rev] = None |
5727
1325ebc29e29
bisect: use array.array rather than lists for ancestor lists
Matt Mackall <mpm@selenic.com>
parents:
5726
diff
changeset
|
74 ancestors[rev] = array.array("l", a.keys()) |
5726
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
75 else: |
5727
1325ebc29e29
bisect: use array.array rather than lists for ancestor lists
Matt Mackall <mpm@selenic.com>
parents:
5726
diff
changeset
|
76 ancestors[rev] = a1 + array.array("l", [rev]) |
5726
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
77 elif a2: |
5727
1325ebc29e29
bisect: use array.array rather than lists for ancestor lists
Matt Mackall <mpm@selenic.com>
parents:
5726
diff
changeset
|
78 ancestors[rev] = a2 + array.array("l", [rev]) |
5726
19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
Matt Mackall <mpm@selenic.com>
parents:
5725
diff
changeset
|
79 else: |
5727
1325ebc29e29
bisect: use array.array rather than lists for ancestor lists
Matt Mackall <mpm@selenic.com>
parents:
5726
diff
changeset
|
80 ancestors[rev] = array.array("l", [rev]) |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
81 |
5724
13653ee67859
bisect: greatly simplify the ancestor accumulating loop
Matt Mackall <mpm@selenic.com>
parents:
5723
diff
changeset
|
82 if badrev not in ancestors[badrev]: |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
83 raise util.Abort(_("Could not find the first bad revision")) |
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
84 |
5721
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
85 # have we narrowed it down to one entry? |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
86 tot = len(ancestors[badrev]) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
87 if tot == 1: |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
88 return (bad, 0) |
5721
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
89 |
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
90 # find the best node to test |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
91 best_rev = None |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
92 best_len = -1 |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
93 skip = dict.fromkeys([cl.rev(n) for n in self.state['skip']]) |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
94 for n in ancestors[badrev]: |
5733 | 95 if n in skip: |
96 continue | |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
97 a = len(ancestors[n]) # number of ancestors |
5724
13653ee67859
bisect: greatly simplify the ancestor accumulating loop
Matt Mackall <mpm@selenic.com>
parents:
5723
diff
changeset
|
98 b = tot - a # number of non-ancestors |
5721
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
99 value = min(a, b) # how good is this test? |
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
100 if value > best_len: |
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
101 best_len = value |
5723
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
102 best_rev = n |
e3b09819496b
bisect: switch to rev-based calculation
Matt Mackall <mpm@selenic.com>
parents:
5722
diff
changeset
|
103 assert best_rev is not None |
5725
8114d4c915a7
bisect: turn ancestors into an array
Matt Mackall <mpm@selenic.com>
parents:
5724
diff
changeset
|
104 best_node = cl.node(best_rev) |
5721
8d63fa48d44a
bisect: clarify some bisection code
Matt Mackall <mpm@selenic.com>
parents:
5720
diff
changeset
|
105 |
5734
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
106 return (best_node, tot) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
107 |
5730
1542c4ce729b
bisect: rename autobad/good/next
Matt Mackall <mpm@selenic.com>
parents:
5729
diff
changeset
|
108 def next(self): |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
109 """find and update to the next revision to test""" |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
110 if self.state['good'] and self.state['bad']: |
5734
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
111 node, changesets = self.bisect() |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
112 |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
113 if changesets == 0: |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
114 self.ui.write(_("The first bad revision is:\n")) |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
115 displayer = cmdutil.show_changeset(self.ui, self.repo, {}) |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
116 displayer.show(changenode=node) |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
117 elif node is not None: |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
118 # compute the approximate number of remaining tests |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
119 tests, size = 0, 2 |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
120 while size <= changesets: |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
121 tests, size = tests + 1, size * 2 |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
122 rev = self.repo.changelog.rev(node) |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
123 self.ui.write(_("Testing changeset %s:%s " |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
124 "(%s changesets remaining, ~%s tests)\n") |
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
125 % (rev, hg.short(node), changesets, tests)) |
5733 | 126 cmdutil.bail_if_changed(self.repo) |
127 return hg.clean(self.repo, node) | |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
128 |
5730
1542c4ce729b
bisect: rename autobad/good/next
Matt Mackall <mpm@selenic.com>
parents:
5729
diff
changeset
|
129 def good(self, rev=None): |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
130 """mark revision as good and update to the next revision to test""" |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
131 self.state['good'].append(self.repo.lookup(rev or '.')) |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
132 self.write() |
5733 | 133 return self.next() |
134 | |
135 def skip(self, rev=None): | |
136 """mark revision as skipped and update to the next revision to test""" | |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
137 self.state['skip'].append(self.repo.lookup(rev or '.')) |
5733 | 138 self.write() |
139 return self.next() | |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
140 |
5730
1542c4ce729b
bisect: rename autobad/good/next
Matt Mackall <mpm@selenic.com>
parents:
5729
diff
changeset
|
141 def bad(self, rev=None): |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
142 """mark revision as bad and update to the next revision to test""" |
5736
6e79d5e0e541
bisect: keep history of all bad revisions
Matt Mackall <mpm@selenic.com>
parents:
5735
diff
changeset
|
143 self.state['bad'].append(self.repo.lookup(rev or '.')) |
5732
2060cad9fabd
bisect: simplify state handling and init
Matt Mackall <mpm@selenic.com>
parents:
5731
diff
changeset
|
144 self.write() |
5734
944b231fa0e7
bisect: move reporting out of core bisect function
Matt Mackall <mpm@selenic.com>
parents:
5733
diff
changeset
|
145 return self.next() |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
146 |
5735
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
147 def bisect_run(ui, repo, node=None, extra=None, |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
148 reset=None, good=None, bad=None, skip=None): |
5729
73646515c435
bisect: slightly improve the help message
Matt Mackall <mpm@selenic.com>
parents:
5728
diff
changeset
|
149 """Subdivision search of changesets |
4390
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
150 |
5729
73646515c435
bisect: slightly improve the help message
Matt Mackall <mpm@selenic.com>
parents:
5728
diff
changeset
|
151 This extension helps to find changesets which introduce problems. |
73646515c435
bisect: slightly improve the help message
Matt Mackall <mpm@selenic.com>
parents:
5728
diff
changeset
|
152 To use, mark the earliest changeset you know exhibits the problem |
4390
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
153 as bad, then mark the latest changeset which is free from the problem |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
154 as good. Bisect will update your working directory to a revision for |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
155 testing. Once you have performed tests, mark the working directory |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
156 as bad or good and bisect will either update to another candidate |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
157 changeset or announce that it has found the bad revision. |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
158 |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
159 Note: bisect expects bad revisions to be descendants of good revisions. |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
160 If you are looking for the point at which a problem was fixed, then make |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
161 the problem-free state "bad" and the problematic state "good." |
052062b98f26
Flesh out bisect help text
Brendan Cully <brendan@kublai.com>
parents:
3891
diff
changeset
|
162 |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
163 """ |
5735
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
164 # backward compatibility |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
165 if node in "good bad reset init".split(): |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
166 ui.warn(_("(use of 'hg bisect <cmd>' is deprecated)\n")) |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
167 cmd, node, extra = node, extra, None |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
168 if cmd == "good": |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
169 good = True |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
170 elif cmd == "bad": |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
171 bad = True |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
172 else: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
173 reset = True |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
174 elif extra or good + bad + skip + reset > 1: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
175 raise util.Abort("Incompatible arguments") |
1855
0ba9dee8cfbd
Fixed spacing/indentation, removed #! script header, added short description.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1854
diff
changeset
|
176 |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
177 b = bisect(ui, repo) |
5735
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
178 if good: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
179 return b.good(node) |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
180 elif bad: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
181 return b.bad(node) |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
182 elif skip: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
183 return b.skip(node) |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
184 elif reset: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
185 return b.init() |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
186 else: |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
187 return b.next() |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
188 |
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
189 cmdtable = { |
5735
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
190 "bisect": (bisect_run, |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
191 [('r', 'reset', False, _('reset bisect state')), |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
192 ('g', 'good', False, _('mark changeset good')), |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
193 ('b', 'bad', False, _('mark changeset bad')), |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
194 ('s', 'skip', False, _('skip testing changeset'))], |
9079081b8982
bisect: use more standard command syntax and help
Matt Mackall <mpm@selenic.com>
parents:
5734
diff
changeset
|
195 _("hg bisect [-gbsr] [REV]")) |
1367
a7678cbd7c28
bisect extension for mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
196 } |