Show More
@@ -31,19 +31,19 b' def toposort(ui, rl):' | |||||
31 | # build children and roots |
|
31 | # build children and roots | |
32 | ui.status(_('reading revs\n')) |
|
32 | ui.status(_('reading revs\n')) | |
33 | try: |
|
33 | try: | |
34 |
for |
|
34 | for rev in rl: | |
35 |
ui.progress(_('reading'), |
|
35 | ui.progress(_('reading'), rev, total=len(rl)) | |
36 |
children[ |
|
36 | children[rev] = [] | |
37 |
parents = [p for p in rl.parentrevs( |
|
37 | parents = [p for p in rl.parentrevs(rev) if p != node.nullrev] | |
38 | # in case of duplicate parents |
|
38 | # in case of duplicate parents | |
39 | if len(parents) == 2 and parents[0] == parents[1]: |
|
39 | if len(parents) == 2 and parents[0] == parents[1]: | |
40 | del parents[1] |
|
40 | del parents[1] | |
41 | for p in parents: |
|
41 | for p in parents: | |
42 | assert p in children |
|
42 | assert p in children | |
43 |
children[p].append( |
|
43 | children[p].append(rev) | |
44 |
|
44 | |||
45 | if len(parents) == 0: |
|
45 | if len(parents) == 0: | |
46 |
root.append( |
|
46 | root.append(rev) | |
47 | finally: |
|
47 | finally: | |
48 | ui.progress(_('reading'), None, total=len(rl)) |
|
48 | ui.progress(_('reading'), None, total=len(rl)) | |
49 |
|
49 | |||
@@ -52,34 +52,34 b' def toposort(ui, rl):' | |||||
52 | # the algorithm |
|
52 | # the algorithm | |
53 | ui.status(_('sorting revs\n')) |
|
53 | ui.status(_('sorting revs\n')) | |
54 | visit = root |
|
54 | visit = root | |
55 | ret = [] |
|
55 | result = [] | |
56 |
|
56 | |||
57 | # suboptimal: nodes whose predecessor is not first parent |
|
57 | # suboptimal: nodes whose predecessor is not first parent | |
58 | suboptimal = 0 |
|
58 | suboptimal = 0 | |
59 |
|
59 | |||
60 | while visit: |
|
60 | while visit: | |
61 |
|
|
61 | cur = visit.pop(0) | |
62 | # revlog will compute delta relative to ret[-1], so keep track |
|
62 | # revlog will compute delta relative to result[-1], so keep track | |
63 | # of nodes where this might result in a large delta |
|
63 | # of nodes where this might result in a large delta | |
64 |
parents = rl.parentrevs( |
|
64 | parents = rl.parentrevs(cur) | |
65 | if ret: |
|
65 | if result: | |
66 | if ret[-1] != parents[0]: |
|
66 | if result[-1] != parents[0]: | |
67 | suboptimal += 1 |
|
67 | suboptimal += 1 | |
68 |
|
68 | |||
69 |
ret.append( |
|
69 | result.append(cur) | |
70 |
if |
|
70 | if cur not in children: | |
71 | # This only happens if some node's p1 == p2, which can |
|
71 | # This only happens if some node's p1 == p2, which can | |
72 | # happen in the manifest in certain circumstances. |
|
72 | # happen in the manifest in certain circumstances. | |
73 | continue |
|
73 | continue | |
74 | next = [] |
|
74 | next = [] | |
75 |
for c in children.pop( |
|
75 | for c in children.pop(cur): | |
76 | parents_unseen = [p for p in rl.parentrevs(c) |
|
76 | parents_unseen = [p for p in rl.parentrevs(c) | |
77 | if p != node.nullrev and p in children] |
|
77 | if p != node.nullrev and p in children] | |
78 | if len(parents_unseen) == 0: |
|
78 | if len(parents_unseen) == 0: | |
79 | next.append(c) |
|
79 | next.append(c) | |
80 | visit = next + visit |
|
80 | visit = next + visit | |
81 | ui.note(_('%d suboptimal nodes\n') % suboptimal) |
|
81 | ui.note(_('%d suboptimal nodes\n') % suboptimal) | |
82 | return ret |
|
82 | return result | |
83 |
|
83 | |||
84 | def writerevs(ui, r1, r2, order, tr): |
|
84 | def writerevs(ui, r1, r2, order, tr): | |
85 |
|
85 |
General Comments 0
You need to be logged in to leave comments.
Login now