114
def _enumerate_with_merges(ancestry, graph, tip_revno, tip, reverse=False):
114
def _enumerate_with_merges(branch, ancestry, graph, tip_revno, tip,
115
116
"""Enumerate the revisions for the ancestry.
118
:param branch: The branch we care about
117
119
:param ancestry: A set of revisions that we care about
118
120
:param graph: A Graph which lets us find the parents for a revision
119
121
:param tip_revno: The revision number for the tip revision
126
128
if not ancestry: #Empty ancestry, no need to do any work
129
parent_map = graph.get_parent_map(ancestry)
131
mainline_revs, rev_nos, start_rev_id, end_rev_id = log._get_mainline_revs(
132
branch, None, tip_revno)
133
if not mainline_revs:
136
# This asks for all mainline revisions, which is size-of-history and
137
# should be addressed (but currently the only way to get correct
140
# mainline_revisions always includes an extra revision at the
141
# beginning, so don't request it.
142
parent_map = dict(((key, value) for key, value
143
in graph.iter_ancestry(mainline_revs[1:])
144
if value is not None))
130
145
# filter out ghosts; merge_sort errors on ghosts.
131
# XXX: is this needed here ? -- vila080903
146
# XXX: is this needed here ? -- vila080910
132
147
rev_graph = _mod_repository._strip_NULL_ghosts(parent_map)
133
# XXX: what if rev_graph is empty now ?
148
# XXX: what if rev_graph is empty now ? -- vila080910
134
149
merge_sorted_revisions = tsort.merge_sort(rev_graph, tip,
135
None, generate_revno=True)
136
# merge_sort calculate revno for the given graph, we have to recalculate
137
# the correct revno from the tip_revno.
138
ms_tip_revno = merge_sorted_revisions[0][3]
139
revno_delta = tip_revno - ms_tip_revno[0]
152
# Now that we got the correct revnos, keep only the relevant
154
merge_sorted_revisions = [
155
(s, revid, n, d, e) for s, revid, n, d, e in merge_sorted_revisions
156
if revid in ancestry]
141
158
merge_sorted_revisions = log.reverse_by_depth(merge_sorted_revisions)
143
160
for seq, rev_id, merge_depth, revno, end_of_merge in merge_sorted_revisions:
144
real_revno = (revno[0] + revno_delta,) + revno[1:]
145
revline.append(('.'.join(map(str, real_revno)), rev_id))
161
revline.append(('.'.join(map(str, revno)), rev_id))
173
189
local_extra, remote_extra = graph.find_difference(local_revision_id,
174
190
remote_revision_id)
175
191
if include_merges:
176
locals = _enumerate_with_merges(local_extra, graph, local_revno,
192
locals = _enumerate_with_merges(local_branch, local_extra,
177
194
local_revision_id, reverse)
178
remotes = _enumerate_with_merges(remote_extra, graph, remote_revno,
179
remote_revision_id, reverse)
195
remotes = _enumerate_with_merges(remote_branch, remote_extra,
197
remote_revision_id, reverse)
181
199
# Now that we have unique ancestors, compute just the mainline, and
182
200
# generate revnos for them.