Mercurial > hg > mercurial-crew
comparison hgext/hbisect.py @ 5730:19cbe2aea2bc
bisect: switch individual ancestor lists from dict to list
This saves quite a lot of memory and increases performance
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 27 Dec 2007 23:55:39 -0600 |
parents | 8114d4c915a7 |
children | 1325ebc29e29 |
comparison
equal
deleted
inserted
replaced
5729:8114d4c915a7 | 5730:19cbe2aea2bc |
---|---|
77 if not self.goodnodes: | 77 if not self.goodnodes: |
78 self.ui.warn(_("No good revision given\n")) | 78 self.ui.warn(_("No good revision given\n")) |
79 self.ui.warn(_("Marking the first revision as good\n")) | 79 self.ui.warn(_("Marking the first revision as good\n")) |
80 | 80 |
81 # build ancestors array | 81 # build ancestors array |
82 ancestors = [{}] * (cl.count() + 1) # an extra for [-1] | 82 ancestors = [[]] * (cl.count() + 1) # an extra for [-1] |
83 | 83 |
84 # clear goodnodes from array | 84 # clear goodnodes from array |
85 for good in self.goodnodes: | 85 for good in self.goodnodes: |
86 ancestors[cl.rev(good)] = None | 86 ancestors[cl.rev(good)] = None |
87 for rev in xrange(cl.count(), -1, -1): | 87 for rev in xrange(cl.count(), -1, -1): |
93 raise util.Abort(_("Inconsistent state, %s:%s is good and bad") | 93 raise util.Abort(_("Inconsistent state, %s:%s is good and bad") |
94 % (badrev, hg.short(bad))) | 94 % (badrev, hg.short(bad))) |
95 | 95 |
96 # accumulate ancestor lists | 96 # accumulate ancestor lists |
97 for rev in xrange(badrev + 1): | 97 for rev in xrange(badrev + 1): |
98 if ancestors[rev] == {}: | 98 if ancestors[rev] == []: |
99 ancestors[rev] = {rev: 1} | 99 p1, p2 = clparents(rev) |
100 for p in clparents(rev): | 100 a1, a2 = ancestors[p1], ancestors[p2] |
101 if ancestors[p]: | 101 if a1: |
102 # add parent ancestors to our ancestors | 102 if a2: |
103 ancestors[rev].update(ancestors[p]) | 103 # merge ancestor lists |
104 a = dict.fromkeys(a2) | |
105 a.update(dict.fromkeys(a1)) | |
106 a[rev] = None | |
107 ancestors[rev] = a.keys() | |
108 else: | |
109 ancestors[rev] = a1 + [rev] | |
110 elif a2: | |
111 ancestors[rev] = a2 + [rev] | |
112 else: | |
113 ancestors[rev] = [rev] | |
104 | 114 |
105 if badrev not in ancestors[badrev]: | 115 if badrev not in ancestors[badrev]: |
106 raise util.Abort(_("Could not find the first bad revision")) | 116 raise util.Abort(_("Could not find the first bad revision")) |
107 | 117 |
108 # have we narrowed it down to one entry? | 118 # have we narrowed it down to one entry? |