1
# Cache the whole history data needed by loggerhead about a branch.
6
from bzrlib.revision import is_null, NULL_REVISION
7
from bzrlib.tsort import merge_sort
10
def _strip_NULL_ghosts(revision_graph):
12
Copied over from bzrlib meant as a temporary workaround for
15
# Filter ghosts, and null:
16
if NULL_REVISION in revision_graph:
17
del revision_graph[NULL_REVISION]
18
for key, parents in revision_graph.items():
19
revision_graph[key] = tuple(parent for parent in parents if parent
24
def compute_whole_history_data(branch):
27
last_revid = branch.last_revision()
29
log = logging.getLogger('loggerhead.%s' % (branch.nick,))
31
graph = branch.repository.get_graph()
32
parent_map = dict(((key, value) for key, value in
33
graph.iter_ancestry([last_revid]) if value is not None))
35
_revision_graph = _strip_NULL_ghosts(parent_map)
39
if is_null(last_revid):
42
_merge_sort = merge_sort(
43
_revision_graph, last_revid, generate_revno=True)
45
for (seq, revid, merge_depth, revno, end_of_merge) in _merge_sort:
46
_full_history.append(revid)
47
revno_str = '.'.join(str(n) for n in revno)
48
_revno_revid[revno_str] = revid
49
_revision_info[revid] = (
50
seq, revid, merge_depth, revno_str, end_of_merge)
54
for revid in _revision_graph.keys():
55
if _revision_info[revid][2] == 0:
57
for parent in _revision_graph[revid]:
58
_where_merged.setdefault(parent, set()).add(revid)
60
log.info('built revision graph cache: %r secs' % (time.time() - z,))
62
return (_revision_graph, _full_history, _revision_info,
63
_revno_revid, _merge_sort, _where_merged)