30
32
# Filter ghosts, and null:
31
33
if NULL_REVISION in revision_graph:
32
34
del revision_graph[NULL_REVISION]
33
for key, parents in revision_graph.items():
35
for key, parents in revision_graph.iteritems():
34
36
revision_graph[key] = tuple(parent for parent in parents if parent
36
38
return revision_graph
39
41
def compute_whole_history_data(branch):
42
"""Compute _rev_info and _rev_indices for a branch.
44
See History.__doc__ for what these data structures mean.
42
48
last_revid = branch.last_revision()
44
log = logging.getLogger('loggerhead.%s' % branch.nick)
50
log = logging.getLogger('loggerhead.%s' %
51
(branch.get_config().get_nickname(),))
46
53
graph = branch.repository.get_graph()
47
parent_map = dict(((key, value) for key, value in
48
graph.iter_ancestry([last_revid]) if value is not None))
54
parent_map = dict((key, value) for key, value in
55
graph.iter_ancestry([last_revid]) if value is not None)
50
57
_revision_graph = _strip_NULL_ghosts(parent_map)
54
62
if is_null(last_revid):
57
65
_merge_sort = merge_sort(
58
66
_revision_graph, last_revid, generate_revno=True)
60
for (seq, revid, merge_depth, revno, end_of_merge) in _merge_sort:
61
_full_history.append(revid)
68
for info in _merge_sort:
69
seq, revid, merge_depth, revno, end_of_merge = info
62
70
revno_str = '.'.join(str(n) for n in revno)
63
_revno_revid[revno_str] = revid
64
_revision_info[revid] = (
65
seq, revid, merge_depth, revno_str, end_of_merge)
69
for revid in _revision_graph.keys():
70
if _revision_info[revid][2] == 0:
71
parents = _revision_graph[revid]
72
_rev_indices[revid] = len(_rev_info)
73
_rev_info.append([(seq, revid, merge_depth, revno_str, end_of_merge), (), parents])
75
for revid in _revision_graph.iterkeys():
76
if _rev_info[_rev_indices[revid]][0][2] == 0:
72
78
for parent in _revision_graph[revid]:
73
_where_merged.setdefault(parent, set()).add(revid)
75
log.info('built revision graph cache: %r secs' % (time.time() - z))
77
return (_revision_graph, _full_history, _revision_info,
78
_revno_revid, _merge_sort, _where_merged)
79
c = _rev_info[_rev_indices[parent]]
81
c[1] = c[1] + (revid,)
83
log.info('built revision graph cache: %r secs' % (time.time() - z,))
85
return (_rev_info, _rev_indices)