Mercurial > hg
changeset 5720:bd86c9f2f697
bisect: inline num_children function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 27 Dec 2007 23:55:39 -0600 |
parents | 7edf0501f643 |
children | 8d63fa48d44a |
files | hgext/hbisect.py |
diffstat | 1 files changed, 11 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/hbisect.py Thu Dec 27 23:55:39 2007 -0600 +++ b/hgext/hbisect.py Thu Dec 27 23:55:39 2007 -0600 @@ -82,25 +82,20 @@ continue stop.update(cl.reachable(g)) - def num_children(a): - """ - returns a dictionary with the following mapping - node -> [number of children, empty set] - """ - d = {a: [0, {}]} - for i in xrange(cl.rev(a)+1): - n = cl.node(i) - if n not in d: - d[n] = [0, {}] - parents = [p for p in cl.parents(n) if p != hg.nullid] - for p in parents: - d[p][0] += 1 - return d - if head in stop: raise util.Abort(_("Inconsistent state, %s:%s is good and bad") % (cl.rev(head), hg.short(head))) - n_child = num_children(head) + + # build a dict of node -> [number of children, {}] + n_child = {head: [0, {}]} + for i in xrange(cl.rev(head)+1): + n = cl.node(i) + if n not in d: + n_child[n] = [0, {}] + parents = [p for p in cl.parents(n) if p != hg.nullid] + for p in parents: + n_child[p][0] += 1 + for i in xrange(cl.rev(head)+1): n = cl.node(i) parents = [p for p in cl.parents(n) if p != hg.nullid]